Commit d63ec48c authored by Jesse Beder's avatar Jesse Beder
Browse files

Run clang-format

parent 3355bbb3
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
// #pragma message( "Defining YAML_CPP_API for DLL import" ) // #pragma message( "Defining YAML_CPP_API for DLL import" )
#define YAML_CPP_API __declspec(dllimport) #define YAML_CPP_API __declspec(dllimport)
#endif // yaml_cpp_EXPORTS #endif // yaml_cpp_EXPORTS
#else // YAML_CPP_DLL #else // YAML_CPP_DLL
#define YAML_CPP_API #define YAML_CPP_API
#endif // YAML_CPP_DLL #endif // YAML_CPP_DLL
......
#ifndef EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #ifndef EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define EXCEPTIONS_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 #if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once #pragma once
#endif #endif
#include "yaml-cpp/mark.h" #include "yaml-cpp/mark.h"
#include "yaml-cpp/traits.h" #include "yaml-cpp/traits.h"
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
#include <sstream> #include <sstream>
namespace YAML namespace YAML {
{ // error messages
// error messages namespace ErrorMsg {
namespace ErrorMsg const char* const YAML_DIRECTIVE_ARGS =
{ "YAML directives must have exactly one argument";
const char * const YAML_DIRECTIVE_ARGS = "YAML directives must have exactly one argument"; const char* const YAML_VERSION = "bad YAML version: ";
const char * const YAML_VERSION = "bad YAML version: "; const char* const YAML_MAJOR_VERSION = "YAML major version too large";
const char * const YAML_MAJOR_VERSION = "YAML major version too large"; const char* const REPEATED_YAML_DIRECTIVE = "repeated YAML directive";
const char * const REPEATED_YAML_DIRECTIVE= "repeated YAML directive"; const char* const TAG_DIRECTIVE_ARGS =
const char * const TAG_DIRECTIVE_ARGS = "TAG directives must have exactly two arguments"; "TAG directives must have exactly two arguments";
const char * const REPEATED_TAG_DIRECTIVE = "repeated TAG directive"; const char* const REPEATED_TAG_DIRECTIVE = "repeated TAG directive";
const char * const CHAR_IN_TAG_HANDLE = "illegal character found while scanning tag handle"; const char* const CHAR_IN_TAG_HANDLE =
const char * const TAG_WITH_NO_SUFFIX = "tag handle with no suffix"; "illegal character found while scanning tag handle";
const char * const END_OF_VERBATIM_TAG = "end of verbatim tag not found"; const char* const TAG_WITH_NO_SUFFIX = "tag handle with no suffix";
const char * const END_OF_MAP = "end of map not found"; const char* const END_OF_VERBATIM_TAG = "end of verbatim tag not found";
const char * const END_OF_MAP_FLOW = "end of map flow not found"; const char* const END_OF_MAP = "end of map not found";
const char * const END_OF_SEQ = "end of sequence not found"; const char* const END_OF_MAP_FLOW = "end of map flow not found";
const char * const END_OF_SEQ_FLOW = "end of sequence flow not found"; const char* const END_OF_SEQ = "end of sequence not found";
const char * const MULTIPLE_TAGS = "cannot assign multiple tags to the same node"; const char* const END_OF_SEQ_FLOW = "end of sequence flow not found";
const char * const MULTIPLE_ANCHORS = "cannot assign multiple anchors to the same node"; const char* const MULTIPLE_TAGS =
const char * const MULTIPLE_ALIASES = "cannot assign multiple aliases to the same node"; "cannot assign multiple tags to the same node";
const char * const ALIAS_CONTENT = "aliases can't have any content, *including* tags"; const char* const MULTIPLE_ANCHORS =
const char * const INVALID_HEX = "bad character found while scanning hex number"; "cannot assign multiple anchors to the same node";
const char * const INVALID_UNICODE = "invalid unicode: "; const char* const MULTIPLE_ALIASES =
const char * const INVALID_ESCAPE = "unknown escape character: "; "cannot assign multiple aliases to the same node";
const char * const UNKNOWN_TOKEN = "unknown token"; const char* const ALIAS_CONTENT =
const char * const DOC_IN_SCALAR = "illegal document indicator in scalar"; "aliases can't have any content, *including* tags";
const char * const EOF_IN_SCALAR = "illegal EOF in scalar"; const char* const INVALID_HEX = "bad character found while scanning hex number";
const char * const CHAR_IN_SCALAR = "illegal character in scalar"; const char* const INVALID_UNICODE = "invalid unicode: ";
const char * const TAB_IN_INDENTATION = "illegal tab when looking for indentation"; const char* const INVALID_ESCAPE = "unknown escape character: ";
const char * const FLOW_END = "illegal flow end"; const char* const UNKNOWN_TOKEN = "unknown token";
const char * const BLOCK_ENTRY = "illegal block entry"; const char* const DOC_IN_SCALAR = "illegal document indicator in scalar";
const char * const MAP_KEY = "illegal map key"; const char* const EOF_IN_SCALAR = "illegal EOF in scalar";
const char * const MAP_VALUE = "illegal map value"; const char* const CHAR_IN_SCALAR = "illegal character in scalar";
const char * const ALIAS_NOT_FOUND = "alias not found after *"; const char* const TAB_IN_INDENTATION =
const char * const ANCHOR_NOT_FOUND = "anchor not found after &"; "illegal tab when looking for indentation";
const char * const CHAR_IN_ALIAS = "illegal character found while scanning alias"; const char* const FLOW_END = "illegal flow end";
const char * const CHAR_IN_ANCHOR = "illegal character found while scanning anchor"; const char* const BLOCK_ENTRY = "illegal block entry";
const char * const ZERO_INDENT_IN_BLOCK = "cannot set zero indentation for a block scalar"; const char* const MAP_KEY = "illegal map key";
const char * const CHAR_IN_BLOCK = "unexpected character in block scalar"; const char* const MAP_VALUE = "illegal map value";
const char * const AMBIGUOUS_ANCHOR = "cannot assign the same alias to multiple nodes"; const char* const ALIAS_NOT_FOUND = "alias not found after *";
const char * const UNKNOWN_ANCHOR = "the referenced anchor is not defined"; const char* const ANCHOR_NOT_FOUND = "anchor not found after &";
const char* const CHAR_IN_ALIAS =
const char * const INVALID_NODE = "invalid node; this may result from using a map iterator as a sequence iterator, or vice-versa"; "illegal character found while scanning alias";
const char * const INVALID_SCALAR = "invalid scalar"; const char* const CHAR_IN_ANCHOR =
const char * const KEY_NOT_FOUND = "key not found"; "illegal character found while scanning anchor";
const char * const BAD_CONVERSION = "bad conversion"; const char* const ZERO_INDENT_IN_BLOCK =
const char * const BAD_DEREFERENCE = "bad dereference"; "cannot set zero indentation for a block scalar";
const char * const BAD_SUBSCRIPT = "operator[] call on a scalar"; const char* const CHAR_IN_BLOCK = "unexpected character in block scalar";
const char * const BAD_PUSHBACK = "appending to a non-sequence"; const char* const AMBIGUOUS_ANCHOR =
const char * const BAD_INSERT = "inserting in a non-convertible-to-map"; "cannot assign the same alias to multiple nodes";
const char* const UNKNOWN_ANCHOR = "the referenced anchor is not defined";
const char * const UNMATCHED_GROUP_TAG = "unmatched group tag";
const char * const UNEXPECTED_END_SEQ = "unexpected end sequence token"; const char* const INVALID_NODE =
const char * const UNEXPECTED_END_MAP = "unexpected end map token"; "invalid node; this may result from using a map iterator as a sequence "
const char * const SINGLE_QUOTED_CHAR = "invalid character in single-quoted string"; "iterator, or vice-versa";
const char * const INVALID_ANCHOR = "invalid anchor"; const char* const INVALID_SCALAR = "invalid scalar";
const char * const INVALID_ALIAS = "invalid alias"; const char* const KEY_NOT_FOUND = "key not found";
const char * const INVALID_TAG = "invalid tag"; const char* const BAD_CONVERSION = "bad conversion";
const char * const BAD_FILE = "bad file"; const char* const BAD_DEREFERENCE = "bad dereference";
const char* const BAD_SUBSCRIPT = "operator[] call on a scalar";
template <typename T> const char* const BAD_PUSHBACK = "appending to a non-sequence";
inline const std::string KEY_NOT_FOUND_WITH_KEY(const T&, typename disable_if<is_numeric<T> >::type * = 0) { const char* const BAD_INSERT = "inserting in a non-convertible-to-map";
return KEY_NOT_FOUND;
} const char* const UNMATCHED_GROUP_TAG = "unmatched group tag";
const char* const UNEXPECTED_END_SEQ = "unexpected end sequence token";
inline const std::string KEY_NOT_FOUND_WITH_KEY(const std::string& key) { const char* const UNEXPECTED_END_MAP = "unexpected end map token";
std::stringstream stream; const char* const SINGLE_QUOTED_CHAR =
stream << KEY_NOT_FOUND << ": " << key; "invalid character in single-quoted string";
return stream.str(); const char* const INVALID_ANCHOR = "invalid anchor";
} const char* const INVALID_ALIAS = "invalid alias";
const char* const INVALID_TAG = "invalid tag";
template <typename T> const char* const BAD_FILE = "bad file";
inline const std::string KEY_NOT_FOUND_WITH_KEY(const T& key, typename enable_if<is_numeric<T> >::type * = 0) {
std::stringstream stream; template <typename T>
stream << KEY_NOT_FOUND << ": " << key; inline const std::string KEY_NOT_FOUND_WITH_KEY(
return stream.str(); const T&, typename disable_if<is_numeric<T> >::type* = 0) {
} return KEY_NOT_FOUND;
} }
class Exception: public std::runtime_error { inline const std::string KEY_NOT_FOUND_WITH_KEY(const std::string& key) {
public: std::stringstream stream;
Exception(const Mark& mark_, const std::string& msg_) stream << KEY_NOT_FOUND << ": " << key;
: std::runtime_error(build_what(mark_, msg_)), mark(mark_), msg(msg_) {} return stream.str();
virtual ~Exception() throw() {} }
Mark mark; template <typename T>
std::string msg; inline const std::string KEY_NOT_FOUND_WITH_KEY(
const T& key, typename enable_if<is_numeric<T> >::type* = 0) {
private: std::stringstream stream;
static const std::string build_what(const Mark& mark, const std::string& msg) { stream << KEY_NOT_FOUND << ": " << key;
std::stringstream output; return stream.str();
output << "yaml-cpp: error at line " << mark.line+1 << ", column " << mark.column+1 << ": " << msg; }
return output.str(); }
}
}; class Exception : public std::runtime_error {
public:
class ParserException: public Exception { Exception(const Mark& mark_, const std::string& msg_)
public: : std::runtime_error(build_what(mark_, msg_)), mark(mark_), msg(msg_) {}
ParserException(const Mark& mark_, const std::string& msg_) virtual ~Exception() throw() {}
: Exception(mark_, msg_) {}
}; Mark mark;
std::string msg;
class RepresentationException: public Exception {
public: private:
RepresentationException(const Mark& mark_, const std::string& msg_) static const std::string build_what(const Mark& mark,
: Exception(mark_, msg_) {} const std::string& msg) {
}; std::stringstream output;
output << "yaml-cpp: error at line " << mark.line + 1 << ", column "
// representation exceptions << mark.column + 1 << ": " << msg;
class InvalidScalar: public RepresentationException { return output.str();
public: }
InvalidScalar(const Mark& mark_) };
: RepresentationException(mark_, ErrorMsg::INVALID_SCALAR) {}
}; class ParserException : public Exception {
public:
class KeyNotFound: public RepresentationException { ParserException(const Mark& mark_, const std::string& msg_)
public: : Exception(mark_, msg_) {}
template <typename T> };
KeyNotFound(const Mark& mark_, const T& key_)
: RepresentationException(mark_, ErrorMsg::KEY_NOT_FOUND_WITH_KEY(key_)) {} class RepresentationException : public Exception {
}; public:
RepresentationException(const Mark& mark_, const std::string& msg_)
template <typename T> : Exception(mark_, msg_) {}
class TypedKeyNotFound: public KeyNotFound { };
public:
TypedKeyNotFound(const Mark& mark_, const T& key_) // representation exceptions
: KeyNotFound(mark_, key_), key(key_) {} class InvalidScalar : public RepresentationException {
virtual ~TypedKeyNotFound() throw() {} public:
InvalidScalar(const Mark& mark_)
T key; : RepresentationException(mark_, ErrorMsg::INVALID_SCALAR) {}
}; };
template <typename T> class KeyNotFound : public RepresentationException {
inline TypedKeyNotFound <T> MakeTypedKeyNotFound(const Mark& mark, const T& key) { public:
return TypedKeyNotFound <T> (mark, key); template <typename T>
} KeyNotFound(const Mark& mark_, const T& key_)
: RepresentationException(mark_, ErrorMsg::KEY_NOT_FOUND_WITH_KEY(key_)) {
class InvalidNode: public RepresentationException { }
public: };
InvalidNode()
: RepresentationException(Mark::null_mark(), ErrorMsg::INVALID_NODE) {} template <typename T>
}; class TypedKeyNotFound : public KeyNotFound {
public:
class BadConversion: public RepresentationException { TypedKeyNotFound(const Mark& mark_, const T& key_)
public: : KeyNotFound(mark_, key_), key(key_) {}
BadConversion() virtual ~TypedKeyNotFound() throw() {}
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_CONVERSION) {}
}; T key;
};
template<typename T>
class TypedBadConversion: public BadConversion { template <typename T>
public: inline TypedKeyNotFound<T> MakeTypedKeyNotFound(const Mark& mark,
TypedBadConversion() const T& key) {
: BadConversion() {} return TypedKeyNotFound<T>(mark, key);
}; }
class BadDereference: public RepresentationException { class InvalidNode : public RepresentationException {
public: public:
BadDereference() InvalidNode()
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_DEREFERENCE) {} : RepresentationException(Mark::null_mark(), ErrorMsg::INVALID_NODE) {}
}; };
class BadSubscript: public RepresentationException { class BadConversion : public RepresentationException {
public: public:
BadSubscript() BadConversion()
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_SUBSCRIPT) {} : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_CONVERSION) {}
}; };
class BadPushback: public RepresentationException { template <typename T>
public: class TypedBadConversion : public BadConversion {
BadPushback() public:
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_PUSHBACK) {} TypedBadConversion() : BadConversion() {}
}; };
class BadInsert: public RepresentationException { class BadDereference : public RepresentationException {
public: public:
BadInsert() BadDereference()
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_INSERT) {} : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_DEREFERENCE) {}
}; };
class EmitterException: public Exception { class BadSubscript : public RepresentationException {
public: public:
EmitterException(const std::string& msg_) BadSubscript()
: Exception(Mark::null_mark(), msg_) {} : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_SUBSCRIPT) {}
}; };
class BadFile: public Exception { class BadPushback : public RepresentationException {
public: public:
BadFile(): Exception(Mark::null_mark(), ErrorMsg::BAD_FILE) {} BadPushback()
}; : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_PUSHBACK) {}
};
class BadInsert : public RepresentationException {
public:
BadInsert()
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_INSERT) {}
};
class EmitterException : public Exception {
public:
EmitterException(const std::string& msg_)
: Exception(Mark::null_mark(), msg_) {}
};
class BadFile : public Exception {
public:
BadFile() : Exception(Mark::null_mark(), ErrorMsg::BAD_FILE) {}
};
} }
#endif // EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #ifndef NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define NODE_CONVERT_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 #if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once #pragma once
#endif #endif
#include "yaml-cpp/binary.h" #include "yaml-cpp/binary.h"
#include "yaml-cpp/node/node.h" #include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/iterator.h" #include "yaml-cpp/node/iterator.h"
...@@ -16,265 +17,259 @@ ...@@ -16,265 +17,259 @@
#include <sstream> #include <sstream>
#include <vector> #include <vector>
namespace YAML namespace YAML {
{ namespace conversion {
namespace conversion { inline bool IsInfinity(const std::string& input) {
inline bool IsInfinity(const std::string& input) { return input == ".inf" || input == ".Inf" || input == ".INF" ||
return input == ".inf" || input == ".Inf" || input == ".INF" || input == "+.inf" || input == "+.Inf" || input == "+.INF"; input == "+.inf" || input == "+.Inf" || input == "+.INF";
} }
inline bool IsNegativeInfinity(const std::string& input) { inline bool IsNegativeInfinity(const std::string& input) {
return input == "-.inf" || input == "-.Inf" || input == "-.INF"; return input == "-.inf" || input == "-.Inf" || input == "-.INF";
} }
inline bool IsNaN(const std::string& input) { inline bool IsNaN(const std::string& input) {
return input == ".nan" || input == ".NaN" || input == ".NAN"; return input == ".nan" || input == ".NaN" || input == ".NAN";
} }
} }
// std::string // std::string
template<> template <>
struct convert<std::string> { struct convert<std::string> {
static Node encode(const std::string& rhs) { static Node encode(const std::string& rhs) { return Node(rhs); }
return Node(rhs);
} static bool decode(const Node& node, std::string& rhs) {
if (!node.IsScalar())
static bool decode(const Node& node, std::string& rhs) { return false;
if(!node.IsScalar()) rhs = node.Scalar();
return false; return true;
rhs = node.Scalar(); }
return true; };
}
}; // C-strings can only be encoded
template <>
// C-strings can only be encoded struct convert<const char*> {
template<> static Node encode(const char*& rhs) { return Node(rhs); }
struct convert<const char *> { };
static Node encode(const char *&rhs) {
return Node(rhs); template <std::size_t N>
} struct convert<const char[N]> {
}; static Node encode(const char (&rhs)[N]) { return Node(rhs); }
};
template<std::size_t N>
struct convert<const char[N]> { template <>
static Node encode(const char (&rhs)[N]) { struct convert<_Null> {
return Node(rhs); static Node encode(const _Null& /* rhs */) { return Node(); }
}
}; static bool decode(const Node& node, _Null& /* rhs */) {
return node.IsNull();
template<> }
struct convert<_Null> { };
static Node encode(const _Null& /* rhs */) {
return Node(); #define YAML_DEFINE_CONVERT_STREAMABLE(type, negative_op) \
} template <> \
struct convert<type> { \
static bool decode(const Node& node, _Null& /* rhs */) { static Node encode(const type& rhs) { \
return node.IsNull(); std::stringstream stream; \
} stream.precision(std::numeric_limits<type>::digits10 + 1); \
}; stream << rhs; \
return Node(stream.str()); \
#define YAML_DEFINE_CONVERT_STREAMABLE(type, negative_op)\ } \
template<>\ \
struct convert<type> {\ static bool decode(const Node& node, type& rhs) { \
static Node encode(const type& rhs) {\ if (node.Type() != NodeType::Scalar) \
std::stringstream stream;\ return false; \
stream.precision(std::numeric_limits<type>::digits10 + 1);\ const std::string& input = node.Scalar(); \
stream << rhs;\ std::stringstream stream(input); \
return Node(stream.str());\ stream.unsetf(std::ios::dec); \
}\ if ((stream >> std::noskipws >> rhs) && (stream >> std::ws).eof()) \
\ return true; \
static bool decode(const Node& node, type& rhs) {\ if (std::numeric_limits<type>::has_infinity) { \
if(node.Type() != NodeType::Scalar)\ if (conversion::IsInfinity(input)) { \
return false;\ rhs = std::numeric_limits<type>::infinity(); \
const std::string& input = node.Scalar();\ return true; \
std::stringstream stream(input);\ } else if (conversion::IsNegativeInfinity(input)) { \
stream.unsetf(std::ios::dec);\ rhs = negative_op std::numeric_limits<type>::infinity(); \
if((stream >> std::noskipws >> rhs) && (stream >> std::ws).eof())\ return true; \
return true;\ } \
if(std::numeric_limits<type>::has_infinity) {\ } \
if(conversion::IsInfinity(input)) {\ \
rhs = std::numeric_limits<type>::infinity();\ if (std::numeric_limits<type>::has_quiet_NaN && \
return true;\ conversion::IsNaN(input)) { \
} else if(conversion::IsNegativeInfinity(input)) {\ rhs = std::numeric_limits<type>::quiet_NaN(); \
rhs = negative_op std::numeric_limits<type>::infinity();\ return true; \
return true;\ } \
}\ \
}\ return false; \
\ } \
if(std::numeric_limits<type>::has_quiet_NaN && conversion::IsNaN(input)) {\ }
rhs = std::numeric_limits<type>::quiet_NaN();\
return true;\ #define YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(type) \
}\ YAML_DEFINE_CONVERT_STREAMABLE(type, -)
\
return false;\ #define YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(type) \
}\ YAML_DEFINE_CONVERT_STREAMABLE(type, +)
}
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(int);
#define YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(type)\ YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(short);
YAML_DEFINE_CONVERT_STREAMABLE(type, -) YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long long);
#define YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(type)\ YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned);
YAML_DEFINE_CONVERT_STREAMABLE(type, +) YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned short);
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned long);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(int); YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned long long);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(short);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long); YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(char);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long long); YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned char);
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned);
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned short); YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(float);
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned long); YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(double);
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned long long); YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long double);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(char);
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned char);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(float);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(double);
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long double);
#undef YAML_DEFINE_CONVERT_STREAMABLE_SIGNED #undef YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
#undef YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED #undef YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED
#undef YAML_DEFINE_CONVERT_STREAMABLE #undef YAML_DEFINE_CONVERT_STREAMABLE
// bool // bool
template<> template <>
struct convert<bool> { struct convert<bool> {
static Node encode(bool rhs) { static Node encode(bool rhs) { return rhs ? Node("true") : Node("false"); }
return rhs ? Node("true") : Node("false");
} static bool decode(const Node& node, bool& rhs);
};
static bool decode(const Node& node, bool& rhs);
}; // std::map
template <typename K, typename V>
// std::map struct convert<std::map<K, V> > {
template<typename K, typename V> static Node encode(const std::map<K, V>& rhs) {
struct convert<std::map<K, V> > { Node node(NodeType::Map);
static Node encode(const std::map<K, V>& rhs) { for (typename std::map<K, V>::const_iterator it = rhs.begin();
Node node(NodeType::Map); it != rhs.end(); ++it)
for(typename std::map<K, V>::const_iterator it=rhs.begin();it!=rhs.end();++it) node.force_insert(it->first, it->second);
node.force_insert(it->first, it->second); return node;
return node; }
}
static bool decode(const Node& node, std::map<K, V>& rhs) {
static bool decode(const Node& node, std::map<K, V>& rhs) { if (!node.IsMap())
if(!node.IsMap()) return false;
return false;
rhs.clear();
rhs.clear(); for (const_iterator it = node.begin(); it != node.end(); ++it)
for(const_iterator it=node.begin();it!=node.end();++it)
#if defined(__GNUC__) && __GNUC__ < 4 #if defined(__GNUC__) && __GNUC__ < 4
//workaround for GCC 3: // workaround for GCC 3:
rhs[it->first.template as<K>()] = it->second.template as<V>(); rhs[it->first.template as<K>()] = it->second.template as<V>();
#else #else
rhs[it->first.as<K>()] = it->second.as<V>(); rhs[it->first.as<K>()] = it->second.as<V>();
#endif #endif
return true; return true;
} }
}; };
// std::vector // std::vector
template<typename T> template <typename T>
struct convert<std::vector<T> > { struct convert<std::vector<T> > {
static Node encode(const std::vector<T>& rhs) { static Node encode(const std::vector<T>& rhs) {
Node node(NodeType::Sequence); Node node(NodeType::Sequence);
for(typename std::vector<T>::const_iterator it=rhs.begin();it!=rhs.end();++it) for (typename std::vector<T>::const_iterator it = rhs.begin();
node.push_back(*it); it != rhs.end(); ++it)
return node; node.push_back(*it);
} return node;
}
static bool decode(const Node& node, std::vector<T>& rhs) {
if(!node.IsSequence()) static bool decode(const Node& node, std::vector<T>& rhs) {
return false; if (!node.IsSequence())
return false;
rhs.clear();
for(const_iterator it=node.begin();it!=node.end();++it) rhs.clear();
for (const_iterator it = node.begin(); it != node.end(); ++it)
#if defined(__GNUC__) && __GNUC__ < 4 #if defined(__GNUC__) && __GNUC__ < 4
//workaround for GCC 3: // workaround for GCC 3:
rhs.push_back(it->template as<T>()); rhs.push_back(it->template as<T>());
#else #else
rhs.push_back(it->as<T>()); rhs.push_back(it->as<T>());
#endif #endif
return true; return true;
} }
}; };
// std::list // std::list
template<typename T> template <typename T>
struct convert<std::list<T> > { struct convert<std::list<T> > {
static Node encode(const std::list<T>& rhs) { static Node encode(const std::list<T>& rhs) {
Node node(NodeType::Sequence); Node node(NodeType::Sequence);
for(typename std::list<T>::const_iterator it=rhs.begin();it!=rhs.end();++it) for (typename std::list<T>::const_iterator it = rhs.begin();
node.push_back(*it); it != rhs.end(); ++it)
return node; node.push_back(*it);
} return node;
}
static bool decode(const Node& node, std::list<T>& rhs) {
if(!node.IsSequence()) static bool decode(const Node& node, std::list<T>& rhs) {
return false; if (!node.IsSequence())
return false;
rhs.clear();
for(const_iterator it=node.begin();it!=node.end();++it) rhs.clear();
for (const_iterator it = node.begin(); it != node.end(); ++it)
#if defined(__GNUC__) && __GNUC__ < 4 #if defined(__GNUC__) && __GNUC__ < 4
//workaround for GCC 3: // workaround for GCC 3:
rhs.push_back(it->template as<T>()); rhs.push_back(it->template as<T>());
#else #else
rhs.push_back(it->as<T>()); rhs.push_back(it->as<T>());
#endif #endif
return true; return true;
} }
}; };
// std::pair // std::pair
template<typename T, typename U> template <typename T, typename U>
struct convert<std::pair<T, U> > { struct convert<std::pair<T, U> > {
static Node encode(const std::pair<T, U>& rhs) { static Node encode(const std::pair<T, U>& rhs) {
Node node(NodeType::Sequence); Node node(NodeType::Sequence);
node.push_back(rhs.first); node.push_back(rhs.first);
node.push_back(rhs.second); node.push_back(rhs.second);
return node; return node;
} }
static bool decode(const Node& node, std::pair<T, U>& rhs) { static bool decode(const Node& node, std::pair<T, U>& rhs) {
if(!node.IsSequence()) if (!node.IsSequence())
return false; return false;
if (node.size() != 2) if (node.size() != 2)
return false; return false;
#if defined(__GNUC__) && __GNUC__ < 4 #if defined(__GNUC__) && __GNUC__ < 4
//workaround for GCC 3: // workaround for GCC 3:
rhs.first = node[0].template as<T>(); rhs.first = node[0].template as<T>();
#else #else
rhs.first = node[0].as<T>(); rhs.first = node[0].as<T>();
#endif #endif
#if defined(__GNUC__) && __GNUC__ < 4 #if defined(__GNUC__) && __GNUC__ < 4
//workaround for GCC 3: // workaround for GCC 3:
rhs.second = node[1].template as<U>(); rhs.second = node[1].template as<U>();
#else #else
rhs.second = node[1].as<U>(); rhs.second = node[1].as<U>();
#endif #endif
return true; return true;
} }
}; };
// binary // binary
template<> template <>
struct convert<Binary> { struct convert<Binary> {
static Node encode(const Binary& rhs) { static Node encode(const Binary& rhs) {
return Node(EncodeBase64(rhs.data(), rhs.size())); return Node(EncodeBase64(rhs.data(), rhs.size()));
} }
static bool decode(const Node& node, Binary& rhs) { static bool decode(const Node& node, Binary& rhs) {
if(!node.IsScalar()) if (!node.IsScalar())
return false; return false;
std::vector<unsigned char> data = DecodeBase64(node.Scalar()); std::vector<unsigned char> data = DecodeBase64(node.Scalar());
if(data.empty() && !node.Scalar().empty()) if (data.empty() && !node.Scalar().empty())
return false; return false;
rhs.swap(data); rhs.swap(data);
return true; return true;
} }
}; };
} }
#endif // NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #ifndef NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define 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 #if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once #pragma once
#endif #endif
namespace YAML namespace YAML {
{ namespace detail {
namespace detail struct unspecified_bool {
{ struct NOT_ALLOWED;
struct unspecified_bool { static void true_value(NOT_ALLOWED*) {}
struct NOT_ALLOWED; };
static void true_value(NOT_ALLOWED*) {} typedef void (*unspecified_bool_type)(unspecified_bool::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 #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
#ifndef NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #ifndef NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define NODE_DETAIL_IMPL_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 #if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once #pragma once
#endif #endif
#include "yaml-cpp/node/detail/node.h" #include "yaml-cpp/node/detail/node.h"
#include "yaml-cpp/node/detail/node_data.h" #include "yaml-cpp/node/detail/node_data.h"
#include <boost/type_traits.hpp> #include <boost/type_traits.hpp>
namespace YAML namespace YAML {
{ namespace detail {
namespace detail template <typename Key, typename Enable = void>
{ struct get_idx {
template<typename Key, typename Enable = void> static node* get(const std::vector<node*>& /* sequence */,
struct get_idx { const Key& /* key */, shared_memory_holder /* pMemory */) {
static node *get(const std::vector<node *>& /* sequence */, const Key& /* key */, shared_memory_holder /* pMemory */) { return 0;
return 0; }
} };
};
template <typename Key>
template<typename Key> struct get_idx<
struct get_idx<Key, typename boost::enable_if_c<boost::is_unsigned<Key>::value && !boost::is_same<Key, bool>::value>::type> { Key, typename boost::enable_if_c<boost::is_unsigned<Key>::value &&
static node *get(const std::vector<node *>& sequence, const Key& key, shared_memory_holder /* pMemory */) { !boost::is_same<Key, bool>::value>::type> {
return key < sequence.size() ? sequence[key] : 0; static node* get(const std::vector<node*>& sequence, const Key& key,
} shared_memory_holder /* pMemory */) {
return key < sequence.size() ? sequence[key] : 0;
static node *get(std::vector<node *>& sequence, const Key& key, shared_memory_holder pMemory) { }
if(key > sequence.size())
return 0; static node* get(std::vector<node*>& sequence, const Key& key,
if(key == sequence.size()) shared_memory_holder pMemory) {
sequence.push_back(&pMemory->create_node()); if (key > sequence.size())
return sequence[key]; return 0;
} if (key == sequence.size())
}; sequence.push_back(&pMemory->create_node());
return sequence[key];
template<typename Key> }
struct get_idx<Key, typename boost::enable_if<boost::is_signed<Key> >::type> { };
static node *get(const std::vector<node *>& sequence, const Key& key, shared_memory_holder pMemory) {
return key >= 0 ? get_idx<std::size_t>::get(sequence, static_cast<std::size_t>(key), pMemory) : 0; template <typename Key>
} struct get_idx<Key, typename boost::enable_if<boost::is_signed<Key> >::type> {
static node *get(std::vector<node *>& sequence, const Key& key, shared_memory_holder pMemory) { static node* get(const std::vector<node*>& sequence, const Key& key,
return key >= 0 ? get_idx<std::size_t>::get(sequence, static_cast<std::size_t>(key), pMemory) : 0; shared_memory_holder pMemory) {
} return key >= 0 ? get_idx<std::size_t>::get(
}; sequence, static_cast<std::size_t>(key), pMemory)
: 0;
// indexing }
template<typename Key> static node* get(std::vector<node*>& sequence, const Key& key,
inline node& node_data::get(const Key& key, shared_memory_holder pMemory) const shared_memory_holder pMemory) {
{ return key >= 0 ? get_idx<std::size_t>::get(
switch(m_type) { sequence, static_cast<std::size_t>(key), pMemory)
case NodeType::Map: : 0;
break; }
case NodeType::Undefined: };
case NodeType::Null:
return pMemory->create_node(); // indexing
case NodeType::Sequence: template <typename Key>
if(node *pNode = get_idx<Key>::get(m_sequence, key, pMemory)) inline node& node_data::get(const Key& key,
return *pNode; shared_memory_holder pMemory) const {
return pMemory->create_node(); switch (m_type) {
case NodeType::Scalar: case NodeType::Map:
throw BadSubscript(); break;
} case NodeType::Undefined:
case NodeType::Null:
for(node_map::const_iterator it=m_map.begin();it!=m_map.end();++it) { return pMemory->create_node();
if(equals(*it->first, key, pMemory)) case NodeType::Sequence:
return *it->second; if (node* pNode = get_idx<Key>::get(m_sequence, key, pMemory))
} return *pNode;
return pMemory->create_node();
return pMemory->create_node(); case NodeType::Scalar:
} throw BadSubscript();
}
template<typename Key>
inline node& node_data::get(const Key& key, shared_memory_holder pMemory) for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
{ if (equals(*it->first, key, pMemory))
switch(m_type) { return *it->second;
case NodeType::Map: }
break;
case NodeType::Undefined: return pMemory->create_node();
case NodeType::Null: }
case NodeType::Sequence:
if(node *pNode = get_idx<Key>::get(m_sequence, key, pMemory)) { template <typename Key>
m_type = NodeType::Sequence; inline node& node_data::get(const Key& key, shared_memory_holder pMemory) {
return *pNode; switch (m_type) {
} case NodeType::Map:
break;
convert_to_map(pMemory); case NodeType::Undefined:
break; case NodeType::Null:
case NodeType::Scalar: case NodeType::Sequence:
throw BadSubscript(); if (node* pNode = get_idx<Key>::get(m_sequence, key, pMemory)) {
} m_type = NodeType::Sequence;
return *pNode;
for(node_map::const_iterator it=m_map.begin();it!=m_map.end();++it) { }
if(equals(*it->first, key, pMemory))
return *it->second; convert_to_map(pMemory);
} break;
case NodeType::Scalar:
node& k = convert_to_node(key, pMemory); throw BadSubscript();
node& v = pMemory->create_node(); }
insert_map_pair(k, v);
return v; for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
} if (equals(*it->first, key, pMemory))
return *it->second;
template<typename Key> }
inline bool node_data::remove(const Key& key, shared_memory_holder pMemory)
{ node& k = convert_to_node(key, pMemory);
if(m_type != NodeType::Map) node& v = pMemory->create_node();
return false; insert_map_pair(k, v);
return v;
for(node_map::iterator it=m_map.begin();it!=m_map.end();++it) { }
if(equals(*it->first, key, pMemory)) {
m_map.erase(it); template <typename Key>
return true; inline bool node_data::remove(const Key& key, shared_memory_holder pMemory) {
} if (m_type != NodeType::Map)
} return false;
return false; for (node_map::iterator it = m_map.begin(); it != m_map.end(); ++it) {
} if (equals(*it->first, key, pMemory)) {
m_map.erase(it);
// map return true;
template<typename Key, typename Value> }
inline void node_data::force_insert(const Key& key, const Value& value, shared_memory_holder pMemory) }
{
switch(m_type) { return false;
case NodeType::Map: }
break;
case NodeType::Undefined: // map
case NodeType::Null: template <typename Key, typename Value>
case NodeType::Sequence: inline void node_data::force_insert(const Key& key, const Value& value,
convert_to_map(pMemory); shared_memory_holder pMemory) {
break; switch (m_type) {
case NodeType::Scalar: case NodeType::Map:
throw BadInsert(); break;
} case NodeType::Undefined:
case NodeType::Null:
node& k = convert_to_node(key, pMemory); case NodeType::Sequence:
node& v = convert_to_node(value, pMemory); convert_to_map(pMemory);
insert_map_pair(k, v); break;
} case NodeType::Scalar:
throw BadInsert();
template<typename T> }
inline bool node_data::equals(node& node, const T& rhs, shared_memory_holder pMemory)
{ node& k = convert_to_node(key, pMemory);
T lhs; node& v = convert_to_node(value, pMemory);
if(convert<T>::decode(Node(node, pMemory), lhs)) insert_map_pair(k, v);
return lhs == rhs; }
return false;
} template <typename T>
inline bool node_data::equals(node& node, const T& rhs,
inline bool node_data::equals(node& node, const char *rhs, shared_memory_holder pMemory) shared_memory_holder pMemory) {
{ T lhs;
return equals<std::string>(node, rhs, pMemory); if (convert<T>::decode(Node(node, pMemory), lhs))
} return lhs == rhs;
return false;
template<typename T> }
inline node& node_data::convert_to_node(const T& rhs, shared_memory_holder pMemory)
{ inline bool node_data::equals(node& node, const char* rhs,
Node value = convert<T>::encode(rhs); shared_memory_holder pMemory) {
value.EnsureNodeExists(); return equals<std::string>(node, rhs, pMemory);
pMemory->merge(*value.m_pMemory); }
return *value.m_pNode;
} template <typename T>
} inline node& node_data::convert_to_node(const T& rhs,
shared_memory_holder pMemory) {
Node value = convert<T>::encode(rhs);
value.EnsureNodeExists();
pMemory->merge(*value.m_pMemory);
return *value.m_pNode;
}
}
} }
#endif // NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #ifndef VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define VALUE_DETAIL_ITERATOR_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 #if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once #pragma once
#endif #endif
#include "yaml-cpp/dll.h" #include "yaml-cpp/dll.h"
#include "yaml-cpp/node/ptr.h" #include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/detail/node_iterator.h" #include "yaml-cpp/node/detail/node_iterator.h"
#include <boost/iterator/iterator_adaptor.hpp> #include <boost/iterator/iterator_adaptor.hpp>
#include <boost/utility.hpp> #include <boost/utility.hpp>
namespace YAML namespace YAML {
{ namespace detail {
namespace detail struct iterator_value;
{
struct iterator_value; template <typename V>
class iterator_base
: public boost::iterator_adaptor<iterator_base<V>, node_iterator, V,
std::forward_iterator_tag, V> {
private:
template <typename>
friend class iterator_base;
struct enabler {};
typedef typename iterator_base::base_type base_type;
public:
typedef typename iterator_base::value_type value_type;
public:
iterator_base() {}
explicit iterator_base(base_type rhs, shared_memory_holder pMemory)
: iterator_base::iterator_adaptor_(rhs), m_pMemory(pMemory) {}
template<typename V> template <class W>
class iterator_base: public boost::iterator_adaptor< iterator_base(
iterator_base<V>, const iterator_base<W>& rhs,
node_iterator, typename boost::enable_if<boost::is_convertible<W*, V*>, enabler>::type =
V, enabler())
std::forward_iterator_tag, : iterator_base::iterator_adaptor_(rhs.base()),
V> m_pMemory(rhs.m_pMemory) {}
{
private:
template<typename> friend class iterator_base;
struct enabler {};
typedef typename iterator_base::base_type base_type;
public:
typedef typename iterator_base::value_type value_type;
public:
iterator_base() {}
explicit iterator_base(base_type rhs, shared_memory_holder pMemory): iterator_base::iterator_adaptor_(rhs), m_pMemory(pMemory) {}
template<class W>
iterator_base(const iterator_base<W>& rhs, typename boost::enable_if<boost::is_convertible<W*, V*>, enabler>::type = enabler()): iterator_base::iterator_adaptor_(rhs.base()), m_pMemory(rhs.m_pMemory) {}
private:
friend class boost::iterator_core_access;
void increment() { this->base_reference() = boost::next(this->base()); } private:
friend class boost::iterator_core_access;
value_type dereference() const {
const typename base_type::value_type& v = *this->base(); void increment() { this->base_reference() = boost::next(this->base()); }
if(v.pNode)
return value_type(Node(*v, m_pMemory)); value_type dereference() const {
if(v.first && v.second) const typename base_type::value_type& v = *this->base();
return value_type(Node(*v.first, m_pMemory), Node(*v.second, m_pMemory)); if (v.pNode)
return value_type(); return value_type(Node(*v, m_pMemory));
} if (v.first && v.second)
return value_type(Node(*v.first, m_pMemory), Node(*v.second, m_pMemory));
private: return value_type();
shared_memory_holder m_pMemory; }
};
} private:
shared_memory_holder m_pMemory;
};
}
} }
#endif // VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #ifndef VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define VALUE_DETAIL_ITERATOR_FWD_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 #if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once #pragma once
#endif #endif
#include "yaml-cpp/dll.h" #include "yaml-cpp/dll.h"
#include <list> #include <list>
#include <utility> #include <utility>
#include <vector> #include <vector>
namespace YAML namespace YAML {
{ class node;
class node;
namespace detail {
namespace detail { struct iterator_value;
struct iterator_value; template <typename V>
template<typename V> class iterator_base; class iterator_base;
} }
typedef detail::iterator_base<detail::iterator_value> iterator; typedef detail::iterator_base<detail::iterator_value> iterator;
typedef detail::iterator_base<const detail::iterator_value> const_iterator; typedef detail::iterator_base<const detail::iterator_value> const_iterator;
} }
#endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #ifndef VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define VALUE_DETAIL_MEMORY_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 #if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once #pragma once
#endif #endif
...@@ -9,31 +11,29 @@ ...@@ -9,31 +11,29 @@
#include <set> #include <set>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
namespace YAML namespace YAML {
{ namespace detail {
namespace detail class memory {
{ public:
class memory { node& create_node();
public: void merge(const memory& rhs);
node& create_node();
void merge(const memory& rhs); private:
typedef std::set<shared_node> Nodes;
private: Nodes m_nodes;
typedef std::set<shared_node> Nodes; };
Nodes m_nodes;
}; class memory_holder {
public:
class memory_holder { memory_holder() : m_pMemory(new memory) {}
public:
memory_holder(): m_pMemory(new memory) {} node& create_node() { return m_pMemory->create_node(); }
void merge(memory_holder& rhs);
node& create_node() { return m_pMemory->create_node(); }
void merge(memory_holder& rhs); private:
boost::shared_ptr<memory> m_pMemory;
private: };
boost::shared_ptr<memory> m_pMemory; }
};
}
} }
#endif // VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #ifndef NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define NODE_DETAIL_NODE_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 #if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once #pragma once
#endif #endif
#include "yaml-cpp/dll.h" #include "yaml-cpp/dll.h"
#include "yaml-cpp/node/type.h" #include "yaml-cpp/node/type.h"
#include "yaml-cpp/node/ptr.h" #include "yaml-cpp/node/ptr.h"
...@@ -13,118 +14,134 @@ ...@@ -13,118 +14,134 @@
#include <set> #include <set>
#include <boost/utility.hpp> #include <boost/utility.hpp>
namespace YAML namespace YAML {
{ namespace detail {
namespace detail class node : private boost::noncopyable {
{ public:
class node: private boost::noncopyable node() : m_pRef(new node_ref) {}
{
public: bool is(const node& rhs) const { return m_pRef == rhs.m_pRef; }
node(): m_pRef(new node_ref) {} const node_ref* ref() const { return m_pRef.get(); }
bool is(const node& rhs) const { return m_pRef == rhs.m_pRef; } bool is_defined() const { return m_pRef->is_defined(); }
const node_ref *ref() const { return m_pRef.get(); } NodeType::value type() const { return m_pRef->type(); }
bool is_defined() const { return m_pRef->is_defined(); } const std::string& scalar() const { return m_pRef->scalar(); }
NodeType::value type() const { return m_pRef->type(); } const std::string& tag() const { return m_pRef->tag(); }
const std::string& scalar() const { return m_pRef->scalar(); } void mark_defined() {
const std::string& tag() const { return m_pRef->tag(); } if (is_defined())
return;
void mark_defined() {
if(is_defined()) m_pRef->mark_defined();
return; for (nodes::iterator it = m_dependencies.begin();
it != m_dependencies.end(); ++it)
m_pRef->mark_defined(); (*it)->mark_defined();
for(nodes::iterator it=m_dependencies.begin();it!=m_dependencies.end();++it) m_dependencies.clear();
(*it)->mark_defined(); }
m_dependencies.clear();
} void add_dependency(node& rhs) {
if (is_defined())
void add_dependency(node& rhs) { rhs.mark_defined();
if(is_defined()) else
rhs.mark_defined(); m_dependencies.insert(&rhs);
else }
m_dependencies.insert(&rhs);
} void set_ref(const node& rhs) {
if (rhs.is_defined())
void set_ref(const node& rhs) { mark_defined();
if(rhs.is_defined()) m_pRef = rhs.m_pRef;
mark_defined(); }
m_pRef = rhs.m_pRef; void set_data(const node& rhs) {
} if (rhs.is_defined())
void set_data(const node& rhs) { mark_defined();
if(rhs.is_defined()) m_pRef->set_data(*rhs.m_pRef);
mark_defined(); }
m_pRef->set_data(*rhs.m_pRef);
} void set_type(NodeType::value type) {
if (type != NodeType::Undefined)
void set_type(NodeType::value type) { mark_defined();
if(type != NodeType::Undefined) m_pRef->set_type(type);
mark_defined(); }
m_pRef->set_type(type); void set_null() {
} mark_defined();
void set_null() { m_pRef->set_null();
mark_defined(); }
m_pRef->set_null(); void set_scalar(const std::string& scalar) {
} mark_defined();
void set_scalar(const std::string& scalar) { m_pRef->set_scalar(scalar);
mark_defined(); }
m_pRef->set_scalar(scalar); void set_tag(const std::string& tag) {
} mark_defined();
void set_tag(const std::string& tag) { m_pRef->set_tag(tag);
mark_defined(); }
m_pRef->set_tag(tag);
} // size/iterator
std::size_t size() const { return m_pRef->size(); }
// size/iterator
std::size_t size() const { return m_pRef->size(); } const_node_iterator begin() const {
return static_cast<const node_ref&>(*m_pRef).begin();
const_node_iterator begin() const { return static_cast<const node_ref&>(*m_pRef).begin(); } }
node_iterator begin() { return m_pRef->begin(); } node_iterator begin() { return m_pRef->begin(); }
const_node_iterator end() const { return static_cast<const node_ref&>(*m_pRef).end(); } const_node_iterator end() const {
node_iterator end() { return m_pRef->end(); } return static_cast<const node_ref&>(*m_pRef).end();
}
// sequence node_iterator end() { return m_pRef->end(); }
void push_back(node& node, shared_memory_holder pMemory) {
m_pRef->push_back(node, pMemory); // sequence
node.add_dependency(*this); void push_back(node& node, shared_memory_holder pMemory) {
} m_pRef->push_back(node, pMemory);
void insert(node& key, node& value, shared_memory_holder pMemory) { node.add_dependency(*this);
m_pRef->insert(key, value, pMemory); }
key.add_dependency(*this); void insert(node& key, node& value, shared_memory_holder pMemory) {
value.add_dependency(*this); m_pRef->insert(key, value, pMemory);
} key.add_dependency(*this);
value.add_dependency(*this);
// indexing }
template<typename Key> node& get(const Key& key, shared_memory_holder pMemory) const { return static_cast<const node_ref&>(*m_pRef).get(key, pMemory); }
template<typename Key> node& get(const Key& key, shared_memory_holder pMemory) { // indexing
node& value = m_pRef->get(key, pMemory); template <typename Key>
value.add_dependency(*this); node& get(const Key& key, shared_memory_holder pMemory) const {
return value; return static_cast<const node_ref&>(*m_pRef).get(key, pMemory);
} }
template<typename Key> bool remove(const Key& key, shared_memory_holder pMemory) { return m_pRef->remove(key, pMemory); } template <typename Key>
node& get(const Key& key, shared_memory_holder pMemory) {
node& get(node& key, shared_memory_holder pMemory) const { return static_cast<const node_ref&>(*m_pRef).get(key, pMemory); } node& value = m_pRef->get(key, pMemory);
node& get(node& key, shared_memory_holder pMemory) { value.add_dependency(*this);
node& value = m_pRef->get(key, pMemory); return value;
key.add_dependency(*this); }
value.add_dependency(*this); template <typename Key>
return value; bool remove(const Key& key, shared_memory_holder pMemory) {
} return m_pRef->remove(key, pMemory);
bool remove(node& key, shared_memory_holder pMemory) { return m_pRef->remove(key, pMemory); } }
// map node& get(node& key, shared_memory_holder pMemory) const {
template<typename Key, typename Value> return static_cast<const node_ref&>(*m_pRef).get(key, pMemory);
void force_insert(const Key& key, const Value& value, shared_memory_holder pMemory){ m_pRef->force_insert(key, value, pMemory); } }
node& get(node& key, shared_memory_holder pMemory) {
private: node& value = m_pRef->get(key, pMemory);
shared_node_ref m_pRef; key.add_dependency(*this);
typedef std::set<node *> nodes; value.add_dependency(*this);
nodes m_dependencies; return value;
}; }
} bool remove(node& key, shared_memory_holder pMemory) {
return m_pRef->remove(key, pMemory);
}
// map
template <typename Key, typename Value>
void force_insert(const Key& key, const Value& value,
shared_memory_holder pMemory) {
m_pRef->force_insert(key, value, pMemory);
}
private:
shared_node_ref m_pRef;
typedef std::set<node*> nodes;
nodes m_dependencies;
};
}
} }
#endif // NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #ifndef VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define VALUE_DETAIL_NODE_DATA_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 #if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once #pragma once
#endif #endif
#include "yaml-cpp/dll.h" #include "yaml-cpp/dll.h"
#include "yaml-cpp/node/iterator.h" #include "yaml-cpp/node/iterator.h"
#include "yaml-cpp/node/ptr.h" #include "yaml-cpp/node/ptr.h"
...@@ -15,96 +16,99 @@ ...@@ -15,96 +16,99 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
namespace YAML namespace YAML {
{ namespace detail {
namespace detail class node_data : private boost::noncopyable {
{ public:
class node_data: private boost::noncopyable node_data();
{
public: void mark_defined();
node_data(); void set_type(NodeType::value type);
void set_tag(const std::string& tag);
void mark_defined(); void set_null();
void set_type(NodeType::value type); void set_scalar(const std::string& scalar);
void set_tag(const std::string& tag);
void set_null(); bool is_defined() const { return m_isDefined; }
void set_scalar(const std::string& scalar); NodeType::value type() const {
return m_isDefined ? m_type : NodeType::Undefined;
bool is_defined() const { return m_isDefined; } }
NodeType::value type() const { return m_isDefined ? m_type : NodeType::Undefined; } const std::string& scalar() const { return m_scalar; }
const std::string& scalar() const { return m_scalar; } const std::string& tag() const { return m_tag; }
const std::string& tag() const { return m_tag; }
// size/iterator
// size/iterator std::size_t size() const;
std::size_t size() const;
const_node_iterator begin() const;
const_node_iterator begin() const; node_iterator begin();
node_iterator begin();
const_node_iterator end() const;
const_node_iterator end() const; node_iterator end();
node_iterator end();
// sequence
// sequence void push_back(node& node, shared_memory_holder pMemory);
void push_back(node& node, shared_memory_holder pMemory); void insert(node& key, node& value, shared_memory_holder pMemory);
void insert(node& key, node& value, shared_memory_holder pMemory);
// indexing
// indexing template <typename Key>
template<typename Key> node& get(const Key& key, shared_memory_holder pMemory) const; node& get(const Key& key, shared_memory_holder pMemory) const;
template<typename Key> node& get(const Key& key, shared_memory_holder pMemory); template <typename Key>
template<typename Key> bool remove(const Key& key, shared_memory_holder pMemory); node& get(const Key& key, shared_memory_holder pMemory);
template <typename Key>
node& get(node& key, shared_memory_holder pMemory) const; bool remove(const Key& key, shared_memory_holder pMemory);
node& get(node& key, shared_memory_holder pMemory);
bool remove(node& key, shared_memory_holder pMemory); node& get(node& key, shared_memory_holder pMemory) const;
node& get(node& key, shared_memory_holder pMemory);
// map bool remove(node& key, shared_memory_holder pMemory);
template<typename Key, typename Value>
void force_insert(const Key& key, const Value& value, shared_memory_holder pMemory); // map
template <typename Key, typename Value>
public: void force_insert(const Key& key, const Value& value,
static std::string empty_scalar; shared_memory_holder pMemory);
private: public:
void compute_seq_size() const; static std::string empty_scalar;
void compute_map_size() const;
private:
void reset_sequence(); void compute_seq_size() const;
void reset_map(); void compute_map_size() const;
void insert_map_pair(node& key, node& value); void reset_sequence();
void convert_to_map(shared_memory_holder pMemory); void reset_map();
void convert_sequence_to_map(shared_memory_holder pMemory);
void insert_map_pair(node& key, node& value);
template<typename T> void convert_to_map(shared_memory_holder pMemory);
static bool equals(node& node, const T& rhs, shared_memory_holder pMemory); void convert_sequence_to_map(shared_memory_holder pMemory);
static bool equals(node& node, const char *rhs, shared_memory_holder pMemory);
template <typename T>
template<typename T> static bool equals(node& node, const T& rhs, shared_memory_holder pMemory);
static node& convert_to_node(const T& rhs, shared_memory_holder pMemory); static bool equals(node& node, const char* rhs, shared_memory_holder pMemory);
private: template <typename T>
bool m_isDefined; static node& convert_to_node(const T& rhs, shared_memory_holder pMemory);
NodeType::value m_type;
std::string m_tag; private:
bool m_isDefined;
// scalar NodeType::value m_type;
std::string m_scalar; std::string m_tag;
// sequence // scalar
typedef std::vector<node *> node_seq; std::string m_scalar;
node_seq m_sequence;
// sequence
mutable std::size_t m_seqSize; typedef std::vector<node*> node_seq;
node_seq m_sequence;
// map
typedef std::map<node *, node *> node_map; mutable std::size_t m_seqSize;
node_map m_map;
// map
typedef std::pair<node *, node *> kv_pair; typedef std::map<node*, node*> node_map;
typedef std::list<kv_pair> kv_pairs; node_map m_map;
mutable kv_pairs m_undefinedPairs;
}; typedef std::pair<node*, node*> kv_pair;
} typedef std::list<kv_pair> kv_pairs;
mutable kv_pairs m_undefinedPairs;
};
}
} }
#endif // VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #ifndef VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define VALUE_DETAIL_NODE_ITERATOR_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 #if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once #pragma once
#endif #endif
#include "yaml-cpp/dll.h" #include "yaml-cpp/dll.h"
#include "yaml-cpp/node/ptr.h" #include "yaml-cpp/node/ptr.h"
#include <boost/iterator/iterator_facade.hpp> #include <boost/iterator/iterator_facade.hpp>
...@@ -14,126 +15,143 @@ ...@@ -14,126 +15,143 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
namespace YAML namespace YAML {
{ namespace detail {
namespace detail struct iterator_type {
{ enum value {
struct iterator_type { enum value { None, Sequence, Map }; }; None,
Sequence,
template<typename V> Map
struct node_iterator_value: public std::pair<V*, V*> { };
typedef std::pair<V*, V*> kv; };
node_iterator_value(): kv(), pNode(0) {} template <typename V>
explicit node_iterator_value(V& rhs): kv(), pNode(&rhs) {} struct node_iterator_value : public std::pair<V*, V*> {
explicit node_iterator_value(V& key, V& value): kv(&key, &value), pNode(0) {} typedef std::pair<V*, V*> kv;
V& operator *() const { return *pNode; } node_iterator_value() : kv(), pNode(0) {}
V& operator ->() const { return *pNode; } explicit node_iterator_value(V& rhs) : kv(), pNode(&rhs) {}
explicit node_iterator_value(V& key, V& value) : kv(&key, &value), pNode(0) {}
V *pNode;
}; V& operator*() const { return *pNode; }
V& operator->() const { return *pNode; }
typedef std::vector<node *> node_seq;
typedef std::map<node *, node *> node_map; V* pNode;
};
template<typename V>
struct node_iterator_type { typedef std::vector<node*> node_seq;
typedef node_seq::iterator seq; typedef std::map<node*, node*> node_map;
typedef node_map::iterator map;
}; template <typename V>
struct node_iterator_type {
template<typename V> typedef node_seq::iterator seq;
struct node_iterator_type<const V> { typedef node_map::iterator map;
typedef node_seq::const_iterator seq; };
typedef node_map::const_iterator map;
}; template <typename V>
struct node_iterator_type<const V> {
typedef node_seq::const_iterator seq;
template<typename V> typedef node_map::const_iterator map;
class node_iterator_base: public boost::iterator_facade< };
node_iterator_base<V>,
node_iterator_value<V>, template <typename V>
std::forward_iterator_tag, class node_iterator_base
node_iterator_value<V> > : public boost::iterator_facade<
{ node_iterator_base<V>, node_iterator_value<V>,
private: std::forward_iterator_tag, node_iterator_value<V> > {
struct enabler {}; private:
struct enabler {};
public:
typedef typename node_iterator_type<V>::seq SeqIter; public:
typedef typename node_iterator_type<V>::map MapIter; typedef typename node_iterator_type<V>::seq SeqIter;
typedef node_iterator_value<V> value_type; typedef typename node_iterator_type<V>::map MapIter;
typedef node_iterator_value<V> value_type;
node_iterator_base(): m_type(iterator_type::None) {}
explicit node_iterator_base(SeqIter seqIt): m_type(iterator_type::Sequence), m_seqIt(seqIt) {} node_iterator_base() : m_type(iterator_type::None) {}
explicit node_iterator_base(MapIter mapIt, MapIter mapEnd): m_type(iterator_type::Map), m_mapIt(mapIt), m_mapEnd(mapEnd) { explicit node_iterator_base(SeqIter seqIt)
m_mapIt = increment_until_defined(m_mapIt); : m_type(iterator_type::Sequence), m_seqIt(seqIt) {}
} explicit node_iterator_base(MapIter mapIt, MapIter mapEnd)
: m_type(iterator_type::Map), m_mapIt(mapIt), m_mapEnd(mapEnd) {
template<typename W> m_mapIt = increment_until_defined(m_mapIt);
node_iterator_base(const node_iterator_base<W>& rhs, typename boost::enable_if<boost::is_convertible<W*, V*>, enabler>::type = enabler()) }
: m_type(rhs.m_type), m_seqIt(rhs.m_seqIt), m_mapIt(rhs.m_mapIt), m_mapEnd(rhs.m_mapEnd) {}
template <typename W>
private: node_iterator_base(
friend class boost::iterator_core_access; const node_iterator_base<W>& rhs,
template<typename> friend class node_iterator_base; typename boost::enable_if<boost::is_convertible<W*, V*>, enabler>::type =
enabler())
template<typename W> : m_type(rhs.m_type),
bool equal(const node_iterator_base<W>& rhs) const { m_seqIt(rhs.m_seqIt),
if(m_type != rhs.m_type) m_mapIt(rhs.m_mapIt),
return false; m_mapEnd(rhs.m_mapEnd) {}
switch(m_type) { private:
case iterator_type::None: return true; friend class boost::iterator_core_access;
case iterator_type::Sequence: return m_seqIt == rhs.m_seqIt; template <typename>
case iterator_type::Map: return m_mapIt == rhs.m_mapIt; friend class node_iterator_base;
}
return true; template <typename W>
} bool equal(const node_iterator_base<W>& rhs) const {
if (m_type != rhs.m_type)
void increment() { return false;
switch(m_type) {
case iterator_type::None: break; switch (m_type) {
case iterator_type::Sequence: case iterator_type::None:
++m_seqIt; return true;
break; case iterator_type::Sequence:
case iterator_type::Map: return m_seqIt == rhs.m_seqIt;
++m_mapIt; case iterator_type::Map:
m_mapIt = increment_until_defined(m_mapIt); return m_mapIt == rhs.m_mapIt;
break; }
} return true;
} }
value_type dereference() const { void increment() {
switch(m_type) { switch (m_type) {
case iterator_type::None: return value_type(); case iterator_type::None:
case iterator_type::Sequence: return value_type(**m_seqIt); break;
case iterator_type::Map: return value_type(*m_mapIt->first, *m_mapIt->second); case iterator_type::Sequence:
} ++m_seqIt;
return value_type(); break;
} case iterator_type::Map:
++m_mapIt;
MapIter increment_until_defined(MapIter it) { m_mapIt = increment_until_defined(m_mapIt);
while(it != m_mapEnd && !is_defined(it)) break;
++it; }
return it; }
}
value_type dereference() const {
bool is_defined(MapIter it) const { switch (m_type) {
return it->first->is_defined() && it->second->is_defined(); case iterator_type::None:
} return value_type();
case iterator_type::Sequence:
private: return value_type(**m_seqIt);
typename iterator_type::value m_type; case iterator_type::Map:
return value_type(*m_mapIt->first, *m_mapIt->second);
SeqIter m_seqIt; }
MapIter m_mapIt, m_mapEnd; return value_type();
}; }
typedef node_iterator_base<node> node_iterator; MapIter increment_until_defined(MapIter it) {
typedef node_iterator_base<const node> const_node_iterator; while (it != m_mapEnd && !is_defined(it))
} ++it;
return it;
}
bool is_defined(MapIter it) const {
return it->first->is_defined() && it->second->is_defined();
}
private:
typename iterator_type::value m_type;
SeqIter m_seqIt;
MapIter m_mapIt, m_mapEnd;
};
typedef node_iterator_base<node> node_iterator;
typedef node_iterator_base<const node> const_node_iterator;
}
} }
#endif // VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #ifndef VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define VALUE_DETAIL_NODE_REF_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 #if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once #pragma once
#endif #endif
#include "yaml-cpp/dll.h" #include "yaml-cpp/dll.h"
#include "yaml-cpp/node/type.h" #include "yaml-cpp/node/type.h"
#include "yaml-cpp/node/ptr.h" #include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/detail/node_data.h" #include "yaml-cpp/node/detail/node_data.h"
#include <boost/utility.hpp> #include <boost/utility.hpp>
namespace YAML namespace YAML {
{ namespace detail {
namespace detail class node_ref : private boost::noncopyable {
{ public:
class node_ref: private boost::noncopyable node_ref() : m_pData(new node_data) {}
{
public: bool is_defined() const { return m_pData->is_defined(); }
node_ref(): m_pData(new node_data) {} NodeType::value type() const { return m_pData->type(); }
const std::string& scalar() const { return m_pData->scalar(); }
bool is_defined() const { return m_pData->is_defined(); } const std::string& tag() const { return m_pData->tag(); }
NodeType::value type() const { return m_pData->type(); }
const std::string& scalar() const { return m_pData->scalar(); } void mark_defined() { m_pData->mark_defined(); }
const std::string& tag() const { return m_pData->tag(); } void set_data(const node_ref& rhs) { m_pData = rhs.m_pData; }
void mark_defined() { m_pData->mark_defined(); } void set_type(NodeType::value type) { m_pData->set_type(type); }
void set_data(const node_ref& rhs) { m_pData = rhs.m_pData; } void set_tag(const std::string& tag) { m_pData->set_tag(tag); }
void set_null() { m_pData->set_null(); }
void set_type(NodeType::value type) { m_pData->set_type(type); } void set_scalar(const std::string& scalar) { m_pData->set_scalar(scalar); }
void set_tag(const std::string& tag) { m_pData->set_tag(tag); }
void set_null() { m_pData->set_null(); } // size/iterator
void set_scalar(const std::string& scalar) { m_pData->set_scalar(scalar); } std::size_t size() const { return m_pData->size(); }
// size/iterator const_node_iterator begin() const {
std::size_t size() const { return m_pData->size(); } return static_cast<const node_data&>(*m_pData).begin();
}
const_node_iterator begin() const { return static_cast<const node_data&>(*m_pData).begin(); } node_iterator begin() { return m_pData->begin(); }
node_iterator begin() {return m_pData->begin(); }
const_node_iterator end() const { return static_cast<const node_data&>(*m_pData).end(); }
node_iterator end() {return m_pData->end(); }
// sequence const_node_iterator end() const {
void push_back(node& node, shared_memory_holder pMemory) { m_pData->push_back(node, pMemory); } return static_cast<const node_data&>(*m_pData).end();
void insert(node& key, node& value, shared_memory_holder pMemory) { m_pData->insert(key, value, pMemory); } }
node_iterator end() { return m_pData->end(); }
// indexing
template<typename Key> node& get(const Key& key, shared_memory_holder pMemory) const { return static_cast<const node_data&>(*m_pData).get(key, pMemory); }
template<typename Key> node& get(const Key& key, shared_memory_holder pMemory) { return m_pData->get(key, pMemory); }
template<typename Key> bool remove(const Key& key, shared_memory_holder pMemory) { return m_pData->remove(key, pMemory); }
node& get(node& key, shared_memory_holder pMemory) const { return static_cast<const node_data&>(*m_pData).get(key, pMemory); }
node& get(node& key, shared_memory_holder pMemory) { return m_pData->get(key, pMemory); }
bool remove(node& key, shared_memory_holder pMemory) { return m_pData->remove(key, pMemory); }
// map
template<typename Key, typename Value>
void force_insert(const Key& key, const Value& value, shared_memory_holder pMemory) { m_pData->force_insert(key, value, pMemory); }
private: // sequence
shared_node_data m_pData; void push_back(node& node, shared_memory_holder pMemory) {
}; m_pData->push_back(node, pMemory);
} }
void insert(node& key, node& value, shared_memory_holder pMemory) {
m_pData->insert(key, value, pMemory);
}
// indexing
template <typename Key>
node& get(const Key& key, shared_memory_holder pMemory) const {
return static_cast<const node_data&>(*m_pData).get(key, pMemory);
}
template <typename Key>
node& get(const Key& key, shared_memory_holder pMemory) {
return m_pData->get(key, pMemory);
}
template <typename Key>
bool remove(const Key& key, shared_memory_holder pMemory) {
return m_pData->remove(key, pMemory);
}
node& get(node& key, shared_memory_holder pMemory) const {
return static_cast<const node_data&>(*m_pData).get(key, pMemory);
}
node& get(node& key, shared_memory_holder pMemory) {
return m_pData->get(key, pMemory);
}
bool remove(node& key, shared_memory_holder pMemory) {
return m_pData->remove(key, pMemory);
}
// map
template <typename Key, typename Value>
void force_insert(const Key& key, const Value& value,
shared_memory_holder pMemory) {
m_pData->force_insert(key, value, pMemory);
}
private:
shared_node_data m_pData;
};
}
} }
#endif // VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #ifndef NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define NODE_EMIT_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 #if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once #pragma once
#endif #endif
#include <string> #include <string>
#include <iosfwd> #include <iosfwd>
namespace YAML namespace YAML {
{ class Emitter;
class Emitter; class Node;
class Node;
Emitter& operator<<(Emitter& out, const Node& node);
Emitter& operator << (Emitter& out, const Node& node); std::ostream& operator<<(std::ostream& out, const Node& node);
std::ostream& operator << (std::ostream& out, const Node& node);
std::string Dump(const Node& node);
}
#endif // NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 std::string Dump(const Node& node);
}
#endif // NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
This diff is collapsed.
#ifndef VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #ifndef VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define VALUE_ITERATOR_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 #if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once #pragma once
#endif #endif
#include "yaml-cpp/dll.h" #include "yaml-cpp/dll.h"
#include "yaml-cpp/node/node.h" #include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/detail/iterator_fwd.h" #include "yaml-cpp/node/detail/iterator_fwd.h"
...@@ -14,15 +15,17 @@ ...@@ -14,15 +15,17 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
namespace YAML namespace YAML {
{ namespace detail {
namespace detail { struct iterator_value : public Node, std::pair<Node, Node> {
struct iterator_value: public Node, std::pair<Node, Node> { iterator_value() {}
iterator_value() {} explicit iterator_value(const Node& rhs)
explicit iterator_value(const Node& rhs): Node(rhs), std::pair<Node, Node>(Node(Node::ZombieNode), Node(Node::ZombieNode)) {} : Node(rhs),
explicit iterator_value(const Node& key, const Node& value): Node(Node::ZombieNode), std::pair<Node, Node>(key, value) {} std::pair<Node, Node>(Node(Node::ZombieNode), Node(Node::ZombieNode)) {}
}; explicit iterator_value(const Node& key, const Node& value)
} : Node(Node::ZombieNode), std::pair<Node, Node>(key, value) {}
};
}
} }
#endif // VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #ifndef NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define NODE_NODE_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 #if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once #pragma once
#endif #endif
#include "yaml-cpp/dll.h" #include "yaml-cpp/dll.h"
#include "yaml-cpp/node/ptr.h" #include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/type.h" #include "yaml-cpp/node/type.h"
...@@ -13,104 +14,115 @@ ...@@ -13,104 +14,115 @@
#include "yaml-cpp/node/detail/bool_type.h" #include "yaml-cpp/node/detail/bool_type.h"
#include <stdexcept> #include <stdexcept>
namespace YAML namespace YAML {
{ class Node {
class Node public:
{ friend class NodeBuilder;
public: friend class NodeEvents;
friend class NodeBuilder; friend struct detail::iterator_value;
friend class NodeEvents; friend class detail::node_data;
friend struct detail::iterator_value; template <typename>
friend class detail::node_data; friend class detail::iterator_base;
template<typename> friend class detail::iterator_base; template <typename T, typename S>
template<typename T, typename S> friend struct as_if; friend struct as_if;
typedef YAML::iterator iterator; typedef YAML::iterator iterator;
typedef YAML::const_iterator const_iterator; typedef YAML::const_iterator const_iterator;
Node(); Node();
explicit Node(NodeType::value type); explicit Node(NodeType::value type);
template<typename T> explicit Node(const T& rhs); template <typename T>
explicit Node(const detail::iterator_value& rhs); explicit Node(const T& rhs);
Node(const Node& rhs); explicit Node(const detail::iterator_value& rhs);
~Node(); Node(const Node& rhs);
~Node();
NodeType::value Type() const;
bool IsDefined() const; NodeType::value Type() const;
bool IsNull() const { return Type() == NodeType::Null; } bool IsDefined() const;
bool IsScalar() const { return Type() == NodeType::Scalar; } bool IsNull() const { return Type() == NodeType::Null; }
bool IsSequence() const { return Type() == NodeType::Sequence; } bool IsScalar() const { return Type() == NodeType::Scalar; }
bool IsMap() const { return Type() == NodeType::Map; } bool IsSequence() const { return Type() == NodeType::Sequence; }
bool IsMap() const { return Type() == NodeType::Map; }
// bool conversions
YAML_CPP_OPERATOR_BOOL(); // bool conversions
bool operator!() const { return !IsDefined(); } YAML_CPP_OPERATOR_BOOL();
bool operator!() const { return !IsDefined(); }
// access
template<typename T> const T as() const; // access
template<typename T, typename S> const T as(const S& fallback) const; template <typename T>
const std::string& Scalar() const; const T as() const;
const std::string& Tag() const; template <typename T, typename S>
void SetTag(const std::string& tag); const T as(const S& fallback) const;
const std::string& Scalar() const;
// assignment const std::string& Tag() const;
bool is(const Node& rhs) const; void SetTag(const std::string& tag);
template<typename T> Node& operator=(const T& rhs);
Node& operator=(const Node& rhs); // assignment
void reset(const Node& rhs = Node()); bool is(const Node& rhs) const;
template <typename T>
// size/iterator Node& operator=(const T& rhs);
std::size_t size() const; Node& operator=(const Node& rhs);
void reset(const Node& rhs = Node());
const_iterator begin() const;
iterator begin(); // size/iterator
std::size_t size() const;
const_iterator end() const;
iterator end(); const_iterator begin() const;
iterator begin();
// sequence
template<typename T> void push_back(const T& rhs); const_iterator end() const;
void push_back(const Node& rhs); iterator end();
// indexing // sequence
template<typename Key> const Node operator[](const Key& key) const; template <typename T>
template<typename Key> Node operator[](const Key& key); void push_back(const T& rhs);
template<typename Key> bool remove(const Key& key); void push_back(const Node& rhs);
const Node operator[](const Node& key) const; // indexing
Node operator[](const Node& key); template <typename Key>
bool remove(const Node& key); const Node operator[](const Key& key) const;
template <typename Key>
// map Node operator[](const Key& key);
template<typename Key, typename Value> template <typename Key>
void force_insert(const Key& key, const Value& value); bool remove(const Key& key);
private: const Node operator[](const Node& key) const;
enum Zombie { ZombieNode }; Node operator[](const Node& key);
explicit Node(Zombie); bool remove(const Node& key);
explicit Node(detail::node& node, detail::shared_memory_holder pMemory);
// map
void EnsureNodeExists() const; template <typename Key, typename Value>
void force_insert(const Key& key, const Value& value);
template<typename T> void Assign(const T& rhs);
void Assign(const char *rhs); private:
void Assign(char *rhs); enum Zombie {
ZombieNode
void AssignData(const Node& rhs); };
void AssignNode(const Node& rhs); explicit Node(Zombie);
explicit Node(detail::node& node, detail::shared_memory_holder pMemory);
private:
bool m_isValid; void EnsureNodeExists() const;
mutable detail::shared_memory_holder m_pMemory;
mutable detail::node *m_pNode; template <typename T>
}; void Assign(const T& rhs);
void Assign(const char* rhs);
bool operator==(const Node& lhs, const Node& rhs); void Assign(char* rhs);
Node Clone(const Node& node); void AssignData(const Node& rhs);
void AssignNode(const Node& rhs);
template<typename T>
struct convert; private:
bool m_isValid;
mutable detail::shared_memory_holder m_pMemory;
mutable detail::node* m_pNode;
};
bool operator==(const Node& lhs, const Node& rhs);
Node Clone(const Node& node);
template <typename T>
struct convert;
} }
#endif // NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #ifndef VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define VALUE_PARSE_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 #if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once #pragma once
#endif #endif
...@@ -9,20 +11,18 @@ ...@@ -9,20 +11,18 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace YAML namespace YAML {
{ class Node;
class Node;
Node Load(const std::string& input);
Node Load(const char *input);
Node Load(std::istream& input);
Node LoadFile(const std::string& filename);
std::vector<Node> LoadAll(const std::string& input); Node Load(const std::string& input);
std::vector<Node> LoadAll(const char *input); Node Load(const char* input);
std::vector<Node> LoadAll(std::istream& input); Node Load(std::istream& input);
std::vector<Node> LoadAllFromFile(const std::string& filename); Node LoadFile(const std::string& filename);
}
#endif // VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 std::vector<Node> LoadAll(const std::string& input);
std::vector<Node> LoadAll(const char* input);
std::vector<Node> LoadAll(std::istream& input);
std::vector<Node> LoadAllFromFile(const std::string& filename);
}
#endif // VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #ifndef VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define VALUE_PTR_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 #if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once #pragma once
#endif #endif
#include "yaml-cpp/dll.h" #include "yaml-cpp/dll.h"
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
namespace YAML namespace YAML {
{ namespace detail {
namespace detail { class node;
class node; class node_ref;
class node_ref; class node_data;
class node_data; class memory;
class memory; class memory_holder;
class memory_holder;
typedef boost::shared_ptr<node> shared_node; typedef boost::shared_ptr<node> shared_node;
typedef boost::shared_ptr<node_ref> shared_node_ref; typedef boost::shared_ptr<node_ref> shared_node_ref;
typedef boost::shared_ptr<node_data> shared_node_data; typedef boost::shared_ptr<node_data> shared_node_data;
typedef boost::shared_ptr<memory_holder> shared_memory_holder; typedef boost::shared_ptr<memory_holder> shared_memory_holder;
typedef boost::shared_ptr<memory> shared_memory; typedef boost::shared_ptr<memory> shared_memory;
} }
} }
#endif // VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #ifndef VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define VALUE_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 #if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once #pragma once
#endif #endif
namespace YAML {
namespace YAML struct NodeType {
{ enum value {
struct NodeType { enum value { Undefined, Null, Scalar, Sequence, Map }; }; Undefined,
Null,
Scalar,
Sequence,
Map
};
};
} }
#endif // VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #ifndef PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define PARSER_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 #if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once #pragma once
#endif #endif
#include "yaml-cpp/dll.h" #include "yaml-cpp/dll.h"
#include "yaml-cpp/noncopyable.h" #include "yaml-cpp/noncopyable.h"
#include <ios> #include <ios>
#include <memory> #include <memory>
namespace YAML namespace YAML {
{ struct Directives;
struct Directives; struct Token;
struct Token; class EventHandler;
class EventHandler; class Scanner;
class Scanner;
class YAML_CPP_API Parser : private noncopyable {
class YAML_CPP_API Parser: private noncopyable public:
{ Parser();
public: Parser(std::istream& in);
Parser(); ~Parser();
Parser(std::istream& in);
~Parser(); operator bool() const;
operator bool() const; void Load(std::istream& in);
bool HandleNextDocument(EventHandler& eventHandler);
void Load(std::istream& in);
bool HandleNextDocument(EventHandler& eventHandler); void PrintTokens(std::ostream& out);
void PrintTokens(std::ostream& out); private:
void ParseDirectives();
private: void HandleDirective(const Token& token);
void ParseDirectives(); void HandleYamlDirective(const Token& token);
void HandleDirective(const Token& token); void HandleTagDirective(const Token& token);
void HandleYamlDirective(const Token& token);
void HandleTagDirective(const Token& token); private:
std::auto_ptr<Scanner> m_pScanner;
private: std::auto_ptr<Directives> m_pDirectives;
std::auto_ptr<Scanner> m_pScanner; };
std::auto_ptr<Directives> m_pDirectives;
};
} }
#endif // PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
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