Commit 704c39e9 authored by xuebingbing's avatar xuebingbing

1 增加编译机编译出的yaml-cpp 库

parent 8ad71d2b
No preview for this file type
No preview for this file type
set(PACKAGE_VERSION "0.6.3")
# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()
......@@ -5,10 +5,10 @@
# Compute paths
get_filename_component(YAML_CPP_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(YAML_CPP_INCLUDE_DIR "")
set(YAML_CPP_INCLUDE_DIR "${YAML_CPP_CMAKE_DIR}/../include")
# Our library dependencies (contains definitions for IMPORTED targets)
include("${YAML_CPP_CMAKE_DIR}/yaml-cpp-targets.cmake")
# These are IMPORTED targets created by yaml-cpp-targets.cmake
set(YAML_CPP_LIBRARIES "")
set(YAML_CPP_LIBRARIES "yaml-cpp")
#----------------------------------------------------------------
# Generated CMake target import file for configuration "Debug".
#----------------------------------------------------------------
# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)
# Import target "yaml-cpp" for configuration "Debug"
set_property(TARGET yaml-cpp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(yaml-cpp PROPERTIES
IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/lib/yaml-cpp.lib"
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/bin/yaml-cpp.dll"
)
list(APPEND _IMPORT_CHECK_TARGETS yaml-cpp )
list(APPEND _IMPORT_CHECK_FILES_FOR_yaml-cpp "${_IMPORT_PREFIX}/lib/yaml-cpp.lib" "${_IMPORT_PREFIX}/bin/yaml-cpp.dll" )
# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)
......@@ -44,8 +44,6 @@ unset(_expectedTargets)
# Compute the installation prefix relative to this file.
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
if(_IMPORT_PREFIX STREQUAL "/")
set(_IMPORT_PREFIX "")
endif()
......
......@@ -10,7 +10,7 @@
#include <cstddef>
namespace YAML {
using anchor_t = std::size_t;
typedef std::size_t anchor_t;
const anchor_t NullAnchor = 0;
}
......
......@@ -15,7 +15,7 @@ class Parser;
// GraphBuilderInterface
// . Abstraction of node creation
// . pParentNode is always nullptr or the return value of one of the NewXXX()
// . pParentNode is always NULL or the return value of one of the NewXXX()
// functions.
class GraphBuilderInterface {
public:
......@@ -73,9 +73,9 @@ class GraphBuilder : public GraphBuilderInterface {
typedef typename Impl::Map Map;
GraphBuilder(Impl &impl) : m_impl(impl) {
Map *pMap = nullptr;
Sequence *pSeq = nullptr;
Node *pNode = nullptr;
Map *pMap = NULL;
Sequence *pSeq = NULL;
Node *pNode = NULL;
// Type consistency checks
pNode = pMap;
......
......@@ -24,21 +24,21 @@ class EmitFromEvents : public EventHandler {
public:
EmitFromEvents(Emitter& emitter);
void OnDocumentStart(const Mark& mark) override;
void OnDocumentEnd() override;
virtual void OnDocumentStart(const Mark& mark);
virtual void OnDocumentEnd();
void OnNull(const Mark& mark, anchor_t anchor) override;
void OnAlias(const Mark& mark, anchor_t anchor) override;
void OnScalar(const Mark& mark, const std::string& tag,
anchor_t anchor, const std::string& value) override;
virtual void OnNull(const Mark& mark, anchor_t anchor);
virtual void OnAlias(const Mark& mark, anchor_t anchor);
virtual void OnScalar(const Mark& mark, const std::string& tag,
anchor_t anchor, const std::string& value);
void OnSequenceStart(const Mark& mark, const std::string& tag,
anchor_t anchor, EmitterStyle::value style) override;
void OnSequenceEnd() override;
virtual void OnSequenceStart(const Mark& mark, const std::string& tag,
anchor_t anchor, EmitterStyle::value style);
virtual void OnSequenceEnd();
void OnMapStart(const Mark& mark, const std::string& tag,
anchor_t anchor, EmitterStyle::value style) override;
void OnMapEnd() override;
virtual void OnMapStart(const Mark& mark, const std::string& tag,
anchor_t anchor, EmitterStyle::value style);
virtual void OnMapEnd();
private:
void BeginNode();
......
......@@ -50,7 +50,6 @@ class YAML_CPP_API Emitter {
bool SetOutputCharset(EMITTER_MANIP value);
bool SetStringFormat(EMITTER_MANIP value);
bool SetBoolFormat(EMITTER_MANIP value);
bool SetNullFormat(EMITTER_MANIP value);
bool SetIntBase(EMITTER_MANIP value);
bool SetSeqFormat(EMITTER_MANIP value);
bool SetMapFormat(EMITTER_MANIP value);
......@@ -59,7 +58,6 @@ class YAML_CPP_API Emitter {
bool SetPostCommentIndent(std::size_t n);
bool SetFloatPrecision(std::size_t n);
bool SetDoublePrecision(std::size_t n);
void RestoreGlobalModifiedSettings();
// local setters
Emitter& SetLocalValue(EMITTER_MANIP value);
......@@ -125,7 +123,6 @@ class YAML_CPP_API Emitter {
void SpaceOrIndentTo(bool requireSpace, std::size_t indent);
const char* ComputeFullBoolName(bool b) const;
const char* ComputeNullName() const;
bool CanEmitNewline() const;
private:
......@@ -167,12 +164,13 @@ inline Emitter& Emitter::WriteStreamable(T value) {
std::isnan(value)) {
special = true;
stream << ".nan";
} else if (std::numeric_limits<T>::has_infinity && std::isinf(value)) {
special = true;
if (std::signbit(value)) {
stream << "-.inf";
} else {
} else if (std::numeric_limits<T>::has_infinity) {
if (value == std::numeric_limits<T>::infinity()) {
special = true;
stream << ".inf";
} else if (value == -std::numeric_limits<T>::infinity()) {
special = true;
stream << "-.inf";
}
}
}
......
......@@ -19,7 +19,6 @@ enum EMITTER_MANIP {
// output character set
EmitNonAscii,
EscapeNonAscii,
EscapeAsJson,
// string manipulators
// Auto, // duplicate
......@@ -27,12 +26,6 @@ enum EMITTER_MANIP {
DoubleQuoted,
Literal,
// null manipulators
LowerNull,
UpperNull,
CamelNull,
TildeNull,
// bool manipulators
YesNoBool, // yes, no
TrueFalseBool, // true, false
......@@ -81,14 +74,14 @@ struct _Alias {
std::string content;
};
inline _Alias Alias(const std::string& content) { return _Alias(content); }
inline _Alias Alias(const std::string content) { return _Alias(content); }
struct _Anchor {
_Anchor(const std::string& content_) : content(content_) {}
std::string content;
};
inline _Anchor Anchor(const std::string& content) { return _Anchor(content); }
inline _Anchor Anchor(const std::string content) { return _Anchor(content); }
struct _Tag {
struct Type {
......@@ -103,11 +96,11 @@ struct _Tag {
Type::value type;
};
inline _Tag VerbatimTag(const std::string& content) {
inline _Tag VerbatimTag(const std::string content) {
return _Tag("", content, _Tag::Type::Verbatim);
}
inline _Tag LocalTag(const std::string& content) {
inline _Tag LocalTag(const std::string content) {
return _Tag("", content, _Tag::Type::PrimaryHandle);
}
......@@ -115,7 +108,7 @@ inline _Tag LocalTag(const std::string& prefix, const std::string content) {
return _Tag(prefix, content, _Tag::Type::NamedHandle);
}
inline _Tag SecondaryTag(const std::string& content) {
inline _Tag SecondaryTag(const std::string content) {
return _Tag("", content, _Tag::Type::NamedHandle);
}
......@@ -124,7 +117,7 @@ struct _Comment {
std::string content;
};
inline _Comment Comment(const std::string& content) { return _Comment(content); }
inline _Comment Comment(const std::string content) { return _Comment(content); }
struct _Precision {
_Precision(int floatPrecision_, int doublePrecision_)
......
......@@ -17,7 +17,7 @@ struct Mark;
class EventHandler {
public:
virtual ~EventHandler() = default;
virtual ~EventHandler() {}
virtual void OnDocumentStart(const Mark& mark) = 0;
virtual void OnDocumentEnd() = 0;
......
......@@ -8,12 +8,19 @@
#endif
#include "yaml-cpp/mark.h"
#include "yaml-cpp/noexcept.h"
#include "yaml-cpp/traits.h"
#include <sstream>
#include <stdexcept>
#include <string>
// This is here for compatibility with older versions of Visual Studio
// which don't support noexcept
#if defined(_MSC_VER) && _MSC_VER < 1900
#define YAML_CPP_NOEXCEPT _NOEXCEPT
#else
#define YAML_CPP_NOEXCEPT noexcept
#endif
namespace YAML {
// error messages
namespace ErrorMsg {
......@@ -100,12 +107,6 @@ inline const std::string KEY_NOT_FOUND_WITH_KEY(const std::string& key) {
return stream.str();
}
inline const std::string KEY_NOT_FOUND_WITH_KEY(const char* key) {
std::stringstream stream;
stream << KEY_NOT_FOUND << ": " << key;
return stream.str();
}
template <typename T>
inline const std::string KEY_NOT_FOUND_WITH_KEY(
const T& key, typename enable_if<is_numeric<T>>::type* = 0) {
......@@ -126,12 +127,6 @@ inline const std::string BAD_SUBSCRIPT_WITH_KEY(const std::string& key) {
return stream.str();
}
inline const std::string BAD_SUBSCRIPT_WITH_KEY(const char* key) {
std::stringstream stream;
stream << BAD_SUBSCRIPT << " (key: \"" << key << "\")";
return stream.str();
}
template <typename T>
inline const std::string BAD_SUBSCRIPT_WITH_KEY(
const T& key, typename enable_if<is_numeric<T>>::type* = nullptr) {
......@@ -148,13 +143,13 @@ inline const std::string INVALID_NODE_WITH_KEY(const std::string& key) {
stream << "invalid node; first invalid key: \"" << key << "\"";
return stream.str();
}
} // namespace ErrorMsg
}
class YAML_CPP_API Exception : public std::runtime_error {
public:
Exception(const Mark& mark_, const std::string& msg_)
: std::runtime_error(build_what(mark_, msg_)), mark(mark_), msg(msg_) {}
~Exception() YAML_CPP_NOEXCEPT override;
virtual ~Exception() YAML_CPP_NOEXCEPT;
Exception(const Exception&) = default;
......@@ -180,7 +175,7 @@ class YAML_CPP_API ParserException : public Exception {
ParserException(const Mark& mark_, const std::string& msg_)
: Exception(mark_, msg_) {}
ParserException(const ParserException&) = default;
~ParserException() YAML_CPP_NOEXCEPT override;
virtual ~ParserException() YAML_CPP_NOEXCEPT;
};
class YAML_CPP_API RepresentationException : public Exception {
......@@ -188,7 +183,7 @@ class YAML_CPP_API RepresentationException : public Exception {
RepresentationException(const Mark& mark_, const std::string& msg_)
: Exception(mark_, msg_) {}
RepresentationException(const RepresentationException&) = default;
~RepresentationException() YAML_CPP_NOEXCEPT override;
virtual ~RepresentationException() YAML_CPP_NOEXCEPT;
};
// representation exceptions
......@@ -197,7 +192,7 @@ class YAML_CPP_API InvalidScalar : public RepresentationException {
InvalidScalar(const Mark& mark_)
: RepresentationException(mark_, ErrorMsg::INVALID_SCALAR) {}
InvalidScalar(const InvalidScalar&) = default;
~InvalidScalar() YAML_CPP_NOEXCEPT override;
virtual ~InvalidScalar() YAML_CPP_NOEXCEPT;
};
class YAML_CPP_API KeyNotFound : public RepresentationException {
......@@ -207,7 +202,7 @@ class YAML_CPP_API KeyNotFound : public RepresentationException {
: RepresentationException(mark_, ErrorMsg::KEY_NOT_FOUND_WITH_KEY(key_)) {
}
KeyNotFound(const KeyNotFound&) = default;
~KeyNotFound() YAML_CPP_NOEXCEPT override;
virtual ~KeyNotFound() YAML_CPP_NOEXCEPT;
};
template <typename T>
......@@ -215,7 +210,7 @@ class YAML_CPP_API TypedKeyNotFound : public KeyNotFound {
public:
TypedKeyNotFound(const Mark& mark_, const T& key_)
: KeyNotFound(mark_, key_), key(key_) {}
~TypedKeyNotFound() YAML_CPP_NOEXCEPT override = default;
virtual ~TypedKeyNotFound() YAML_CPP_NOEXCEPT {}
T key;
};
......@@ -228,11 +223,11 @@ inline TypedKeyNotFound<T> MakeTypedKeyNotFound(const Mark& mark,
class YAML_CPP_API InvalidNode : public RepresentationException {
public:
InvalidNode(const std::string& key)
InvalidNode(std::string key)
: RepresentationException(Mark::null_mark(),
ErrorMsg::INVALID_NODE_WITH_KEY(key)) {}
InvalidNode(const InvalidNode&) = default;
~InvalidNode() YAML_CPP_NOEXCEPT override;
virtual ~InvalidNode() YAML_CPP_NOEXCEPT;
};
class YAML_CPP_API BadConversion : public RepresentationException {
......@@ -240,7 +235,7 @@ class YAML_CPP_API BadConversion : public RepresentationException {
explicit BadConversion(const Mark& mark_)
: RepresentationException(mark_, ErrorMsg::BAD_CONVERSION) {}
BadConversion(const BadConversion&) = default;
~BadConversion() YAML_CPP_NOEXCEPT override;
virtual ~BadConversion() YAML_CPP_NOEXCEPT;
};
template <typename T>
......@@ -254,16 +249,17 @@ class YAML_CPP_API BadDereference : public RepresentationException {
BadDereference()
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_DEREFERENCE) {}
BadDereference(const BadDereference&) = default;
~BadDereference() YAML_CPP_NOEXCEPT override;
virtual ~BadDereference() YAML_CPP_NOEXCEPT;
};
class YAML_CPP_API BadSubscript : public RepresentationException {
public:
template <typename Key>
BadSubscript(const Mark& mark_, const Key& key)
: RepresentationException(mark_, ErrorMsg::BAD_SUBSCRIPT_WITH_KEY(key)) {}
BadSubscript(const Key& key)
: RepresentationException(Mark::null_mark(),
ErrorMsg::BAD_SUBSCRIPT_WITH_KEY(key)) {}
BadSubscript(const BadSubscript&) = default;
~BadSubscript() YAML_CPP_NOEXCEPT override;
virtual ~BadSubscript() YAML_CPP_NOEXCEPT;
};
class YAML_CPP_API BadPushback : public RepresentationException {
......@@ -271,7 +267,7 @@ class YAML_CPP_API BadPushback : public RepresentationException {
BadPushback()
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_PUSHBACK) {}
BadPushback(const BadPushback&) = default;
~BadPushback() YAML_CPP_NOEXCEPT override;
virtual ~BadPushback() YAML_CPP_NOEXCEPT;
};
class YAML_CPP_API BadInsert : public RepresentationException {
......@@ -279,7 +275,7 @@ class YAML_CPP_API BadInsert : public RepresentationException {
BadInsert()
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_INSERT) {}
BadInsert(const BadInsert&) = default;
~BadInsert() YAML_CPP_NOEXCEPT override;
virtual ~BadInsert() YAML_CPP_NOEXCEPT;
};
class YAML_CPP_API EmitterException : public Exception {
......@@ -287,17 +283,17 @@ class YAML_CPP_API EmitterException : public Exception {
EmitterException(const std::string& msg_)
: Exception(Mark::null_mark(), msg_) {}
EmitterException(const EmitterException&) = default;
~EmitterException() YAML_CPP_NOEXCEPT override;
virtual ~EmitterException() YAML_CPP_NOEXCEPT;
};
class YAML_CPP_API BadFile : public Exception {
public:
explicit BadFile(const std::string& filename)
: Exception(Mark::null_mark(),
std::string(ErrorMsg::BAD_FILE) + ": " + filename) {}
BadFile() : Exception(Mark::null_mark(), ErrorMsg::BAD_FILE) {}
BadFile(const BadFile&) = default;
~BadFile() YAML_CPP_NOEXCEPT override;
virtual ~BadFile() YAML_CPP_NOEXCEPT;
};
} // namespace YAML
}
#undef YAML_CPP_NOEXCEPT
#endif // EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
......@@ -8,12 +8,10 @@
#endif
#include <array>
#include <cmath>
#include <limits>
#include <list>
#include <map>
#include <sstream>
#include <type_traits>
#include <vector>
#include "yaml-cpp/binary.h"
......@@ -23,7 +21,6 @@
#include "yaml-cpp/node/type.h"
#include "yaml-cpp/null.h"
namespace YAML {
class Binary;
struct _Null;
......@@ -74,17 +71,12 @@ struct convert<std::string> {
// C-strings can only be encoded
template <>
struct convert<const char*> {
static Node encode(const char* rhs) { return Node(rhs); }
};
template <>
struct convert<char*> {
static Node encode(const char* rhs) { return Node(rhs); }
static Node encode(const char*& rhs) { return Node(rhs); }
};
template <std::size_t N>
struct convert<char[N]> {
static Node encode(const char* rhs) { return Node(rhs); }
struct convert<const char[N]> {
static Node encode(const char(&rhs)[N]) { return Node(rhs); }
};
template <>
......@@ -96,98 +88,43 @@ struct convert<_Null> {
}
};
namespace conversion {
template <typename T>
typename std::enable_if< std::is_floating_point<T>::value, void>::type
inner_encode(const T& rhs, std::stringstream& stream){
if (std::isnan(rhs)) {
stream << ".nan";
} else if (std::isinf(rhs)) {
if (std::signbit(rhs)) {
stream << "-.inf";
} else {
stream << ".inf";
}
} else {
stream << rhs;
}
}
template <typename T>
typename std::enable_if<!std::is_floating_point<T>::value, void>::type
inner_encode(const T& rhs, std::stringstream& stream){
stream << rhs;
}
template <typename T>
typename std::enable_if<(std::is_same<T, unsigned char>::value ||
std::is_same<T, signed char>::value), bool>::type
ConvertStreamTo(std::stringstream& stream, T& rhs) {
int num;
if ((stream >> std::noskipws >> num) && (stream >> std::ws).eof()) {
if (num >= (std::numeric_limits<T>::min)() &&
num <= (std::numeric_limits<T>::max)()) {
rhs = num;
return true;
}
}
return false;
}
template <typename T>
typename std::enable_if<!(std::is_same<T, unsigned char>::value ||
std::is_same<T, signed char>::value), bool>::type
ConvertStreamTo(std::stringstream& stream, T& rhs) {
if ((stream >> std::noskipws >> rhs) && (stream >> std::ws).eof()) {
return true;
}
return false;
}
}
#define YAML_DEFINE_CONVERT_STREAMABLE(type, negative_op) \
template <> \
struct convert<type> { \
\
static Node encode(const type& rhs) { \
std::stringstream stream; \
stream.precision(std::numeric_limits<type>::max_digits10); \
conversion::inner_encode(rhs, stream); \
return Node(stream.str()); \
} \
\
static bool decode(const Node& node, type& rhs) { \
if (node.Type() != NodeType::Scalar) { \
return false; \
} \
const std::string& input = node.Scalar(); \
std::stringstream stream(input); \
stream.unsetf(std::ios::dec); \
if ((stream.peek() == '-') && std::is_unsigned<type>::value) { \
return false; \
} \
if (conversion::ConvertStreamTo(stream, rhs)) { \
return true; \
} \
if (std::numeric_limits<type>::has_infinity) { \
if (conversion::IsInfinity(input)) { \
rhs = std::numeric_limits<type>::infinity(); \
return true; \
} else if (conversion::IsNegativeInfinity(input)) { \
rhs = negative_op std::numeric_limits<type>::infinity(); \
return true; \
} \
} \
\
if (std::numeric_limits<type>::has_quiet_NaN) { \
if (conversion::IsNaN(input)) { \
rhs = std::numeric_limits<type>::quiet_NaN(); \
return true; \
} \
} \
\
return false; \
} \
#define YAML_DEFINE_CONVERT_STREAMABLE(type, negative_op) \
template <> \
struct convert<type> { \
static Node encode(const type& rhs) { \
std::stringstream stream; \
stream.precision(std::numeric_limits<type>::max_digits10); \
stream << rhs; \
return Node(stream.str()); \
} \
\
static bool decode(const Node& node, type& rhs) { \
if (node.Type() != NodeType::Scalar) \
return false; \
const std::string& input = node.Scalar(); \
std::stringstream stream(input); \
stream.unsetf(std::ios::dec); \
if ((stream >> std::noskipws >> rhs) && (stream >> std::ws).eof()) \
return true; \
if (std::numeric_limits<type>::has_infinity) { \
if (conversion::IsInfinity(input)) { \
rhs = std::numeric_limits<type>::infinity(); \
return true; \
} else if (conversion::IsNegativeInfinity(input)) { \
rhs = negative_op std::numeric_limits<type>::infinity(); \
return true; \
} \
} \
\
if (std::numeric_limits<type>::has_quiet_NaN) { \
if (conversion::IsNaN(input)) { \
rhs = std::numeric_limits<type>::quiet_NaN(); \
return true; \
} \
} \
\
return false; \
} \
}
#define YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(type) \
......@@ -226,78 +163,81 @@ struct convert<bool> {
};
// std::map
template <typename K, typename V, typename C, typename A>
struct convert<std::map<K, V, C, A>> {
static Node encode(const std::map<K, V, C, A>& rhs) {
template <typename K, typename V>
struct convert<std::map<K, V>> {
static Node encode(const std::map<K, V>& rhs) {
Node node(NodeType::Map);
for (const auto& element : rhs)
node.force_insert(element.first, element.second);
for (typename std::map<K, V>::const_iterator it = rhs.begin();
it != rhs.end(); ++it)
node.force_insert(it->first, it->second);
return node;
}
static bool decode(const Node& node, std::map<K, V, C, A>& rhs) {
static bool decode(const Node& node, std::map<K, V>& rhs) {
if (!node.IsMap())
return false;
rhs.clear();
for (const auto& element : node)
for (const_iterator it = node.begin(); it != node.end(); ++it)
#if defined(__GNUC__) && __GNUC__ < 4
// workaround for GCC 3:
rhs[element.first.template as<K>()] = element.second.template as<V>();
rhs[it->first.template as<K>()] = it->second.template as<V>();
#else
rhs[element.first.as<K>()] = element.second.as<V>();
rhs[it->first.as<K>()] = it->second.as<V>();
#endif
return true;
}
};
// std::vector
template <typename T, typename A>
struct convert<std::vector<T, A>> {
static Node encode(const std::vector<T, A>& rhs) {
template <typename T>
struct convert<std::vector<T>> {
static Node encode(const std::vector<T>& rhs) {
Node node(NodeType::Sequence);
for (const auto& element : rhs)
node.push_back(element);
for (typename std::vector<T>::const_iterator it = rhs.begin();
it != rhs.end(); ++it)
node.push_back(*it);
return node;
}
static bool decode(const Node& node, std::vector<T, A>& rhs) {
static bool decode(const Node& node, std::vector<T>& rhs) {
if (!node.IsSequence())
return false;
rhs.clear();
for (const auto& element : node)
for (const_iterator it = node.begin(); it != node.end(); ++it)
#if defined(__GNUC__) && __GNUC__ < 4
// workaround for GCC 3:
rhs.push_back(element.template as<T>());
rhs.push_back(it->template as<T>());
#else
rhs.push_back(element.as<T>());
rhs.push_back(it->as<T>());
#endif
return true;
}
};
// std::list
template <typename T, typename A>
struct convert<std::list<T,A>> {
static Node encode(const std::list<T,A>& rhs) {
template <typename T>
struct convert<std::list<T>> {
static Node encode(const std::list<T>& rhs) {
Node node(NodeType::Sequence);
for (const auto& element : rhs)
node.push_back(element);
for (typename std::list<T>::const_iterator it = rhs.begin();
it != rhs.end(); ++it)
node.push_back(*it);
return node;
}
static bool decode(const Node& node, std::list<T,A>& rhs) {
static bool decode(const Node& node, std::list<T>& rhs) {
if (!node.IsSequence())
return false;
rhs.clear();
for (const auto& element : node)
for (const_iterator it = node.begin(); it != node.end(); ++it)
#if defined(__GNUC__) && __GNUC__ < 4
// workaround for GCC 3:
rhs.push_back(element.template as<T>());
rhs.push_back(it->template as<T>());
#else
rhs.push_back(element.as<T>());
rhs.push_back(it->as<T>());
#endif
return true;
}
......
#ifndef NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif
namespace YAML {
namespace detail {
struct unspecified_bool {
struct NOT_ALLOWED;
static void true_value(NOT_ALLOWED*) {}
};
typedef void (*unspecified_bool_type)(unspecified_bool::NOT_ALLOWED*);
}
}
#define YAML_CPP_OPERATOR_BOOL() \
operator YAML::detail::unspecified_bool_type() const { \
return this->operator!() ? 0 \
: &YAML::detail::unspecified_bool::true_value; \
}
#endif // NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
......@@ -9,8 +9,6 @@
#include "yaml-cpp/node/detail/node.h"
#include "yaml-cpp/node/detail/node_data.h"
#include <algorithm>
#include <type_traits>
namespace YAML {
......@@ -35,7 +33,7 @@ struct get_idx<Key,
static node* get(std::vector<node*>& sequence, const Key& key,
shared_memory_holder pMemory) {
if (key > sequence.size() || (key > 0 && !sequence[key - 1]->is_defined()))
return nullptr;
return 0;
if (key == sequence.size())
sequence.push_back(&pMemory->create_node());
return sequence[key];
......@@ -60,9 +58,7 @@ struct get_idx<Key, typename std::enable_if<std::is_signed<Key>::value>::type> {
template <typename Key, typename Enable = void>
struct remove_idx {
static bool remove(std::vector<node*>&, const Key&, std::size_t&) {
return false;
}
static bool remove(std::vector<node*>&, const Key&) { return false; }
};
template <typename Key>
......@@ -70,15 +66,11 @@ struct remove_idx<
Key, typename std::enable_if<std::is_unsigned<Key>::value &&
!std::is_same<Key, bool>::value>::type> {
static bool remove(std::vector<node*>& sequence, const Key& key,
std::size_t& seqSize) {
static bool remove(std::vector<node*>& sequence, const Key& key) {
if (key >= sequence.size()) {
return false;
} else {
sequence.erase(sequence.begin() + key);
if (seqSize > key) {
--seqSize;
}
return true;
}
}
......@@ -88,10 +80,9 @@ template <typename Key>
struct remove_idx<Key,
typename std::enable_if<std::is_signed<Key>::value>::type> {
static bool remove(std::vector<node*>& sequence, const Key& key,
std::size_t& seqSize) {
static bool remove(std::vector<node*>& sequence, const Key& key) {
return key >= 0 ? remove_idx<std::size_t>::remove(
sequence, static_cast<std::size_t>(key), seqSize)
sequence, static_cast<std::size_t>(key))
: false;
}
};
......@@ -106,11 +97,7 @@ inline bool node::equals(const T& rhs, shared_memory_holder pMemory) {
}
inline bool node::equals(const char* rhs, shared_memory_holder pMemory) {
std::string lhs;
if (convert<std::string>::decode(Node(*this, std::move(pMemory)), lhs)) {
return lhs == rhs;
}
return false;
return equals<std::string>(rhs, pMemory);
}
// indexing
......@@ -128,14 +115,16 @@ inline node* node_data::get(const Key& key,
return pNode;
return nullptr;
case NodeType::Scalar:
throw BadSubscript(m_mark, key);
throw BadSubscript(key);
}
auto it = std::find_if(m_map.begin(), m_map.end(), [&](const kv_pair m) {
return m.first->equals(key, pMemory);
});
for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
if (it->first->equals(key, pMemory)) {
return it->second;
}
}
return it != m_map.end() ? it->second : nullptr;
return nullptr;
}
template <typename Key>
......@@ -154,15 +143,13 @@ inline node& node_data::get(const Key& key, shared_memory_holder pMemory) {
convert_to_map(pMemory);
break;
case NodeType::Scalar:
throw BadSubscript(m_mark, key);
throw BadSubscript(key);
}
auto it = std::find_if(m_map.begin(), m_map.end(), [&](const kv_pair m) {
return m.first->equals(key, pMemory);
});
if (it != m_map.end()) {
return *it->second;
for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
if (it->first->equals(key, pMemory)) {
return *it->second;
}
}
node& k = convert_to_node(key, pMemory);
......@@ -174,10 +161,8 @@ inline node& node_data::get(const Key& key, shared_memory_holder pMemory) {
template <typename Key>
inline bool node_data::remove(const Key& key, shared_memory_holder pMemory) {
if (m_type == NodeType::Sequence) {
return remove_idx<Key>::remove(m_sequence, key, m_seqSize);
}
if (m_type == NodeType::Map) {
return remove_idx<Key>::remove(m_sequence, key);
} else if (m_type == NodeType::Map) {
kv_pairs::iterator it = m_undefinedPairs.begin();
while (it != m_undefinedPairs.end()) {
kv_pairs::iterator jt = std::next(it);
......@@ -187,13 +172,11 @@ inline bool node_data::remove(const Key& key, shared_memory_holder pMemory) {
it = jt;
}
auto iter = std::find_if(m_map.begin(), m_map.end(), [&](const kv_pair m) {
return m.first->equals(key, pMemory);
});
if (iter != m_map.end()) {
m_map.erase(iter);
return true;
for (node_map::iterator iter = m_map.begin(); iter != m_map.end(); ++iter) {
if (iter->first->equals(key, pMemory)) {
m_map.erase(iter);
return true;
}
}
}
......
......@@ -26,7 +26,7 @@ class iterator_base {
template <typename>
friend class iterator_base;
struct enabler {};
using base_type = node_iterator;
typedef node_iterator base_type;
struct proxy {
explicit proxy(const V& x) : m_ref(x) {}
......
......@@ -20,8 +20,8 @@ template <typename V>
class iterator_base;
}
using iterator = detail::iterator_base<detail::iterator_value>;
using const_iterator = detail::iterator_base<const detail::iterator_value>;
typedef detail::iterator_base<detail::iterator_value> iterator;
typedef detail::iterator_base<const detail::iterator_value> const_iterator;
}
#endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66
......@@ -27,7 +27,7 @@ class YAML_CPP_API memory {
void merge(const memory& rhs);
private:
using Nodes = std::set<shared_node>;
typedef std::set<shared_node> Nodes;
Nodes m_nodes;
};
......
......@@ -13,18 +13,12 @@
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/type.h"
#include <set>
#include <atomic>
namespace YAML {
namespace detail {
class node {
private:
struct less {
bool operator ()(const node* l, const node* r) const {return l->m_index < r->m_index;}
};
public:
node() : m_pRef(new node_ref), m_dependencies{}, m_index{} {}
node() : m_pRef(new node_ref), m_dependencies{} {}
node(const node&) = delete;
node& operator=(const node&) = delete;
......@@ -48,8 +42,9 @@ class node {
return;
m_pRef->mark_defined();
for (node* dependency : m_dependencies)
dependency->mark_defined();
for (nodes::iterator it = m_dependencies.begin();
it != m_dependencies.end(); ++it)
(*it)->mark_defined();
m_dependencies.clear();
}
......@@ -114,7 +109,6 @@ class node {
void push_back(node& input, shared_memory_holder pMemory) {
m_pRef->push_back(input, pMemory);
input.add_dependency(*this);
m_index = m_amount.fetch_add(1);
}
void insert(node& key, node& value, shared_memory_holder pMemory) {
m_pRef->insert(key, value, pMemory);
......@@ -126,7 +120,7 @@ class node {
template <typename Key>
node* get(const Key& key, shared_memory_holder pMemory) const {
// NOTE: this returns a non-const node so that the top-level Node can wrap
// it, and returns a pointer so that it can be nullptr (if there is no such
// it, and returns a pointer so that it can be NULL (if there is no such
// key).
return static_cast<const node_ref&>(*m_pRef).get(key, pMemory);
}
......@@ -143,7 +137,7 @@ class node {
node* get(node& key, shared_memory_holder pMemory) const {
// NOTE: this returns a non-const node so that the top-level Node can wrap
// it, and returns a pointer so that it can be nullptr (if there is no such
// it, and returns a pointer so that it can be NULL (if there is no such
// key).
return static_cast<const node_ref&>(*m_pRef).get(key, pMemory);
}
......@@ -166,10 +160,8 @@ class node {
private:
shared_node_ref m_pRef;
using nodes = std::set<node*, less>;
typedef std::set<node*> nodes;
nodes m_dependencies;
size_t m_index;
static std::atomic<size_t> m_amount;
};
} // namespace detail
} // namespace YAML
......
......@@ -60,8 +60,8 @@ class YAML_CPP_API node_data {
node_iterator end();
// sequence
void push_back(node& node, const shared_memory_holder& pMemory);
void insert(node& key, node& value, const shared_memory_holder& pMemory);
void push_back(node& node, shared_memory_holder pMemory);
void insert(node& key, node& value, shared_memory_holder pMemory);
// indexing
template <typename Key>
......@@ -71,9 +71,9 @@ class YAML_CPP_API node_data {
template <typename Key>
bool remove(const Key& key, shared_memory_holder pMemory);
node* get(node& key, const shared_memory_holder& pMemory) const;
node& get(node& key, const shared_memory_holder& pMemory);
bool remove(node& key, const shared_memory_holder& pMemory);
node* get(node& key, shared_memory_holder pMemory) const;
node& get(node& key, shared_memory_holder pMemory);
bool remove(node& key, shared_memory_holder pMemory);
// map
template <typename Key, typename Value>
......@@ -91,8 +91,8 @@ class YAML_CPP_API node_data {
void reset_map();
void insert_map_pair(node& key, node& value);
void convert_to_map(const shared_memory_holder& pMemory);
void convert_sequence_to_map(const shared_memory_holder& pMemory);
void convert_to_map(shared_memory_holder pMemory);
void convert_sequence_to_map(shared_memory_holder pMemory);
template <typename T>
static node& convert_to_node(const T& rhs, shared_memory_holder pMemory);
......@@ -108,17 +108,17 @@ class YAML_CPP_API node_data {
std::string m_scalar;
// sequence
using node_seq = std::vector<node *>;
typedef std::vector<node*> node_seq;
node_seq m_sequence;
mutable std::size_t m_seqSize;
// map
using node_map = std::vector<std::pair<node*, node*>>;
typedef std::vector<std::pair<node*, node*>> node_map;
node_map m_map;
using kv_pair = std::pair<node*, node*>;
using kv_pairs = std::list<kv_pair>;
typedef std::pair<node*, node*> kv_pair;
typedef std::list<kv_pair> kv_pairs;
mutable kv_pairs m_undefinedPairs;
};
}
......
......@@ -24,7 +24,7 @@ struct iterator_type {
template <typename V>
struct node_iterator_value : public std::pair<V*, V*> {
using kv = std::pair<V*, V*>;
typedef std::pair<V*, V*> kv;
node_iterator_value() : kv(), pNode(nullptr) {}
explicit node_iterator_value(V& rhs) : kv(), pNode(&rhs) {}
......@@ -36,23 +36,26 @@ struct node_iterator_value : public std::pair<V*, V*> {
V* pNode;
};
using node_seq = std::vector<node *>;
using node_map = std::vector<std::pair<node*, node*>>;
typedef std::vector<node*> node_seq;
typedef std::vector<std::pair<node*, node*>> node_map;
template <typename V>
struct node_iterator_type {
using seq = node_seq::iterator;
using map = node_map::iterator;
typedef node_seq::iterator seq;
typedef node_map::iterator map;
};
template <typename V>
struct node_iterator_type<const V> {
using seq = node_seq::const_iterator;
using map = node_map::const_iterator;
typedef node_seq::const_iterator seq;
typedef node_map::const_iterator map;
};
template <typename V>
class node_iterator_base {
class node_iterator_base
: public std::iterator<std::forward_iterator_tag, node_iterator_value<V>,
std::ptrdiff_t, node_iterator_value<V>*,
node_iterator_value<V>> {
private:
struct enabler {};
......@@ -65,13 +68,9 @@ class node_iterator_base {
};
public:
using iterator_category = std::forward_iterator_tag;
using value_type = node_iterator_value<V>;
using difference_type = std::ptrdiff_t;
using pointer = node_iterator_value<V>*;
using reference = node_iterator_value<V>;
using SeqIter = typename node_iterator_type<V>::seq;
using MapIter = typename node_iterator_type<V>::map;
typedef typename node_iterator_type<V>::seq SeqIter;
typedef typename node_iterator_type<V>::map MapIter;
typedef node_iterator_value<V> value_type;
node_iterator_base()
: m_type(iterator_type::NoneType), m_seqIt(), m_mapIt(), m_mapEnd() {}
......@@ -173,8 +172,8 @@ class node_iterator_base {
MapIter m_mapIt, m_mapEnd;
};
using node_iterator = node_iterator_base<node>;
using const_node_iterator = node_iterator_base<const node>;
typedef node_iterator_base<node> node_iterator;
typedef node_iterator_base<const node> const_node_iterator;
}
}
......
......@@ -42,7 +42,11 @@ inline Node::Node(const detail::iterator_value& rhs)
m_pMemory(rhs.m_pMemory),
m_pNode(rhs.m_pNode) {}
inline Node::Node(const Node& rhs) = default;
inline Node::Node(const Node& rhs)
: m_isValid(rhs.m_isValid),
m_invalidKey(rhs.m_invalidKey),
m_pMemory(rhs.m_pMemory),
m_pNode(rhs.m_pNode) {}
inline Node::Node(Zombie)
: m_isValid(false), m_invalidKey{}, m_pMemory{}, m_pNode(nullptr) {}
......@@ -53,7 +57,7 @@ inline Node::Node(Zombie, const std::string& key)
inline Node::Node(detail::node& node, detail::shared_memory_holder pMemory)
: m_isValid(true), m_invalidKey{}, m_pMemory(pMemory), m_pNode(&node) {}
inline Node::~Node() = default;
inline Node::~Node() {}
inline void Node::EnsureNodeExists() const {
if (!m_isValid)
......@@ -110,8 +114,6 @@ struct as_if<std::string, S> {
const Node& node;
std::string operator()(const S& fallback) const {
if (node.Type() == NodeType::Null)
return "null";
if (node.Type() != NodeType::Scalar)
return fallback;
return node.Scalar();
......@@ -140,8 +142,6 @@ struct as_if<std::string, void> {
const Node& node;
std::string operator()() const {
if (node.Type() == NodeType::Null)
return "null";
if (node.Type() != NodeType::Scalar)
throw TypedBadConversion<std::string>(node.Mark());
return node.Scalar();
......@@ -176,6 +176,8 @@ inline const std::string& Node::Tag() const {
}
inline void Node::SetTag(const std::string& tag) {
if (!m_isValid)
throw InvalidNode(m_invalidKey);
EnsureNodeExists();
m_pNode->set_tag(tag);
}
......@@ -187,6 +189,8 @@ inline EmitterStyle::value Node::Style() const {
}
inline void Node::SetStyle(EmitterStyle::value style) {
if (!m_isValid)
throw InvalidNode(m_invalidKey);
EnsureNodeExists();
m_pNode->set_style(style);
}
......@@ -202,11 +206,15 @@ inline bool Node::is(const Node& rhs) const {
template <typename T>
inline Node& Node::operator=(const T& rhs) {
if (!m_isValid)
throw InvalidNode(m_invalidKey);
Assign(rhs);
return *this;
}
inline Node& Node::operator=(const Node& rhs) {
if (!m_isValid || !rhs.m_isValid)
throw InvalidNode(m_invalidKey);
if (is(rhs))
return *this;
AssignNode(rhs);
......@@ -229,21 +237,29 @@ inline void Node::Assign(const T& rhs) {
template <>
inline void Node::Assign(const std::string& rhs) {
if (!m_isValid)
throw InvalidNode(m_invalidKey);
EnsureNodeExists();
m_pNode->set_scalar(rhs);
}
inline void Node::Assign(const char* rhs) {
if (!m_isValid)
throw InvalidNode(m_invalidKey);
EnsureNodeExists();
m_pNode->set_scalar(rhs);
}
inline void Node::Assign(char* rhs) {
if (!m_isValid)
throw InvalidNode(m_invalidKey);
EnsureNodeExists();
m_pNode->set_scalar(rhs);
}
inline void Node::AssignData(const Node& rhs) {
if (!m_isValid || !rhs.m_isValid)
throw InvalidNode(m_invalidKey);
EnsureNodeExists();
rhs.EnsureNodeExists();
......@@ -252,7 +268,7 @@ inline void Node::AssignData(const Node& rhs) {
}
inline void Node::AssignNode(const Node& rhs) {
if (!m_isValid)
if (!m_isValid || !rhs.m_isValid)
throw InvalidNode(m_invalidKey);
rhs.EnsureNodeExists();
......@@ -308,6 +324,8 @@ inline void Node::push_back(const T& rhs) {
}
inline void Node::push_back(const Node& rhs) {
if (!m_isValid || !rhs.m_isValid)
throw InvalidNode(m_invalidKey);
EnsureNodeExists();
rhs.EnsureNodeExists();
......@@ -315,6 +333,51 @@ inline void Node::push_back(const Node& rhs) {
m_pMemory->merge(*rhs.m_pMemory);
}
// helpers for indexing
namespace detail {
template <typename T>
struct to_value_t {
explicit to_value_t(const T& t_) : t(t_) {}
const T& t;
typedef const T& return_type;
const T& operator()() const { return t; }
};
template <>
struct to_value_t<const char*> {
explicit to_value_t(const char* t_) : t(t_) {}
const char* t;
typedef std::string return_type;
const std::string operator()() const { return t; }
};
template <>
struct to_value_t<char*> {
explicit to_value_t(char* t_) : t(t_) {}
const char* t;
typedef std::string return_type;
const std::string operator()() const { return t; }
};
template <std::size_t N>
struct to_value_t<char[N]> {
explicit to_value_t(const char* t_) : t(t_) {}
const char* t;
typedef std::string return_type;
const std::string operator()() const { return t; }
};
// converts C-strings to std::strings so they can be copied
template <typename T>
inline typename to_value_t<T>::return_type to_value(const T& t) {
return to_value_t<T>(t)();
}
} // namespace detail
template<typename Key>
std::string key_to_string(const Key& key) {
return streamable_to_string<Key, is_streamable<std::stringstream, Key>::value>().impl(key);
......@@ -323,9 +386,11 @@ std::string key_to_string(const Key& key) {
// indexing
template <typename Key>
inline const Node Node::operator[](const Key& key) const {
if (!m_isValid)
throw InvalidNode(m_invalidKey);
EnsureNodeExists();
detail::node* value =
static_cast<const detail::node&>(*m_pNode).get(key, m_pMemory);
detail::node* value = static_cast<const detail::node&>(*m_pNode).get(
detail::to_value(key), m_pMemory);
if (!value) {
return Node(ZombieNode, key_to_string(key));
}
......@@ -334,18 +399,24 @@ inline const Node Node::operator[](const Key& key) const {
template <typename Key>
inline Node Node::operator[](const Key& key) {
if (!m_isValid)
throw InvalidNode(m_invalidKey);
EnsureNodeExists();
detail::node& value = m_pNode->get(key, m_pMemory);
detail::node& value = m_pNode->get(detail::to_value(key), m_pMemory);
return Node(value, m_pMemory);
}
template <typename Key>
inline bool Node::remove(const Key& key) {
if (!m_isValid)
throw InvalidNode(m_invalidKey);
EnsureNodeExists();
return m_pNode->remove(key, m_pMemory);
return m_pNode->remove(detail::to_value(key), m_pMemory);
}
inline const Node Node::operator[](const Node& key) const {
if (!m_isValid || !key.m_isValid)
throw InvalidNode(m_invalidKey);
EnsureNodeExists();
key.EnsureNodeExists();
m_pMemory->merge(*key.m_pMemory);
......@@ -358,6 +429,8 @@ inline const Node Node::operator[](const Node& key) const {
}
inline Node Node::operator[](const Node& key) {
if (!m_isValid || !key.m_isValid)
throw InvalidNode(m_invalidKey);
EnsureNodeExists();
key.EnsureNodeExists();
m_pMemory->merge(*key.m_pMemory);
......@@ -366,6 +439,8 @@ inline Node Node::operator[](const Node& key) {
}
inline bool Node::remove(const Node& key) {
if (!m_isValid || !key.m_isValid)
throw InvalidNode(m_invalidKey);
EnsureNodeExists();
key.EnsureNodeExists();
return m_pNode->remove(*key.m_pNode, m_pMemory);
......@@ -374,8 +449,11 @@ inline bool Node::remove(const Node& key) {
// map
template <typename Key, typename Value>
inline void Node::force_insert(const Key& key, const Value& value) {
if (!m_isValid)
throw InvalidNode(m_invalidKey);
EnsureNodeExists();
m_pNode->force_insert(key, value, m_pMemory);
m_pNode->force_insert(detail::to_value(key), detail::to_value(value),
m_pMemory);
}
// free functions
......
......@@ -18,7 +18,7 @@
namespace YAML {
namespace detail {
struct iterator_value : public Node, std::pair<Node, Node> {
iterator_value() = default;
iterator_value() {}
explicit iterator_value(const Node& rhs)
: Node(rhs),
std::pair<Node, Node>(Node(Node::ZombieNode), Node(Node::ZombieNode)) {}
......
......@@ -13,6 +13,7 @@
#include "yaml-cpp/dll.h"
#include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/mark.h"
#include "yaml-cpp/node/detail/bool_type.h"
#include "yaml-cpp/node/detail/iterator_fwd.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/type.h"
......@@ -38,8 +39,8 @@ class YAML_CPP_API Node {
template <typename T, typename S>
friend struct as_if;
using iterator = YAML::iterator;
using const_iterator = YAML::const_iterator;
typedef YAML::iterator iterator;
typedef YAML::const_iterator const_iterator;
Node();
explicit Node(NodeType::value type);
......@@ -58,7 +59,7 @@ class YAML_CPP_API Node {
bool IsMap() const { return Type() == NodeType::Map; }
// bool conversions
explicit operator bool() const { return IsDefined(); }
YAML_CPP_OPERATOR_BOOL()
bool operator!() const { return !IsDefined(); }
// access
......
......@@ -18,11 +18,11 @@ class node_data;
class memory;
class memory_holder;
using shared_node = std::shared_ptr<node>;
using shared_node_ref = std::shared_ptr<node_ref>;
using shared_node_data = std::shared_ptr<node_data>;
using shared_memory_holder = std::shared_ptr<memory_holder>;
using shared_memory = std::shared_ptr<memory>;
typedef std::shared_ptr<node> shared_node;
typedef std::shared_ptr<node_ref> shared_node_ref;
typedef std::shared_ptr<node_data> shared_node_data;
typedef std::shared_ptr<memory_holder> shared_memory_holder;
typedef std::shared_ptr<memory> shared_memory;
}
}
......
......@@ -16,8 +16,8 @@ namespace YAML {
template <typename Seq>
inline Emitter& EmitSeq(Emitter& emitter, const Seq& seq) {
emitter << BeginSeq;
for (const auto& v : seq)
emitter << v;
for (typename Seq::const_iterator it = seq.begin(); it != seq.end(); ++it)
emitter << *it;
emitter << EndSeq;
return emitter;
}
......@@ -39,9 +39,10 @@ inline Emitter& operator<<(Emitter& emitter, const std::set<T>& v) {
template <typename K, typename V>
inline Emitter& operator<<(Emitter& emitter, const std::map<K, V>& m) {
typedef typename std::map<K, V> map;
emitter << BeginMap;
for (const auto& v : m)
emitter << Key << v.first << Value << v.second;
for (typename map::const_iterator it = m.begin(); it != m.end(); ++it)
emitter << Key << it->first << Value << it->second;
emitter << EndMap;
return emitter;
}
......
......@@ -84,7 +84,7 @@ struct is_numeric<long double> {
template <bool, class T = void>
struct enable_if_c {
using type = T;
typedef T type;
};
template <class T>
......@@ -95,7 +95,7 @@ struct enable_if : public enable_if_c<Cond::value, T> {};
template <bool, class T = void>
struct disable_if_c {
using type = T;
typedef T type;
};
template <class T>
......
No preview for this file type
# This is a basic version file for the Config-mode of find_package().
# It is used by write_basic_package_version_file() as input file for configure_file()
# to create a version-file which can be installed along a config.cmake file.
#
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
# the requested version string are exactly the same and it sets
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version.
# The variable CVF_VERSION must be set before calling configure_file().
set(PACKAGE_VERSION "0.6.3")
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()
# if the installed project requested no architecture check, don't perform the check
if("FALSE")
return()
endif()
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
return()
endif()
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8")
math(EXPR installedBits "8 * 8")
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment