First pass at spearating out a 'core' library from the old api (default) branch
This commit is contained in:
parent
fca7b7e190
commit
0d32d19ed8
@ -1,75 +0,0 @@
|
||||
#ifndef CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define CONVERSION_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
|
||||
|
||||
|
||||
#include "yaml-cpp/null.h"
|
||||
#include "yaml-cpp/traits.h"
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
// traits for conversion
|
||||
|
||||
template<typename T>
|
||||
struct is_scalar_convertible { enum { value = is_numeric<T>::value }; };
|
||||
|
||||
template<> struct is_scalar_convertible<std::string> { enum { value = true }; };
|
||||
template<> struct is_scalar_convertible<bool> { enum { value = true }; };
|
||||
template<> struct is_scalar_convertible<_Null> { enum { value = true }; };
|
||||
|
||||
// actual conversion
|
||||
|
||||
inline bool Convert(const std::string& input, std::string& output) {
|
||||
output = input;
|
||||
return true;
|
||||
}
|
||||
|
||||
YAML_CPP_API bool Convert(const std::string& input, bool& output);
|
||||
YAML_CPP_API bool Convert(const std::string& input, _Null& output);
|
||||
|
||||
inline bool IsInfinity(const std::string& input) {
|
||||
return input == ".inf" || input == ".Inf" || input == ".INF" || input == "+.inf" || input == "+.Inf" || input == "+.INF";
|
||||
}
|
||||
|
||||
inline bool IsNegativeInfinity(const std::string& input) {
|
||||
return input == "-.inf" || input == "-.Inf" || input == "-.INF";
|
||||
}
|
||||
|
||||
inline bool IsNaN(const std::string& input) {
|
||||
return input == ".nan" || input == ".NaN" || input == ".NAN";
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline bool Convert(const std::string& input, T& output, typename enable_if<is_numeric<T> >::type * = 0) {
|
||||
std::stringstream stream(input);
|
||||
stream.unsetf(std::ios::dec);
|
||||
if((stream >> output) && (stream >> std::ws).eof())
|
||||
return true;
|
||||
|
||||
if(std::numeric_limits<T>::has_infinity) {
|
||||
if(IsInfinity(input)) {
|
||||
output = std::numeric_limits<T>::infinity();
|
||||
return true;
|
||||
} else if(IsNegativeInfinity(input)) {
|
||||
output = -std::numeric_limits<T>::infinity();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(std::numeric_limits<T>::has_quiet_NaN && IsNaN(input)) {
|
||||
output = std::numeric_limits<T>::quiet_NaN();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
@ -1,40 +0,0 @@
|
||||
#ifndef ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define 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
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include <memory>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class Node;
|
||||
struct IterPriv;
|
||||
|
||||
class YAML_CPP_API Iterator
|
||||
{
|
||||
public:
|
||||
Iterator();
|
||||
Iterator(std::auto_ptr<IterPriv> pData);
|
||||
Iterator(const Iterator& rhs);
|
||||
~Iterator();
|
||||
|
||||
Iterator& operator = (const Iterator& rhs);
|
||||
Iterator& operator ++ ();
|
||||
Iterator operator ++ (int);
|
||||
const Node& operator * () const;
|
||||
const Node *operator -> () const;
|
||||
const Node& first() const;
|
||||
const Node& second() const;
|
||||
|
||||
friend YAML_CPP_API bool operator == (const Iterator& it, const Iterator& jt);
|
||||
friend YAML_CPP_API bool operator != (const Iterator& it, const Iterator& jt);
|
||||
|
||||
private:
|
||||
std::auto_ptr<IterPriv> m_pData;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
@ -1,18 +0,0 @@
|
||||
#ifndef LTNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define LTNODE_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
|
||||
{
|
||||
class Node;
|
||||
|
||||
struct ltnode {
|
||||
bool operator()(const Node *pNode1, const Node *pNode2) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // LTNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
@ -1,135 +0,0 @@
|
||||
#ifndef NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define 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
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include "yaml-cpp/mark.h"
|
||||
#include "yaml-cpp/noncopyable.h"
|
||||
#include "yaml-cpp/conversion.h"
|
||||
#include "yaml-cpp/iterator.h"
|
||||
#include "yaml-cpp/ltnode.h"
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class AliasManager;
|
||||
class Content;
|
||||
class NodeOwnership;
|
||||
class Scanner;
|
||||
class Emitter;
|
||||
class EventHandler;
|
||||
|
||||
struct NodeType { enum value { Null, Scalar, Sequence, Map }; };
|
||||
|
||||
class YAML_CPP_API Node: private noncopyable
|
||||
{
|
||||
public:
|
||||
friend class NodeOwnership;
|
||||
friend class NodeBuilder;
|
||||
|
||||
Node();
|
||||
~Node();
|
||||
|
||||
void Clear();
|
||||
std::auto_ptr<Node> Clone() const;
|
||||
void EmitEvents(EventHandler& eventHandler) const;
|
||||
void EmitEvents(AliasManager& am, EventHandler& eventHandler) const;
|
||||
|
||||
NodeType::value Type() const { return m_type; }
|
||||
bool IsAliased() const;
|
||||
|
||||
// file location of start of this node
|
||||
const Mark GetMark() const { return m_mark; }
|
||||
|
||||
// accessors
|
||||
Iterator begin() const;
|
||||
Iterator end() const;
|
||||
std::size_t size() const;
|
||||
|
||||
// extraction of scalars
|
||||
bool GetScalar(std::string& s) const;
|
||||
|
||||
// we can specialize this for other values
|
||||
template <typename T>
|
||||
bool Read(T& value) const;
|
||||
|
||||
template <typename T>
|
||||
const T to() const;
|
||||
|
||||
template <typename T>
|
||||
friend YAML_CPP_API typename enable_if<is_scalar_convertible<T> >::type operator >> (const Node& node, T& value);
|
||||
|
||||
// retrieval for maps and sequences
|
||||
template <typename T>
|
||||
const Node *FindValue(const T& key) const;
|
||||
|
||||
template <typename T>
|
||||
const Node& operator [] (const T& key) const;
|
||||
|
||||
// specific to maps
|
||||
const Node *FindValue(const char *key) const;
|
||||
const Node *FindValue(char *key) const;
|
||||
const Node& operator [] (const char *key) const;
|
||||
const Node& operator [] (char *key) const;
|
||||
|
||||
// for tags
|
||||
const std::string& Tag() const { return m_tag; }
|
||||
|
||||
// emitting
|
||||
friend YAML_CPP_API Emitter& operator << (Emitter& out, const Node& node);
|
||||
|
||||
// ordering
|
||||
int Compare(const Node& rhs) const;
|
||||
friend bool operator < (const Node& n1, const Node& n2);
|
||||
|
||||
private:
|
||||
explicit Node(NodeOwnership& owner);
|
||||
Node& CreateNode();
|
||||
|
||||
void Init(NodeType::value type, const Mark& mark, const std::string& tag);
|
||||
|
||||
void MarkAsAliased();
|
||||
void SetScalarData(const std::string& data);
|
||||
void Append(Node& node);
|
||||
void Insert(Node& key, Node& value);
|
||||
|
||||
// helper for sequences
|
||||
template <typename, bool> friend struct _FindFromNodeAtIndex;
|
||||
const Node *FindAtIndex(std::size_t i) const;
|
||||
|
||||
// helper for maps
|
||||
template <typename T>
|
||||
const Node& GetValue(const T& key) const;
|
||||
|
||||
template <typename T>
|
||||
const Node *FindValueForKey(const T& key) const;
|
||||
|
||||
private:
|
||||
std::auto_ptr<NodeOwnership> m_pOwnership;
|
||||
|
||||
Mark m_mark;
|
||||
std::string m_tag;
|
||||
|
||||
typedef std::vector<Node *> node_seq;
|
||||
typedef std::map<Node *, Node *, ltnode> node_map;
|
||||
|
||||
NodeType::value m_type;
|
||||
std::string m_scalarData;
|
||||
node_seq m_seqData;
|
||||
node_map m_mapData;
|
||||
};
|
||||
}
|
||||
|
||||
#include "yaml-cpp/nodeimpl.h"
|
||||
#include "yaml-cpp/nodereadimpl.h"
|
||||
|
||||
#endif // NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
@ -1,85 +0,0 @@
|
||||
#ifndef NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODEIMPL_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
|
||||
|
||||
|
||||
#include "yaml-cpp/nodeutil.h"
|
||||
#include <cassert>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
// implementation of templated things
|
||||
template <typename T>
|
||||
inline const T Node::to() const {
|
||||
T value;
|
||||
*this >> value;
|
||||
return value;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline typename enable_if<is_scalar_convertible<T> >::type operator >> (const Node& node, T& value) {
|
||||
if(!ConvertScalar(node, value))
|
||||
throw InvalidScalar(node.m_mark);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const Node *Node::FindValue(const T& key) const {
|
||||
switch(m_type) {
|
||||
case NodeType::Null:
|
||||
case NodeType::Scalar:
|
||||
throw BadDereference();
|
||||
case NodeType::Sequence:
|
||||
return FindFromNodeAtIndex(*this, key);
|
||||
case NodeType::Map:
|
||||
return FindValueForKey(key);
|
||||
}
|
||||
assert(false);
|
||||
throw BadDereference();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const Node *Node::FindValueForKey(const T& key) const {
|
||||
for(Iterator it=begin();it!=end();++it) {
|
||||
T t;
|
||||
if(it.first().Read(t)) {
|
||||
if(key == t)
|
||||
return &it.second();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const Node& Node::GetValue(const T& key) const {
|
||||
if(const Node *pValue = FindValue(key))
|
||||
return *pValue;
|
||||
throw MakeTypedKeyNotFound(m_mark, key);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const Node& Node::operator [] (const T& key) const {
|
||||
return GetValue(key);
|
||||
}
|
||||
|
||||
inline const Node *Node::FindValue(const char *key) const {
|
||||
return FindValue(std::string(key));
|
||||
}
|
||||
|
||||
inline const Node *Node::FindValue(char *key) const {
|
||||
return FindValue(std::string(key));
|
||||
}
|
||||
|
||||
inline const Node& Node::operator [] (const char *key) const {
|
||||
return GetValue(std::string(key));
|
||||
}
|
||||
|
||||
inline const Node& Node::operator [] (char *key) const {
|
||||
return GetValue(std::string(key));
|
||||
}
|
||||
}
|
||||
|
||||
#endif // NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
@ -1,86 +0,0 @@
|
||||
#ifndef NODEREADIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODEREADIMPL_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
|
||||
{
|
||||
// implementation for Node::Read
|
||||
// (the goal is to call ConvertScalar if we can, and fall back to operator >> if not)
|
||||
// thanks to litb from stackoverflow.com
|
||||
// http://stackoverflow.com/questions/1386183/how-to-call-a-templated-function-if-it-exists-and-something-else-otherwise/1386390#1386390
|
||||
|
||||
// Note: this doesn't work on gcc 3.2, but does on gcc 3.4 and above. I'm not sure about 3.3.
|
||||
|
||||
#if __GNUC__ && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ <= 3))
|
||||
// trick doesn't work? Just fall back to ConvertScalar.
|
||||
// This means that we can't use any user-defined types as keys in a map
|
||||
template <typename T>
|
||||
inline bool Node::Read(T& value) const {
|
||||
return ConvertScalar(*this, value);
|
||||
}
|
||||
#else
|
||||
// usual case: the trick!
|
||||
template<bool>
|
||||
struct read_impl;
|
||||
|
||||
// ConvertScalar available
|
||||
template<>
|
||||
struct read_impl<true> {
|
||||
template<typename T>
|
||||
static bool read(const Node& node, T& value) {
|
||||
return ConvertScalar(node, value);
|
||||
}
|
||||
};
|
||||
|
||||
// ConvertScalar not available
|
||||
template<>
|
||||
struct read_impl<false> {
|
||||
template<typename T>
|
||||
static bool read(const Node& node, T& value) {
|
||||
try {
|
||||
node >> value;
|
||||
} catch(const Exception&) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
namespace fallback {
|
||||
// sizeof > 1
|
||||
struct flag { char c[2]; };
|
||||
flag Convert(...);
|
||||
|
||||
int operator,(flag, flag);
|
||||
|
||||
template<typename T>
|
||||
char operator,(flag, T const&);
|
||||
|
||||
char operator,(int, flag);
|
||||
int operator,(char, flag);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool Node::Read(T& value) const {
|
||||
using namespace fallback;
|
||||
|
||||
return read_impl<sizeof (fallback::flag(), Convert(std::string(), value), fallback::flag()) != 1>::read(*this, value);
|
||||
}
|
||||
#endif // done with trick
|
||||
|
||||
// the main conversion function
|
||||
template <typename T>
|
||||
inline bool ConvertScalar(const Node& node, T& value) {
|
||||
std::string scalar;
|
||||
if(!node.GetScalar(scalar))
|
||||
return false;
|
||||
|
||||
return Convert(scalar, value);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // NODEREADIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
@ -1,62 +0,0 @@
|
||||
#ifndef NODEUTIL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODEUTIL_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
|
||||
{
|
||||
template <typename T, typename U>
|
||||
struct is_same_type {
|
||||
enum { value = false };
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_same_type<T, T> {
|
||||
enum { value = true };
|
||||
};
|
||||
|
||||
template <typename T, bool check>
|
||||
struct is_index_type_with_check {
|
||||
enum { value = false };
|
||||
};
|
||||
|
||||
template <> struct is_index_type_with_check<std::size_t, false> { enum { value = true }; };
|
||||
|
||||
#define MAKE_INDEX_TYPE(Type) \
|
||||
template <> struct is_index_type_with_check<Type, is_same_type<Type, std::size_t>::value> { enum { value = true }; }
|
||||
|
||||
MAKE_INDEX_TYPE(int);
|
||||
MAKE_INDEX_TYPE(unsigned);
|
||||
MAKE_INDEX_TYPE(short);
|
||||
MAKE_INDEX_TYPE(unsigned short);
|
||||
MAKE_INDEX_TYPE(long);
|
||||
MAKE_INDEX_TYPE(unsigned long);
|
||||
|
||||
#undef MAKE_INDEX_TYPE
|
||||
|
||||
template <typename T>
|
||||
struct is_index_type: public is_index_type_with_check<T, false> {};
|
||||
|
||||
// messing around with template stuff to get the right overload for operator [] for a sequence
|
||||
template <typename T, bool b>
|
||||
struct _FindFromNodeAtIndex {
|
||||
const Node *pRet;
|
||||
_FindFromNodeAtIndex(const Node&, const T&): pRet(0) {}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct _FindFromNodeAtIndex<T, true> {
|
||||
const Node *pRet;
|
||||
_FindFromNodeAtIndex(const Node& node, const T& key): pRet(node.FindAtIndex(static_cast<std::size_t>(key))) {}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline const Node *FindFromNodeAtIndex(const Node& node, const T& key) {
|
||||
return _FindFromNodeAtIndex<T, is_index_type<T>::value>(node, key).pRet;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // NODEUTIL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
@ -1,29 +0,0 @@
|
||||
#include "yaml-cpp/aliasmanager.h"
|
||||
#include "yaml-cpp/node.h"
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
AliasManager::AliasManager(): m_curAnchor(0)
|
||||
{
|
||||
}
|
||||
|
||||
void AliasManager::RegisterReference(const Node& node)
|
||||
{
|
||||
m_anchorByIdentity.insert(std::make_pair(&node, _CreateNewAnchor()));
|
||||
}
|
||||
|
||||
anchor_t AliasManager::LookupAnchor(const Node& node) const
|
||||
{
|
||||
AnchorByIdentity::const_iterator it = m_anchorByIdentity.find(&node);
|
||||
if(it == m_anchorByIdentity.end())
|
||||
return 0;
|
||||
return it->second;
|
||||
}
|
||||
|
||||
anchor_t AliasManager::_CreateNewAnchor()
|
||||
{
|
||||
return ++m_curAnchor;
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
#include "yaml-cpp/conversion.h"
|
||||
#include <algorithm>
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Specializations for converting a string to specific types
|
||||
|
||||
namespace
|
||||
{
|
||||
// we're not gonna mess with the mess that is all the isupper/etc. functions
|
||||
bool IsLower(char ch) { return 'a' <= ch && ch <= 'z'; }
|
||||
bool IsUpper(char ch) { return 'A' <= ch && ch <= 'Z'; }
|
||||
char ToLower(char ch) { return IsUpper(ch) ? ch + 'a' - 'A' : ch; }
|
||||
|
||||
std::string tolower(const std::string& str)
|
||||
{
|
||||
std::string s(str);
|
||||
std::transform(s.begin(), s.end(), s.begin(), ToLower);
|
||||
return s;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool IsEntirely(const std::string& str, T func)
|
||||
{
|
||||
for(std::size_t i=0;i<str.size();i++)
|
||||
if(!func(str[i]))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// IsFlexibleCase
|
||||
// . Returns true if 'str' is:
|
||||
// . UPPERCASE
|
||||
// . lowercase
|
||||
// . Capitalized
|
||||
bool IsFlexibleCase(const std::string& str)
|
||||
{
|
||||
if(str.empty())
|
||||
return true;
|
||||
|
||||
if(IsEntirely(str, IsLower))
|
||||
return true;
|
||||
|
||||
bool firstcaps = IsUpper(str[0]);
|
||||
std::string rest = str.substr(1);
|
||||
return firstcaps && (IsEntirely(rest, IsLower) || IsEntirely(rest, IsUpper));
|
||||
}
|
||||
}
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
bool Convert(const std::string& input, bool& b)
|
||||
{
|
||||
// we can't use iostream bool extraction operators as they don't
|
||||
// recognize all possible values in the table below (taken from
|
||||
// http://yaml.org/type/bool.html)
|
||||
static const struct {
|
||||
std::string truename, falsename;
|
||||
} names[] = {
|
||||
{ "y", "n" },
|
||||
{ "yes", "no" },
|
||||
{ "true", "false" },
|
||||
{ "on", "off" },
|
||||
};
|
||||
|
||||
if(!IsFlexibleCase(input))
|
||||
return false;
|
||||
|
||||
for(unsigned i=0;i<sizeof(names)/sizeof(names[0]);i++) {
|
||||
if(names[i].truename == tolower(input)) {
|
||||
b = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(names[i].falsename == tolower(input)) {
|
||||
b = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Convert(const std::string& input, _Null& /*output*/)
|
||||
{
|
||||
return input.empty() || input == "~" || input == "null" || input == "Null" || input == "NULL";
|
||||
}
|
||||
}
|
||||
|
103
src/iterator.cpp
103
src/iterator.cpp
@ -1,103 +0,0 @@
|
||||
#include "yaml-cpp/node.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include "iterpriv.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
Iterator::Iterator(): m_pData(new IterPriv)
|
||||
{
|
||||
}
|
||||
|
||||
Iterator::Iterator(std::auto_ptr<IterPriv> pData): m_pData(pData)
|
||||
{
|
||||
}
|
||||
|
||||
Iterator::Iterator(const Iterator& rhs): m_pData(new IterPriv(*rhs.m_pData))
|
||||
{
|
||||
}
|
||||
|
||||
Iterator& Iterator::operator = (const Iterator& rhs)
|
||||
{
|
||||
if(this == &rhs)
|
||||
return *this;
|
||||
|
||||
m_pData.reset(new IterPriv(*rhs.m_pData));
|
||||
return *this;
|
||||
}
|
||||
|
||||
Iterator::~Iterator()
|
||||
{
|
||||
}
|
||||
|
||||
Iterator& Iterator::operator ++ ()
|
||||
{
|
||||
if(m_pData->type == IterPriv::IT_SEQ)
|
||||
++m_pData->seqIter;
|
||||
else if(m_pData->type == IterPriv::IT_MAP)
|
||||
++m_pData->mapIter;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Iterator Iterator::operator ++ (int)
|
||||
{
|
||||
Iterator temp = *this;
|
||||
|
||||
if(m_pData->type == IterPriv::IT_SEQ)
|
||||
++m_pData->seqIter;
|
||||
else if(m_pData->type == IterPriv::IT_MAP)
|
||||
++m_pData->mapIter;
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
const Node& Iterator::operator * () const
|
||||
{
|
||||
if(m_pData->type == IterPriv::IT_SEQ)
|
||||
return **m_pData->seqIter;
|
||||
|
||||
throw BadDereference();
|
||||
}
|
||||
|
||||
const Node *Iterator::operator -> () const
|
||||
{
|
||||
if(m_pData->type == IterPriv::IT_SEQ)
|
||||
return *m_pData->seqIter;
|
||||
|
||||
throw BadDereference();
|
||||
}
|
||||
|
||||
const Node& Iterator::first() const
|
||||
{
|
||||
if(m_pData->type == IterPriv::IT_MAP)
|
||||
return *m_pData->mapIter->first;
|
||||
|
||||
throw BadDereference();
|
||||
}
|
||||
|
||||
const Node& Iterator::second() const
|
||||
{
|
||||
if(m_pData->type == IterPriv::IT_MAP)
|
||||
return *m_pData->mapIter->second;
|
||||
|
||||
throw BadDereference();
|
||||
}
|
||||
|
||||
bool operator == (const Iterator& it, const Iterator& jt)
|
||||
{
|
||||
if(it.m_pData->type != jt.m_pData->type)
|
||||
return false;
|
||||
|
||||
if(it.m_pData->type == IterPriv::IT_SEQ)
|
||||
return it.m_pData->seqIter == jt.m_pData->seqIter;
|
||||
else if(it.m_pData->type == IterPriv::IT_MAP)
|
||||
return it.m_pData->mapIter == jt.m_pData->mapIter;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator != (const Iterator& it, const Iterator& jt)
|
||||
{
|
||||
return !(it == jt);
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
#ifndef ITERPRIV_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define ITERPRIV_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
|
||||
|
||||
|
||||
#include "yaml-cpp/ltnode.h"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class Node;
|
||||
|
||||
// IterPriv
|
||||
// . The implementation for iterators - essentially a union of sequence and map iterators.
|
||||
struct IterPriv
|
||||
{
|
||||
IterPriv(): type(IT_NONE) {}
|
||||
IterPriv(std::vector <Node *>::const_iterator it): type(IT_SEQ), seqIter(it) {}
|
||||
IterPriv(std::map <Node *, Node *, ltnode>::const_iterator it): type(IT_MAP), mapIter(it) {}
|
||||
|
||||
enum ITER_TYPE { IT_NONE, IT_SEQ, IT_MAP };
|
||||
ITER_TYPE type;
|
||||
|
||||
std::vector <Node *>::const_iterator seqIter;
|
||||
std::map <Node *, Node *, ltnode>::const_iterator mapIter;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // ITERPRIV_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
269
src/node.cpp
269
src/node.cpp
@ -1,269 +0,0 @@
|
||||
#include "yaml-cpp/node.h"
|
||||
#include "yaml-cpp/aliasmanager.h"
|
||||
#include "yaml-cpp/emitfromevents.h"
|
||||
#include "yaml-cpp/emitter.h"
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
#include "iterpriv.h"
|
||||
#include "nodebuilder.h"
|
||||
#include "nodeownership.h"
|
||||
#include "scanner.h"
|
||||
#include "tag.h"
|
||||
#include "token.h"
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
bool ltnode::operator()(const Node *pNode1, const Node *pNode2) const {
|
||||
return *pNode1 < *pNode2;
|
||||
}
|
||||
|
||||
Node::Node(): m_pOwnership(new NodeOwnership), m_type(NodeType::Null)
|
||||
{
|
||||
}
|
||||
|
||||
Node::Node(NodeOwnership& owner): m_pOwnership(new NodeOwnership(&owner)), m_type(NodeType::Null)
|
||||
{
|
||||
}
|
||||
|
||||
Node::~Node()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Node::Clear()
|
||||
{
|
||||
m_pOwnership.reset(new NodeOwnership);
|
||||
m_type = NodeType::Null;
|
||||
m_tag.clear();
|
||||
m_scalarData.clear();
|
||||
m_seqData.clear();
|
||||
m_mapData.clear();
|
||||
}
|
||||
|
||||
bool Node::IsAliased() const
|
||||
{
|
||||
return m_pOwnership->IsAliased(*this);
|
||||
}
|
||||
|
||||
Node& Node::CreateNode()
|
||||
{
|
||||
return m_pOwnership->Create();
|
||||
}
|
||||
|
||||
std::auto_ptr<Node> Node::Clone() const
|
||||
{
|
||||
std::auto_ptr<Node> pNode(new Node);
|
||||
NodeBuilder nodeBuilder(*pNode);
|
||||
EmitEvents(nodeBuilder);
|
||||
return pNode;
|
||||
}
|
||||
|
||||
void Node::EmitEvents(EventHandler& eventHandler) const
|
||||
{
|
||||
eventHandler.OnDocumentStart(m_mark);
|
||||
AliasManager am;
|
||||
EmitEvents(am, eventHandler);
|
||||
eventHandler.OnDocumentEnd();
|
||||
}
|
||||
|
||||
void Node::EmitEvents(AliasManager& am, EventHandler& eventHandler) const
|
||||
{
|
||||
anchor_t anchor = NullAnchor;
|
||||
if(IsAliased()) {
|
||||
anchor = am.LookupAnchor(*this);
|
||||
if(anchor) {
|
||||
eventHandler.OnAlias(m_mark, anchor);
|
||||
return;
|
||||
}
|
||||
|
||||
am.RegisterReference(*this);
|
||||
anchor = am.LookupAnchor(*this);
|
||||
}
|
||||
|
||||
switch(m_type) {
|
||||
case NodeType::Null:
|
||||
eventHandler.OnNull(m_mark, anchor);
|
||||
break;
|
||||
case NodeType::Scalar:
|
||||
eventHandler.OnScalar(m_mark, m_tag, anchor, m_scalarData);
|
||||
break;
|
||||
case NodeType::Sequence:
|
||||
eventHandler.OnSequenceStart(m_mark, m_tag, anchor);
|
||||
for(std::size_t i=0;i<m_seqData.size();i++)
|
||||
m_seqData[i]->EmitEvents(am, eventHandler);
|
||||
eventHandler.OnSequenceEnd();
|
||||
break;
|
||||
case NodeType::Map:
|
||||
eventHandler.OnMapStart(m_mark, m_tag, anchor);
|
||||
for(node_map::const_iterator it=m_mapData.begin();it!=m_mapData.end();++it) {
|
||||
it->first->EmitEvents(am, eventHandler);
|
||||
it->second->EmitEvents(am, eventHandler);
|
||||
}
|
||||
eventHandler.OnMapEnd();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Node::Init(NodeType::value type, const Mark& mark, const std::string& tag)
|
||||
{
|
||||
Clear();
|
||||
m_mark = mark;
|
||||
m_type = type;
|
||||
m_tag = tag;
|
||||
}
|
||||
|
||||
void Node::MarkAsAliased()
|
||||
{
|
||||
m_pOwnership->MarkAsAliased(*this);
|
||||
}
|
||||
|
||||
void Node::SetScalarData(const std::string& data)
|
||||
{
|
||||
assert(m_type == NodeType::Scalar); // TODO: throw?
|
||||
m_scalarData = data;
|
||||
}
|
||||
|
||||
void Node::Append(Node& node)
|
||||
{
|
||||
assert(m_type == NodeType::Sequence); // TODO: throw?
|
||||
m_seqData.push_back(&node);
|
||||
}
|
||||
|
||||
void Node::Insert(Node& key, Node& value)
|
||||
{
|
||||
assert(m_type == NodeType::Map); // TODO: throw?
|
||||
m_mapData[&key] = &value;
|
||||
}
|
||||
|
||||
// begin
|
||||
// Returns an iterator to the beginning of this (sequence or map).
|
||||
Iterator Node::begin() const
|
||||
{
|
||||
switch(m_type) {
|
||||
case NodeType::Null:
|
||||
case NodeType::Scalar:
|
||||
return Iterator();
|
||||
case NodeType::Sequence:
|
||||
return Iterator(std::auto_ptr<IterPriv>(new IterPriv(m_seqData.begin())));
|
||||
case NodeType::Map:
|
||||
return Iterator(std::auto_ptr<IterPriv>(new IterPriv(m_mapData.begin())));
|
||||
}
|
||||
|
||||
assert(false);
|
||||
return Iterator();
|
||||
}
|
||||
|
||||
// end
|
||||
// . Returns an iterator to the end of this (sequence or map).
|
||||
Iterator Node::end() const
|
||||
{
|
||||
switch(m_type) {
|
||||
case NodeType::Null:
|
||||
case NodeType::Scalar:
|
||||
return Iterator();
|
||||
case NodeType::Sequence:
|
||||
return Iterator(std::auto_ptr<IterPriv>(new IterPriv(m_seqData.end())));
|
||||
case NodeType::Map:
|
||||
return Iterator(std::auto_ptr<IterPriv>(new IterPriv(m_mapData.end())));
|
||||
}
|
||||
|
||||
assert(false);
|
||||
return Iterator();
|
||||
}
|
||||
|
||||
// size
|
||||
// . Returns the size of a sequence or map node
|
||||
// . Otherwise, returns zero.
|
||||
std::size_t Node::size() const
|
||||
{
|
||||
switch(m_type) {
|
||||
case NodeType::Null:
|
||||
case NodeType::Scalar:
|
||||
return 0;
|
||||
case NodeType::Sequence:
|
||||
return m_seqData.size();
|
||||
case NodeType::Map:
|
||||
return m_mapData.size();
|
||||
}
|
||||
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const Node *Node::FindAtIndex(std::size_t i) const
|
||||
{
|
||||
if(m_type == NodeType::Sequence)
|
||||
return m_seqData[i];
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Node::GetScalar(std::string& s) const
|
||||
{
|
||||
switch(m_type) {
|
||||
case NodeType::Null:
|
||||
s = "~";
|
||||
return true;
|
||||
case NodeType::Scalar:
|
||||
s = m_scalarData;
|
||||
return true;
|
||||
case NodeType::Sequence:
|
||||
case NodeType::Map:
|
||||
return false;
|
||||
}
|
||||
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
Emitter& operator << (Emitter& out, const Node& node)
|
||||
{
|
||||
EmitFromEvents emitFromEvents(out);
|
||||
node.EmitEvents(emitFromEvents);
|
||||
return out;
|
||||
}
|
||||
|
||||
int Node::Compare(const Node& rhs) const
|
||||
{
|
||||
if(m_type != rhs.m_type)
|
||||
return rhs.m_type - m_type;
|
||||
|
||||
switch(m_type) {
|
||||
case NodeType::Null:
|
||||
return 0;
|
||||
case NodeType::Scalar:
|
||||
return m_scalarData.compare(rhs.m_scalarData);
|
||||
case NodeType::Sequence:
|
||||
if(m_seqData.size() < rhs.m_seqData.size())
|
||||
return 1;
|
||||
else if(m_seqData.size() > rhs.m_seqData.size())
|
||||
return -1;
|
||||
for(std::size_t i=0;i<m_seqData.size();i++)
|
||||
if(int cmp = m_seqData[i]->Compare(*rhs.m_seqData[i]))
|
||||
return cmp;
|
||||
return 0;
|
||||
case NodeType::Map:
|
||||
if(m_mapData.size() < rhs.m_mapData.size())
|
||||
return 1;
|
||||
else if(m_mapData.size() > rhs.m_mapData.size())
|
||||
return -1;
|
||||
node_map::const_iterator it = m_mapData.begin();
|
||||
node_map::const_iterator jt = rhs.m_mapData.begin();
|
||||
for(;it!=m_mapData.end() && jt!=rhs.m_mapData.end();it++, jt++) {
|
||||
if(int cmp = it->first->Compare(*jt->first))
|
||||
return cmp;
|
||||
if(int cmp = it->second->Compare(*jt->second))
|
||||
return cmp;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool operator < (const Node& n1, const Node& n2)
|
||||
{
|
||||
return n1.Compare(n2) < 0;
|
||||
}
|
||||
}
|
@ -1,145 +0,0 @@
|
||||
#include "nodebuilder.h"
|
||||
#include "yaml-cpp/mark.h"
|
||||
#include "yaml-cpp/node.h"
|
||||
#include <cassert>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
NodeBuilder::NodeBuilder(Node& root): m_root(root), m_initializedRoot(false), m_finished(false)
|
||||
{
|
||||
m_root.Clear();
|
||||
m_anchors.push_back(0); // since the anchors start at 1
|
||||
}
|
||||
|
||||
NodeBuilder::~NodeBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
void NodeBuilder::OnDocumentStart(const Mark&)
|
||||
{
|
||||
}
|
||||
|
||||
void NodeBuilder::OnDocumentEnd()
|
||||
{
|
||||
assert(m_finished);
|
||||
}
|
||||
|
||||
void NodeBuilder::OnNull(const Mark& mark, anchor_t anchor)
|
||||
{
|
||||
Node& node = Push(anchor);
|
||||
node.Init(NodeType::Null, mark, "");
|
||||
Pop();
|
||||
}
|
||||
|
||||
void NodeBuilder::OnAlias(const Mark& /*mark*/, anchor_t anchor)
|
||||
{
|
||||
Node& node = *m_anchors[anchor];
|
||||
Insert(node);
|
||||
node.MarkAsAliased();
|
||||
}
|
||||
|
||||
void NodeBuilder::OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value)
|
||||
{
|
||||
Node& node = Push(anchor);
|
||||
node.Init(NodeType::Scalar, mark, tag);
|
||||
node.SetScalarData(value);
|
||||
Pop();
|
||||
}
|
||||
|
||||
void NodeBuilder::OnSequenceStart(const Mark& mark, const std::string& tag, anchor_t anchor)
|
||||
{
|
||||
Node& node = Push(anchor);
|
||||
node.Init(NodeType::Sequence, mark, tag);
|
||||
}
|
||||
|
||||
void NodeBuilder::OnSequenceEnd()
|
||||
{
|
||||
Pop();
|
||||
}
|
||||
|
||||
void NodeBuilder::OnMapStart(const Mark& mark, const std::string& tag, anchor_t anchor)
|
||||
{
|
||||
Node& node = Push(anchor);
|
||||
node.Init(NodeType::Map, mark, tag);
|
||||
m_didPushKey.push(false);
|
||||
}
|
||||
|
||||
void NodeBuilder::OnMapEnd()
|
||||
{
|
||||
m_didPushKey.pop();
|
||||
Pop();
|
||||
}
|
||||
|
||||
Node& NodeBuilder::Push(anchor_t anchor)
|
||||
{
|
||||
Node& node = Push();
|
||||
RegisterAnchor(anchor, node);
|
||||
return node;
|
||||
}
|
||||
|
||||
Node& NodeBuilder::Push()
|
||||
{
|
||||
if(!m_initializedRoot) {
|
||||
m_initializedRoot = true;
|
||||
return m_root;
|
||||
}
|
||||
|
||||
Node& node = m_root.CreateNode();
|
||||
m_stack.push(&node);
|
||||
return node;
|
||||
}
|
||||
|
||||
Node& NodeBuilder::Top()
|
||||
{
|
||||
return m_stack.empty() ? m_root : *m_stack.top();
|
||||
}
|
||||
|
||||
void NodeBuilder::Pop()
|
||||
{
|
||||
assert(!m_finished);
|
||||
if(m_stack.empty()) {
|
||||
m_finished = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Node& node = *m_stack.top();
|
||||
m_stack.pop();
|
||||
Insert(node);
|
||||
}
|
||||
|
||||
void NodeBuilder::Insert(Node& node)
|
||||
{
|
||||
Node& curTop = Top();
|
||||
switch(curTop.Type()) {
|
||||
case NodeType::Null:
|
||||
case NodeType::Scalar:
|
||||
assert(false);
|
||||
break;
|
||||
case NodeType::Sequence:
|
||||
curTop.Append(node);
|
||||
break;
|
||||
case NodeType::Map:
|
||||
assert(!m_didPushKey.empty());
|
||||
if(m_didPushKey.top()) {
|
||||
assert(!m_pendingKeys.empty());
|
||||
|
||||
Node& key = *m_pendingKeys.top();
|
||||
m_pendingKeys.pop();
|
||||
curTop.Insert(key, node);
|
||||
m_didPushKey.top() = false;
|
||||
} else {
|
||||
m_pendingKeys.push(&node);
|
||||
m_didPushKey.top() = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void NodeBuilder::RegisterAnchor(anchor_t anchor, Node& node)
|
||||
{
|
||||
if(anchor) {
|
||||
assert(anchor == m_anchors.size());
|
||||
m_anchors.push_back(&node);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
#ifndef NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODEBUILDER_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
|
||||
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class Node;
|
||||
|
||||
class NodeBuilder: public EventHandler
|
||||
{
|
||||
public:
|
||||
explicit NodeBuilder(Node& root);
|
||||
virtual ~NodeBuilder();
|
||||
|
||||
virtual void OnDocumentStart(const Mark& mark);
|
||||
virtual void OnDocumentEnd();
|
||||
|
||||
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);
|
||||
|
||||
virtual void OnSequenceStart(const Mark& mark, const std::string& tag, anchor_t anchor);
|
||||
virtual void OnSequenceEnd();
|
||||
|
||||
virtual void OnMapStart(const Mark& mark, const std::string& tag, anchor_t anchor);
|
||||
virtual void OnMapEnd();
|
||||
|
||||
private:
|
||||
Node& Push(anchor_t anchor);
|
||||
Node& Push();
|
||||
Node& Top();
|
||||
void Pop();
|
||||
|
||||
void Insert(Node& node);
|
||||
void RegisterAnchor(anchor_t anchor, Node& node);
|
||||
|
||||
private:
|
||||
Node& m_root;
|
||||
bool m_initializedRoot;
|
||||
bool m_finished;
|
||||
|
||||
std::stack<Node *> m_stack;
|
||||
std::stack<Node *> m_pendingKeys;
|
||||
std::stack<bool> m_didPushKey;
|
||||
|
||||
typedef std::vector<Node *> Anchors;
|
||||
Anchors m_anchors;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
@ -1,31 +0,0 @@
|
||||
#include "nodeownership.h"
|
||||
#include "yaml-cpp/node.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
NodeOwnership::NodeOwnership(NodeOwnership *pOwner): m_pOwner(pOwner)
|
||||
{
|
||||
if(!m_pOwner)
|
||||
m_pOwner = this;
|
||||
}
|
||||
|
||||
NodeOwnership::~NodeOwnership()
|
||||
{
|
||||
}
|
||||
|
||||
Node& NodeOwnership::_Create()
|
||||
{
|
||||
m_nodes.push_back(std::auto_ptr<Node>(new Node));
|
||||
return m_nodes.back();
|
||||
}
|
||||
|
||||
void NodeOwnership::_MarkAsAliased(const Node& node)
|
||||
{
|
||||
m_aliasedNodes.insert(&node);
|
||||
}
|
||||
|
||||
bool NodeOwnership::_IsAliased(const Node& node) const
|
||||
{
|
||||
return m_aliasedNodes.count(&node) > 0;
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
#ifndef NODE_OWNERSHIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODE_OWNERSHIP_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
|
||||
|
||||
|
||||
#include "yaml-cpp/noncopyable.h"
|
||||
#include "ptr_vector.h"
|
||||
#include <set>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class Node;
|
||||
|
||||
class NodeOwnership: private noncopyable
|
||||
{
|
||||
public:
|
||||
explicit NodeOwnership(NodeOwnership *pOwner = 0);
|
||||
~NodeOwnership();
|
||||
|
||||
Node& Create() { return m_pOwner->_Create(); }
|
||||
void MarkAsAliased(const Node& node) { m_pOwner->_MarkAsAliased(node); }
|
||||
bool IsAliased(const Node& node) const { return m_pOwner->_IsAliased(node); }
|
||||
|
||||
private:
|
||||
Node& _Create();
|
||||
void _MarkAsAliased(const Node& node);
|
||||
bool _IsAliased(const Node& node) const;
|
||||
|
||||
private:
|
||||
ptr_vector<Node> m_nodes;
|
||||
std::set<const Node *> m_aliasedNodes;
|
||||
NodeOwnership *m_pOwner;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NODE_OWNERSHIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user