Major switch from Value -> Node. The library compiles with the new API, but tests are still oldies, and don't compile

This commit is contained in:
beder
2011-09-10 17:57:23 -05:00
parent 8fd372b0db
commit e905b74232
30 changed files with 387 additions and 364 deletions

View File

@@ -35,6 +35,7 @@ enable_testing()
## Project stuff
option(YAML_CPP_BUILD_TOOLS "Enable testing and parse tools" ON)
option(YAML_CPP_BUILD_CONTRIB "Enable contrib stuff in library" ON)
option(YAML_CPP_BUILD_OLD_API "Enable building the old API" OFF)
## Build options
# --> General
@@ -55,21 +56,35 @@ option(MSVC_STHREADED_RT "MSVC: Build with single-threaded static runtime libs (
###
### Sources, headers, directories and libs
###
file(GLOB sources
"src/[a-zA-Z]*.cpp"
"src/value/[a-zA-Z]*.cpp"
"src/value/detail/[a-zA-Z]*.cpp"
file(GLOB common_sources "src/[a-zA-Z]*.cpp")
file(GLOB new_api_sources
"src/node/[a-zA-Z]*.cpp"
"src/node/detail/[a-zA-Z]*.cpp"
)
file(GLOB public_headers
"include/yaml-cpp/[a-zA-Z]*.h"
"include/yaml-cpp/value/[a-zA-Z]*.h"
"include/yaml-cpp/value/detail/[a-zA-Z]*.h"
file(GLOB old_api_sources "src/old-api/[a-zA-Z]*.cpp")
file(GLOB common_public_headers "include/yaml-cpp/[a-zA-Z]*.h")
file(GLOB new_api_public_headers
"include/yaml-cpp/node/[a-zA-Z]*.h"
"include/yaml-cpp/node/detail/[a-zA-Z]*.h"
)
file(GLOB private_headers
"src/[a-zA-Z]*.h"
"src/value/[a-zA-Z]*.h"
)
file(GLOB old_api_public_headers "include/yaml-cpp/old-api/[a-zA-Z]*.h")
file(GLOB common_private_headers "include/yaml-cpp/[a-zA-Z]*.h")
file(GLOB new_api_private_headers "src/node/[a-zA-Z]*.h")
file(GLOB old_api_private_headers "src/old-api/[a-zA-Z]*.h")
if(YAML_CPP_BUILD_OLD_API)
list(APPEND sources ${common_sources} ${old_api_sources})
list(APPEND public_headers ${common_public_headers} ${old_api_public_headers})
list(APPEND private_headers ${common_private_headers} ${old_api_private_headers})
add_definitions(-DYAML_CPP_OLD_API)
else()
list(APPEND sources ${common_sources} ${new_api_sources})
list(APPEND public_headers ${common_public_headers} ${new_api_public_headers})
list(APPEND private_headers ${common_private_headers} ${new_api_private_headers})
endif()
if(YAML_CPP_BUILD_CONTRIB)
file(GLOB contrib_sources "src/contrib/[a-zA-Z]*.cpp")
file(GLOB contrib_public_headers "include/yaml-cpp/contrib/[a-zA-Z]*.h")

View File

@@ -1,12 +1,12 @@
#ifndef VALUE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_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
#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/value/value.h"
#include "yaml-cpp/node/node.h"
#include <map>
#include <sstream>
@@ -15,12 +15,12 @@ namespace YAML
// std::string
template<>
struct convert<std::string> {
static Value encode(const std::string& rhs) {
return Value(rhs);
static Node encode(const std::string& rhs) {
return Node(rhs);
}
static bool decode(const Value& value, std::string& rhs) {
if(value.Type() != ValueType::Scalar)
static bool decode(const Node& value, std::string& rhs) {
if(value.Type() != NodeType::Scalar)
return false;
rhs = value.scalar();
return true;
@@ -30,14 +30,14 @@ namespace YAML
#define YAML_DEFINE_CONVERT_STREAMABLE(type)\
template<>\
struct convert<type> {\
static Value encode(const type& rhs) {\
static Node encode(const type& rhs) {\
std::stringstream stream;\
stream << rhs;\
return Value(stream.str());\
return Node(stream.str());\
}\
\
static bool decode(const Value& value, type& rhs) {\
if(value.Type() != ValueType::Scalar)\
static bool decode(const Node& value, type& rhs) {\
if(value.Type() != NodeType::Scalar)\
return false;\
std::stringstream stream(value.scalar());\
stream >> rhs;\
@@ -65,18 +65,18 @@ namespace YAML
template<typename K, typename V>
struct convert<std::map<K, V> > {
static Value encode(const std::map<K, V>& rhs) {
Value value(ValueType::Map);
static Node encode(const std::map<K, V>& rhs) {
Node value(NodeType::Map);
for(typename std::map<K, V>::const_iterator it=rhs.begin();it!=rhs.end();++it)
value[it->first] = it->second;
return value;
}
static bool decode(const Value& value, std::map<K, V>& rhs) {
static bool decode(const Node& value, std::map<K, V>& rhs) {
rhs.clear();
return false;
}
};
}
#endif // VALUE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif // NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@@ -1,13 +1,13 @@
#ifndef VALUE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_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
#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/value/detail/node.h"
#include "yaml-cpp/value/detail/node_data.h"
#include "yaml-cpp/node/detail/node.h"
#include "yaml-cpp/node/detail/node_data.h"
namespace YAML
{
@@ -17,7 +17,7 @@ namespace YAML
template<typename Key>
inline node& node_data::get(const Key& key, shared_memory_holder pMemory) const
{
if(m_type != ValueType::Map)
if(m_type != NodeType::Map)
return pMemory->create_node();
for(node_map::const_iterator it=m_map.begin();it!=m_map.end();++it) {
@@ -34,16 +34,16 @@ namespace YAML
// TODO: check if 'key' is index-like, and we're a sequence
switch(m_type) {
case ValueType::Undefined:
case ValueType::Null:
case ValueType::Scalar:
m_type = ValueType::Map;
case NodeType::Undefined:
case NodeType::Null:
case NodeType::Scalar:
m_type = NodeType::Map;
m_map.clear();
break;
case ValueType::Sequence:
case NodeType::Sequence:
convert_sequence_to_map(pMemory);
break;
case ValueType::Map:
case NodeType::Map:
break;
}
@@ -61,7 +61,7 @@ namespace YAML
template<typename Key>
inline bool node_data::remove(const Key& key, shared_memory_holder pMemory)
{
if(m_type != ValueType::Map)
if(m_type != NodeType::Map)
return false;
for(node_map::iterator it=m_map.begin();it!=m_map.end();++it) {
@@ -78,7 +78,7 @@ namespace YAML
inline bool node_data::equals(node& node, const T& rhs, shared_memory_holder pMemory)
{
T lhs;
if(convert<T>::decode(Value(node, pMemory), lhs))
if(convert<T>::decode(Node(node, pMemory), lhs))
return lhs == rhs;
return false;
}
@@ -86,11 +86,11 @@ namespace YAML
template<typename T>
inline node& node_data::convert_to_node(const T& rhs, shared_memory_holder pMemory)
{
Value value = convert<T>::encode(rhs);
Node value = convert<T>::encode(rhs);
pMemory->merge(*value.m_pMemory);
return *value.m_pNode;
}
}
}
#endif // VALUE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif // NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@@ -7,8 +7,8 @@
#include "yaml-cpp/dll.h"
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/value/detail/node_iterator.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/detail/node_iterator.h"
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/utility.hpp>

View File

@@ -5,7 +5,7 @@
#pragma once
#endif
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/node/ptr.h"
#include <set>
#include <boost/shared_ptr.hpp>

View File

@@ -1,5 +1,5 @@
#ifndef VALUE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_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
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
@@ -7,9 +7,9 @@
#include "yaml-cpp/dll.h"
#include "yaml-cpp/value/type.h"
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/value/detail/node_ref.h"
#include "yaml-cpp/node/type.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/detail/node_ref.h"
#include <boost/utility.hpp>
namespace YAML
@@ -24,14 +24,14 @@ namespace YAML
bool is(const node& rhs) const { return m_pRef == rhs.m_pRef; }
const node_ref *ref() const { return m_pRef.get(); }
ValueType::value type() const { return m_pRef->type(); }
NodeType::value type() const { return m_pRef->type(); }
const std::string& scalar() const { return m_pRef->scalar(); }
void set_ref(const node& rhs) { m_pRef = rhs.m_pRef; }
void set_data(const node& rhs) { m_pRef->set_data(*rhs.m_pRef); }
void set_type(ValueType::value type) { m_pRef->set_type(type); }
void set_type(NodeType::value type) { m_pRef->set_type(type); }
void set_null() { m_pRef->set_null(); }
void set_scalar(const std::string& scalar) { m_pRef->set_scalar(scalar); }
@@ -65,4 +65,4 @@ namespace YAML
}
}
#endif // VALUE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif // NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@@ -7,9 +7,9 @@
#include "yaml-cpp/dll.h"
#include "yaml-cpp/value/iterator.h"
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/value/type.h"
#include "yaml-cpp/node/iterator.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/type.h"
#include <boost/utility.hpp>
#include <list>
#include <utility>
@@ -24,11 +24,11 @@ namespace YAML
public:
node_data();
void set_type(ValueType::value type);
void set_type(NodeType::value type);
void set_null();
void set_scalar(const std::string& scalar);
ValueType::value type() const { return m_isDefined ? m_type : ValueType::Undefined; }
NodeType::value type() const { return m_isDefined ? m_type : NodeType::Undefined; }
const std::string& scalar() const { return m_scalar; }
// size/iterator
@@ -67,7 +67,7 @@ namespace YAML
private:
bool m_isDefined;
ValueType::value m_type;
NodeType::value m_type;
// scalar
std::string m_scalar;

View File

@@ -7,7 +7,7 @@
#include "yaml-cpp/dll.h"
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/node/ptr.h"
#include <boost/iterator/iterator_facade.hpp>
#include <boost/utility/enable_if.hpp>
#include <list>

View File

@@ -7,9 +7,9 @@
#include "yaml-cpp/dll.h"
#include "yaml-cpp/value/type.h"
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/value/detail/node_data.h"
#include "yaml-cpp/node/type.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/detail/node_data.h"
#include <boost/utility.hpp>
namespace YAML
@@ -21,12 +21,12 @@ namespace YAML
public:
node_ref() {}
ValueType::value type() const { return m_pData ? m_pData->type() : ValueType::Undefined; }
NodeType::value type() const { return m_pData ? m_pData->type() : NodeType::Undefined; }
const std::string& scalar() const { return m_pData ? m_pData->scalar() : node_data::empty_scalar; }
void set_data(const node_ref& rhs) { m_pData = rhs.m_pData; }
void set_type(ValueType::value type) { ensure_data_exists(); m_pData->set_type(type); }
void set_type(NodeType::value type) { ensure_data_exists(); m_pData->set_type(type); }
void set_null() { ensure_data_exists(); m_pData->set_null(); }
void set_scalar(const std::string& scalar) { ensure_data_exists(); m_pData->set_scalar(scalar); }

View File

@@ -1,5 +1,5 @@
#ifndef VALUE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_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
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
@@ -11,11 +11,11 @@
namespace YAML
{
class Emitter;
class Value;
class Node;
Emitter& operator << (Emitter& out, const foo& value);
std::ostream& operator << (std::ostream& out, const Value& value);
Emitter& operator << (Emitter& out, const Node& node);
std::ostream& operator << (std::ostream& out, const Node& node);
}
#endif // VALUE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif // NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@@ -1,54 +1,54 @@
#ifndef VALUE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NODE_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
#pragma once
#endif
#include "yaml-cpp/value/value.h"
#include "yaml-cpp/value/iterator.h"
#include "yaml-cpp/value/detail/memory.h"
#include "yaml-cpp/value/detail/node.h"
#include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/iterator.h"
#include "yaml-cpp/node/detail/memory.h"
#include "yaml-cpp/node/detail/node.h"
#include <string>
namespace YAML
{
inline Value::Value(): m_pMemory(new detail::memory_holder), m_pNode(&m_pMemory->create_node())
inline Node::Node(): m_pMemory(new detail::memory_holder), m_pNode(&m_pMemory->create_node())
{
}
inline Value::Value(ValueType::value type): m_pMemory(new detail::memory_holder), m_pNode(&m_pMemory->create_node())
inline Node::Node(NodeType::value type): m_pMemory(new detail::memory_holder), m_pNode(&m_pMemory->create_node())
{
m_pNode->set_type(type);
}
template<typename T>
inline Value::Value(const T& rhs): m_pMemory(new detail::memory_holder), m_pNode(&m_pMemory->create_node())
inline Node::Node(const T& rhs): m_pMemory(new detail::memory_holder), m_pNode(&m_pMemory->create_node())
{
Assign(rhs);
}
inline Value::Value(const Value& rhs): m_pMemory(rhs.m_pMemory), m_pNode(rhs.m_pNode)
inline Node::Node(const Node& rhs): m_pMemory(rhs.m_pMemory), m_pNode(rhs.m_pNode)
{
}
inline Value::Value(detail::node& node, detail::shared_memory_holder pMemory): m_pMemory(pMemory), m_pNode(&node)
inline Node::Node(detail::node& node, detail::shared_memory_holder pMemory): m_pMemory(pMemory), m_pNode(&node)
{
}
inline Value::~Value()
inline Node::~Node()
{
}
inline ValueType::value Value::Type() const
inline NodeType::value Node::Type() const
{
return m_pNode->type();
}
// access
template<typename T>
inline const T Value::as() const
inline const T Node::as() const
{
T t;
if(convert<T>::decode(*this, t))
@@ -57,54 +57,54 @@ namespace YAML
}
template<>
inline const std::string Value::as() const
inline const std::string Node::as() const
{
if(Type() != ValueType::Scalar)
if(Type() != NodeType::Scalar)
throw std::runtime_error("Unable to convert to string, not a scalar");
return scalar();
}
inline const std::string& Value::scalar() const
inline const std::string& Node::scalar() const
{
return m_pNode->scalar();
}
// assignment
inline bool Value::is(const Value& rhs) const
inline bool Node::is(const Node& rhs) const
{
return m_pNode->is(*rhs.m_pNode);
}
template<typename T>
inline Value& Value::operator=(const T& rhs)
inline Node& Node::operator=(const T& rhs)
{
Assign(rhs);
return *this;
}
template<typename T>
inline void Value::Assign(const T& rhs)
inline void Node::Assign(const T& rhs)
{
AssignData(convert<T>::encode(rhs));
}
template<>
inline void Value::Assign(const std::string& rhs)
inline void Node::Assign(const std::string& rhs)
{
m_pNode->set_scalar(rhs);
}
inline void Value::Assign(const char *rhs)
inline void Node::Assign(const char *rhs)
{
m_pNode->set_scalar(rhs);
}
inline void Value::Assign(char *rhs)
inline void Node::Assign(char *rhs)
{
m_pNode->set_scalar(rhs);
}
inline Value& Value::operator=(const Value& rhs)
inline Node& Node::operator=(const Node& rhs)
{
if(is(rhs))
return *this;
@@ -112,13 +112,13 @@ namespace YAML
return *this;
}
inline void Value::AssignData(const Value& rhs)
inline void Node::AssignData(const Node& rhs)
{
m_pNode->set_data(*rhs.m_pNode);
m_pMemory->merge(*rhs.m_pMemory);
}
inline void Value::AssignNode(const Value& rhs)
inline void Node::AssignNode(const Node& rhs)
{
m_pNode->set_ref(*rhs.m_pNode);
m_pMemory->merge(*rhs.m_pMemory);
@@ -126,39 +126,39 @@ namespace YAML
}
// size/iterator
inline std::size_t Value::size() const
inline std::size_t Node::size() const
{
return m_pNode->size();
}
inline const_iterator Value::begin() const
inline const_iterator Node::begin() const
{
return const_iterator(m_pNode->begin(), m_pMemory);
}
inline iterator Value::begin()
inline iterator Node::begin()
{
return iterator(m_pNode->begin(), m_pMemory);
}
inline const_iterator Value::end() const
inline const_iterator Node::end() const
{
return const_iterator(m_pNode->end(), m_pMemory);
}
inline iterator Value::end()
inline iterator Node::end()
{
return iterator(m_pNode->end(), m_pMemory);
}
// sequence
template<typename T>
inline void Value::append(const T& rhs)
inline void Node::append(const T& rhs)
{
append(Value(rhs));
append(Node(rhs));
}
inline void Value::append(const Value& rhs)
inline void Node::append(const Node& rhs)
{
m_pNode->append(*rhs.m_pNode, m_pMemory);
m_pMemory->merge(*rhs.m_pMemory);
@@ -166,87 +166,87 @@ namespace YAML
// indexing
template<typename Key>
inline const Value Value::operator[](const Key& key) const
inline const Node Node::operator[](const Key& key) const
{
detail::node& value = static_cast<const detail::node&>(*m_pNode).get(key, m_pMemory);
return Value(value, m_pMemory);
return Node(value, m_pMemory);
}
template<typename Key>
inline Value Value::operator[](const Key& key)
inline Node Node::operator[](const Key& key)
{
detail::node& value = m_pNode->get(key, m_pMemory);
return Value(value, m_pMemory);
return Node(value, m_pMemory);
}
template<typename Key>
inline bool Value::remove(const Key& key)
inline bool Node::remove(const Key& key)
{
return m_pNode->remove(key, m_pMemory);
}
inline const Value Value::operator[](const Value& key) const
inline const Node Node::operator[](const Node& key) const
{
detail::node& value = static_cast<const detail::node&>(*m_pNode).get(*key.m_pNode, m_pMemory);
return Value(value, m_pMemory);
return Node(value, m_pMemory);
}
inline Value Value::operator[](const Value& key)
inline Node Node::operator[](const Node& key)
{
detail::node& value = m_pNode->get(*key.m_pNode, m_pMemory);
return Value(value, m_pMemory);
return Node(value, m_pMemory);
}
inline bool Value::remove(const Value& key)
inline bool Node::remove(const Node& key)
{
return m_pNode->remove(*key.m_pNode, m_pMemory);
}
inline const Value Value::operator[](const char *key) const
inline const Node Node::operator[](const char *key) const
{
return operator[](std::string(key));
}
inline Value Value::operator[](const char *key)
inline Node Node::operator[](const char *key)
{
return operator[](std::string(key));
}
inline bool Value::remove(const char *key)
inline bool Node::remove(const char *key)
{
return remove(std::string(key));
}
inline const Value Value::operator[](char *key) const
inline const Node Node::operator[](char *key) const
{
return operator[](static_cast<const char *>(key));
}
inline Value Value::operator[](char *key)
inline Node Node::operator[](char *key)
{
return operator[](static_cast<const char *>(key));
}
inline bool Value::remove(char *key)
inline bool Node::remove(char *key)
{
return remove(static_cast<const char *>(key));
}
// free functions
inline int compare(const Value& lhs, const Value& rhs)
inline int compare(const Node& lhs, const Node& rhs)
{
return 0;
}
inline bool operator<(const Value& lhs, const Value& rhs)
inline bool operator<(const Node& lhs, const Node& rhs)
{
return false;
}
inline bool is(const Value& lhs, const Value& rhs)
inline bool is(const Node& lhs, const Node& rhs)
{
return lhs.is(rhs);
}
}
#endif // VALUE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif // NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@@ -7,9 +7,9 @@
#include "yaml-cpp/dll.h"
#include "yaml-cpp/value/value.h"
#include "yaml-cpp/value/detail/iterator_fwd.h"
#include "yaml-cpp/value/detail/iterator.h"
#include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/detail/iterator_fwd.h"
#include "yaml-cpp/node/detail/iterator.h"
#include <list>
#include <utility>
#include <vector>
@@ -17,10 +17,10 @@
namespace YAML
{
namespace detail {
struct iterator_value: public Value, std::pair<Value, Value> {
struct iterator_value: public Node, std::pair<Node, Node> {
iterator_value() {}
explicit iterator_value(const Value& rhs): Value(rhs) {}
explicit iterator_value(const Value& key, const Value& value): std::pair<Value, Value>(key, value) {}
explicit iterator_value(const Node& rhs): Node(rhs) {}
explicit iterator_value(const Node& key, const Node& value): std::pair<Node, Node>(key, value) {}
};
}
}

View File

@@ -0,0 +1,96 @@
#ifndef 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
#pragma once
#endif
#include "yaml-cpp/dll.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/type.h"
#include "yaml-cpp/node/detail/iterator_fwd.h"
#include <stdexcept>
namespace YAML
{
class Node
{
public:
friend class NodeBuilder;
friend class NodeEvents;
friend class detail::node_data;
template<typename, typename, typename> friend class detail::iterator_base;
Node();
explicit Node(NodeType::value type);
template<typename T> explicit Node(const T& rhs);
Node(const Node& rhs);
~Node();
NodeType::value Type() const;
// access
template<typename T> const T as() const;
const std::string& scalar() const;
// assignment
bool is(const Node& rhs) const;
template<typename T> Node& operator=(const T& rhs);
Node& operator=(const Node& rhs);
// size/iterator
std::size_t size() const;
const_iterator begin() const;
iterator begin();
const_iterator end() const;
iterator end();
// sequence
template<typename T> void append(const T& rhs);
void append(const Node& rhs);
// indexing
template<typename Key> const Node operator[](const Key& key) const;
template<typename Key> Node operator[](const Key& key);
template<typename Key> bool remove(const Key& key);
const Node operator[](const Node& key) const;
Node operator[](const Node& key);
bool remove(const Node& key);
const Node operator[](const char *key) const;
Node operator[](const char *key);
bool remove(const char *key);
const Node operator[](char *key) const;
Node operator[](char *key);
bool remove(char *key);
private:
explicit Node(detail::node& node, detail::shared_memory_holder pMemory);
template<typename T> void Assign(const T& rhs);
void Assign(const char *rhs);
void Assign(char *rhs);
void AssignData(const Node& rhs);
void AssignNode(const Node& rhs);
private:
detail::shared_memory_holder m_pMemory;
detail::node *m_pNode;
};
int compare(const Node& lhs, const Node& rhs);
bool operator<(const Node& lhs, const Node& rhs);
bool is(const Node& lhs, const Node& rhs);
template<typename T>
struct convert;
}
#endif // NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@@ -10,11 +10,11 @@
namespace YAML
{
class Value;
class Node;
Value Parse(const std::string& input);
Value Parse(const char *input);
Value Parse(std::istream& input);
Node Parse(const std::string& input);
Node Parse(const char *input);
Node Parse(std::istream& input);
}
#endif // VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@@ -8,7 +8,7 @@
namespace YAML
{
struct ValueType { enum value { Undefined, Null, Scalar, Sequence, Map }; };
struct NodeType { enum value { Undefined, Null, Scalar, Sequence, Map }; };
}
#endif // VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@@ -1,96 +0,0 @@
#ifndef VALUE_VALUE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_VALUE_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/value/ptr.h"
#include "yaml-cpp/value/type.h"
#include "yaml-cpp/value/detail/iterator_fwd.h"
#include <stdexcept>
namespace YAML
{
class Value
{
public:
friend class ValueBuilder;
friend class ValueEvents;
friend class detail::node_data;
template<typename, typename, typename> friend class detail::iterator_base;
Value();
explicit Value(ValueType::value type);
template<typename T> explicit Value(const T& rhs);
Value(const Value& rhs);
~Value();
ValueType::value Type() const;
// access
template<typename T> const T as() const;
const std::string& scalar() const;
// assignment
bool is(const Value& rhs) const;
template<typename T> Value& operator=(const T& rhs);
Value& operator=(const Value& rhs);
// size/iterator
std::size_t size() const;
const_iterator begin() const;
iterator begin();
const_iterator end() const;
iterator end();
// sequence
template<typename T> void append(const T& rhs);
void append(const Value& rhs);
// indexing
template<typename Key> const Value operator[](const Key& key) const;
template<typename Key> Value operator[](const Key& key);
template<typename Key> bool remove(const Key& key);
const Value operator[](const Value& key) const;
Value operator[](const Value& key);
bool remove(const Value& key);
const Value operator[](const char *key) const;
Value operator[](const char *key);
bool remove(const char *key);
const Value operator[](char *key) const;
Value operator[](char *key);
bool remove(char *key);
private:
explicit Value(detail::node& node, detail::shared_memory_holder pMemory);
template<typename T> void Assign(const T& rhs);
void Assign(const char *rhs);
void Assign(char *rhs);
void AssignData(const Value& rhs);
void AssignNode(const Value& rhs);
private:
detail::shared_memory_holder m_pMemory;
detail::node *m_pNode;
};
int compare(const Value& lhs, const Value& rhs);
bool operator<(const Value& lhs, const Value& rhs);
bool is(const Value& lhs, const Value& rhs);
template<typename T>
struct convert;
}
#endif // VALUE_VALUE_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@@ -32,7 +32,10 @@ namespace YAML
void Load(std::istream& in);
bool HandleNextDocument(EventHandler& eventHandler);
#if YAML_CPP_OLD_API
bool GetNextDocument(Node& document);
#endif
void PrintTokens(std::ostream& out);
private:

View File

@@ -1,17 +0,0 @@
#ifndef VALUE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_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/value/value.h"
#include "yaml-cpp/value/impl.h"
#include "yaml-cpp/value/convert.h"
#include "yaml-cpp/value/iterator.h"
#include "yaml-cpp/value/detail/impl.h"
#include "yaml-cpp/value/parse.h"
#include "yaml-cpp/value/emit.h"
#endif // VALUE_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@@ -7,11 +7,26 @@
#include "yaml-cpp/parser.h"
#include "yaml-cpp/node.h"
#include "yaml-cpp/stlnode.h"
#include "yaml-cpp/iterator.h"
#include "yaml-cpp/emitter.h"
#include "yaml-cpp/stlemitter.h"
#include "yaml-cpp/exceptions.h"
#ifdef YAML_CPP_OLD_API
#include "yaml-cpp/old-api/node.h"
#include "yaml-cpp/old-api/stlnode.h"
#include "yaml-cpp/old-api/iterator.h"
#else
#include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/impl.h"
#include "yaml-cpp/node/convert.h"
#include "yaml-cpp/node/iterator.h"
#include "yaml-cpp/node/detail/impl.h"
#include "yaml-cpp/node/parse.h"
#include "yaml-cpp/node/emit.h"
#endif // YAML_CPP_OLD_API
#endif // YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@@ -1,4 +1,4 @@
#include "yaml-cpp/value/convert.h"
#include "yaml-cpp/node/convert.h"
namespace YAML
{

View File

@@ -1,5 +1,5 @@
#include "yaml-cpp/value/detail/memory.h"
#include "yaml-cpp/value/detail/node.h"
#include "yaml-cpp/node/detail/memory.h"
#include "yaml-cpp/node/detail/node.h"
namespace YAML
{

View File

@@ -1,6 +1,6 @@
#include "yaml-cpp/value/detail/node_data.h"
#include "yaml-cpp/value/detail/memory.h"
#include "yaml-cpp/value/detail/node.h"
#include "yaml-cpp/node/detail/node_data.h"
#include "yaml-cpp/node/detail/memory.h"
#include "yaml-cpp/node/detail/node.h"
#include <sstream>
#include <stdexcept>
@@ -10,13 +10,13 @@ namespace YAML
{
std::string node_data::empty_scalar;
node_data::node_data(): m_isDefined(false), m_type(ValueType::Null)
node_data::node_data(): m_isDefined(false), m_type(NodeType::Null)
{
}
void node_data::set_type(ValueType::value type)
void node_data::set_type(NodeType::value type)
{
if(type == ValueType::Undefined) {
if(type == NodeType::Undefined) {
m_type = type;
m_isDefined = false;
return;
@@ -30,18 +30,18 @@ namespace YAML
m_type = type;
switch(m_type) {
case ValueType::Null:
case NodeType::Null:
break;
case ValueType::Scalar:
case NodeType::Scalar:
m_scalar.clear();
break;
case ValueType::Sequence:
case NodeType::Sequence:
m_sequence.clear();
break;
case ValueType::Map:
case NodeType::Map:
m_map.clear();
break;
case ValueType::Undefined:
case NodeType::Undefined:
assert(false);
break;
}
@@ -50,13 +50,13 @@ namespace YAML
void node_data::set_null()
{
m_isDefined = true;
m_type = ValueType::Null;
m_type = NodeType::Null;
}
void node_data::set_scalar(const std::string& scalar)
{
m_isDefined = true;
m_type = ValueType::Scalar;
m_type = NodeType::Scalar;
m_scalar = scalar;
}
@@ -69,8 +69,8 @@ namespace YAML
const_node_iterator node_data::begin() const
{
switch(m_type) {
case ValueType::Sequence: return const_node_iterator(m_sequence.begin());
case ValueType::Map: return const_node_iterator(m_map.begin());
case NodeType::Sequence: return const_node_iterator(m_sequence.begin());
case NodeType::Map: return const_node_iterator(m_map.begin());
default: return const_node_iterator();
}
}
@@ -78,8 +78,8 @@ namespace YAML
node_iterator node_data::begin()
{
switch(m_type) {
case ValueType::Sequence: return node_iterator(m_sequence.begin());
case ValueType::Map: return node_iterator(m_map.begin());
case NodeType::Sequence: return node_iterator(m_sequence.begin());
case NodeType::Map: return node_iterator(m_map.begin());
default: return node_iterator();
}
}
@@ -87,8 +87,8 @@ namespace YAML
const_node_iterator node_data::end() const
{
switch(m_type) {
case ValueType::Sequence: return const_node_iterator(m_sequence.end());
case ValueType::Map: return const_node_iterator(m_map.end());
case NodeType::Sequence: return const_node_iterator(m_sequence.end());
case NodeType::Map: return const_node_iterator(m_map.end());
default: return const_node_iterator();
}
}
@@ -96,8 +96,8 @@ namespace YAML
node_iterator node_data::end()
{
switch(m_type) {
case ValueType::Sequence: return node_iterator(m_sequence.end());
case ValueType::Map: return node_iterator(m_map.end());
case NodeType::Sequence: return node_iterator(m_sequence.end());
case NodeType::Map: return node_iterator(m_map.end());
default: return node_iterator();
}
}
@@ -105,7 +105,7 @@ namespace YAML
// sequence
void node_data::append(node& node, shared_memory_holder /* pMemory */)
{
if(m_type != ValueType::Sequence)
if(m_type != NodeType::Sequence)
throw std::runtime_error("Can't append to a non-sequence node");
m_sequence.push_back(&node);
@@ -113,7 +113,7 @@ namespace YAML
void node_data::insert(node& key, node& value, shared_memory_holder /* pMemory */)
{
if(m_type != ValueType::Map)
if(m_type != NodeType::Map)
throw std::runtime_error("Can't insert into a non-map node");
m_map.push_back(kv_pair(&key, &value));
@@ -122,7 +122,7 @@ namespace YAML
// indexing
node& node_data::get(node& key, shared_memory_holder pMemory) const
{
if(m_type != ValueType::Map)
if(m_type != NodeType::Map)
return pMemory->create_node();
for(node_map::const_iterator it=m_map.begin();it!=m_map.end();++it) {
@@ -136,16 +136,16 @@ namespace YAML
node& node_data::get(node& key, shared_memory_holder pMemory)
{
switch(m_type) {
case ValueType::Undefined:
case ValueType::Null:
case ValueType::Scalar:
m_type = ValueType::Map;
case NodeType::Undefined:
case NodeType::Null:
case NodeType::Scalar:
m_type = NodeType::Map;
m_map.clear();
break;
case ValueType::Sequence:
case NodeType::Sequence:
convert_sequence_to_map(pMemory);
break;
case ValueType::Map:
case NodeType::Map:
break;
}
@@ -161,7 +161,7 @@ namespace YAML
bool node_data::remove(node& key, shared_memory_holder /* pMemory */)
{
if(m_type != ValueType::Map)
if(m_type != NodeType::Map)
return false;
for(node_map::iterator it=m_map.begin();it!=m_map.end();++it) {
@@ -176,7 +176,7 @@ namespace YAML
void node_data::convert_sequence_to_map(shared_memory_holder pMemory)
{
assert(m_type == ValueType::Sequence);
assert(m_type == NodeType::Sequence);
m_map.clear();
for(std::size_t i=0;i<m_sequence.size();i++) {
@@ -189,7 +189,7 @@ namespace YAML
}
m_sequence.clear();
m_type = ValueType::Map;
m_type = NodeType::Map;
}
}
}

View File

@@ -1,22 +1,22 @@
#include "yaml-cpp/value/emit.h"
#include "yaml-cpp/node/emit.h"
#include "yaml-cpp/emitfromevents.h"
#include "yaml-cpp/emitter.h"
#include "valueevents.h"
#include "nodeevents.h"
namespace YAML
{
Emitter& operator << (Emitter& out, const Value& value)
Emitter& operator << (Emitter& out, const Node& node)
{
EmitFromEvents emitFromEvents(out);
ValueEvents events(value);
NodeEvents events(node);
events.Emit(emitFromEvents);
return out;
}
std::ostream& operator << (std::ostream& out, const Value& value)
std::ostream& operator << (std::ostream& out, const Node& node)
{
Emitter emitter;
emitter << value;
emitter << node;
out << emitter.c_str();
return out;
}

View File

@@ -1,84 +1,85 @@
#include "valuebuilder.h"
#include "nodebuilder.h"
#include "yaml-cpp/mark.h"
#include "yaml-cpp/value.h"
#include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/impl.h"
#include <cassert>
namespace YAML
{
ValueBuilder::ValueBuilder(): m_pMemory(new detail::memory_holder), m_pRoot(0), m_mapDepth(0)
NodeBuilder::NodeBuilder(): m_pMemory(new detail::memory_holder), m_pRoot(0), m_mapDepth(0)
{
m_anchors.push_back(0); // since the anchors start at 1
}
ValueBuilder::~ValueBuilder()
NodeBuilder::~NodeBuilder()
{
}
Value ValueBuilder::Root()
Node NodeBuilder::Root()
{
if(!m_pRoot)
return Value();
return Node();
return Value(*m_pRoot, m_pMemory);
return Node(*m_pRoot, m_pMemory);
}
void ValueBuilder::OnDocumentStart(const Mark&)
void NodeBuilder::OnDocumentStart(const Mark&)
{
}
void ValueBuilder::OnDocumentEnd()
void NodeBuilder::OnDocumentEnd()
{
}
void ValueBuilder::OnNull(const Mark& mark, anchor_t anchor)
void NodeBuilder::OnNull(const Mark& mark, anchor_t anchor)
{
detail::node& node = Push(anchor);
node.set_null();
Pop();
}
void ValueBuilder::OnAlias(const Mark& /*mark*/, anchor_t anchor)
void NodeBuilder::OnAlias(const Mark& /*mark*/, anchor_t anchor)
{
detail::node& node = *m_anchors[anchor];
m_stack.push_back(&node);
Pop();
}
void ValueBuilder::OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value)
void NodeBuilder::OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value)
{
detail::node& node = Push(anchor);
node.set_scalar(value);
Pop();
}
void ValueBuilder::OnSequenceStart(const Mark& mark, const std::string& tag, anchor_t anchor)
void NodeBuilder::OnSequenceStart(const Mark& mark, const std::string& tag, anchor_t anchor)
{
detail::node& node = Push(anchor);
node.set_type(ValueType::Sequence);
node.set_type(NodeType::Sequence);
}
void ValueBuilder::OnSequenceEnd()
void NodeBuilder::OnSequenceEnd()
{
Pop();
}
void ValueBuilder::OnMapStart(const Mark& mark, const std::string& tag, anchor_t anchor)
void NodeBuilder::OnMapStart(const Mark& mark, const std::string& tag, anchor_t anchor)
{
detail::node& node = Push(anchor);
node.set_type(ValueType::Map);
node.set_type(NodeType::Map);
m_mapDepth++;
}
void ValueBuilder::OnMapEnd()
void NodeBuilder::OnMapEnd()
{
assert(m_mapDepth > 0);
m_mapDepth--;
Pop();
}
detail::node& ValueBuilder::Push(anchor_t anchor)
detail::node& NodeBuilder::Push(anchor_t anchor)
{
const bool needsKey = (!m_stack.empty() && m_stack.back()->type() == ValueType::Map && m_keys.size() < m_mapDepth);
const bool needsKey = (!m_stack.empty() && m_stack.back()->type() == NodeType::Map && m_keys.size() < m_mapDepth);
detail::node& node = m_pMemory->create_node();
m_stack.push_back(&node);
@@ -90,7 +91,7 @@ namespace YAML
return node;
}
void ValueBuilder::Pop()
void NodeBuilder::Pop()
{
assert(!m_stack.empty());
if(m_stack.size() == 1) {
@@ -104,9 +105,9 @@ namespace YAML
detail::node& collection = *m_stack.back();
if(collection.type() == ValueType::Sequence) {
if(collection.type() == NodeType::Sequence) {
collection.append(node, m_pMemory);
} else if(collection.type() == ValueType::Map) {
} else if(collection.type() == NodeType::Map) {
detail::node& key = *m_keys.back();
if(&key != &node) {
m_keys.pop_back();
@@ -118,7 +119,7 @@ namespace YAML
}
}
void ValueBuilder::RegisterAnchor(anchor_t anchor, detail::node& node)
void NodeBuilder::RegisterAnchor(anchor_t anchor, detail::node& node)
{
if(anchor) {
assert(anchor == m_anchors.size());

View File

@@ -1,25 +1,25 @@
#ifndef VALUE_VALUEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_VALUEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef NODE_NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NODE_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 "yaml-cpp/value/ptr.h"
#include "yaml-cpp/node/ptr.h"
#include <vector>
namespace YAML
{
class Value;
class Node;
class ValueBuilder: public EventHandler
class NodeBuilder: public EventHandler
{
public:
ValueBuilder();
virtual ~ValueBuilder();
NodeBuilder();
virtual ~NodeBuilder();
Value Root();
Node Root();
virtual void OnDocumentStart(const Mark& mark);
virtual void OnDocumentEnd();
@@ -52,5 +52,5 @@ namespace YAML
};
}
#endif // VALUE_VALUEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif // NODE_NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@@ -1,16 +1,17 @@
#include "valueevents.h"
#include "yaml-cpp/value.h"
#include "nodeevents.h"
#include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/impl.h"
#include "yaml-cpp/eventhandler.h"
#include "yaml-cpp/mark.h"
namespace YAML
{
void ValueEvents::AliasManager::RegisterReference(const detail::node& node)
void NodeEvents::AliasManager::RegisterReference(const detail::node& node)
{
m_anchorByIdentity.insert(std::make_pair(node.ref(), _CreateNewAnchor()));
}
anchor_t ValueEvents::AliasManager::LookupAnchor(const detail::node& node) const
anchor_t NodeEvents::AliasManager::LookupAnchor(const detail::node& node) const
{
AnchorByIdentity::const_iterator it = m_anchorByIdentity.find(node.ref());
if(it == m_anchorByIdentity.end())
@@ -18,22 +19,22 @@ namespace YAML
return it->second;
}
ValueEvents::ValueEvents(const Value& value): m_pMemory(value.m_pMemory), m_root(*value.m_pNode)
NodeEvents::NodeEvents(const Node& node): m_pMemory(node.m_pMemory), m_root(*node.m_pNode)
{
Setup(m_root);
}
void ValueEvents::Setup(const detail::node& node)
void NodeEvents::Setup(const detail::node& node)
{
int& refCount = m_refCount[node.ref()];
refCount++;
if(refCount > 1)
return;
if(node.type() == ValueType::Sequence) {
if(node.type() == NodeType::Sequence) {
for(detail::const_node_iterator it=node.begin();it!=node.end();++it)
Setup(**it);
} else if(node.type() == ValueType::Map) {
} else if(node.type() == NodeType::Map) {
for(detail::const_node_iterator it=node.begin();it!=node.end();++it) {
Setup(*it->first);
Setup(*it->second);
@@ -41,7 +42,7 @@ namespace YAML
}
}
void ValueEvents::Emit(EventHandler& handler)
void NodeEvents::Emit(EventHandler& handler)
{
AliasManager am;
@@ -50,7 +51,7 @@ namespace YAML
handler.OnDocumentEnd();
}
void ValueEvents::Emit(const detail::node& node, EventHandler& handler, AliasManager& am) const
void NodeEvents::Emit(const detail::node& node, EventHandler& handler, AliasManager& am) const
{
anchor_t anchor = NullAnchor;
if(IsAliased(node)) {
@@ -65,21 +66,21 @@ namespace YAML
}
switch(node.type()) {
case ValueType::Undefined:
case NodeType::Undefined:
break;
case ValueType::Null:
case NodeType::Null:
handler.OnNull(Mark(), anchor);
break;
case ValueType::Scalar:
case NodeType::Scalar:
handler.OnScalar(Mark(), "", anchor, node.scalar());
break;
case ValueType::Sequence:
case NodeType::Sequence:
handler.OnSequenceStart(Mark(), "", anchor);
for(detail::const_node_iterator it=node.begin();it!=node.end();++it)
Emit(**it, handler, am);
handler.OnSequenceEnd();
break;
case ValueType::Map:
case NodeType::Map:
handler.OnMapStart(Mark(), "", anchor);
for(detail::const_node_iterator it=node.begin();it!=node.end();++it) {
Emit(*it->first, handler, am);
@@ -90,7 +91,7 @@ namespace YAML
}
}
bool ValueEvents::IsAliased(const detail::node& node) const
bool NodeEvents::IsAliased(const detail::node& node) const
{
RefCount::const_iterator it = m_refCount.find(node.ref());
return it != m_refCount.end() && it->second > 1;

View File

@@ -1,24 +1,24 @@
#ifndef VALUE_VALUEEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_VALUEEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef NODE_NODEEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NODE_NODEEVENTS_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/anchor.h"
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/node/ptr.h"
#include <map>
#include <vector>
namespace YAML
{
class Value;
class EventHandler;
class Node;
class ValueEvents
class NodeEvents
{
public:
explicit ValueEvents(const Value& value);
explicit NodeEvents(const Node& node);
void Emit(EventHandler& handler);
@@ -53,5 +53,5 @@ namespace YAML
};
}
#endif // VALUE_VALUEEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif // NODE_NODEEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@@ -1,28 +1,28 @@
#include "yaml-cpp/value/parse.h"
#include "yaml-cpp/value/value.h"
#include "yaml-cpp/value/impl.h"
#include "yaml-cpp/node/parse.h"
#include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/impl.h"
#include "yaml-cpp/parser.h"
#include "valuebuilder.h"
#include "nodebuilder.h"
#include <sstream>
namespace YAML
{
Value Parse(const std::string& input) {
Node Parse(const std::string& input) {
std::stringstream stream(input);
return Parse(stream);
}
Value Parse(const char *input) {
Node Parse(const char *input) {
std::stringstream stream(input);
return Parse(stream);
}
Value Parse(std::istream& input) {
Node Parse(std::istream& input) {
Parser parser(input);
ValueBuilder builder;
NodeBuilder builder;
if(!parser.HandleNextDocument(builder))
return Value();
return Node();
return builder.Root();
}

View File

@@ -3,7 +3,6 @@
#include "yaml-cpp/eventhandler.h"
#include "yaml-cpp/exceptions.h"
#include "yaml-cpp/node.h"
#include "nodebuilder.h"
#include "scanner.h"
#include "singledocparser.h"
#include "tag.h"
@@ -11,6 +10,10 @@
#include <sstream>
#include <cstdio>
#if YAML_CPP_OLD_API
#include "old-api/nodebuilder.h"
#endif
namespace YAML
{
Parser::Parser()
@@ -55,6 +58,7 @@ namespace YAML
return true;
}
#if YAML_CPP_OLD_API
// GetNextDocument
// . Reads the next document in the queue (of tokens).
// . Throws a ParserException on error.
@@ -63,6 +67,7 @@ namespace YAML
NodeBuilder builder(document);
return HandleNextDocument(builder);
}
#endif
// ParseDirectives
// . Reads any directives that are next in the queue.

View File

@@ -1,10 +1,10 @@
#include "yaml-cpp/value.h"
#include "yaml-cpp/yaml.h"
#include <map>
int main()
{
YAML::Value value = YAML::Parse("{foo: bar, monkey: value}");
std::cout << value << "\n";
YAML::Node node = YAML::Parse("{foo: bar, monkey: value}");
std::cout << node << "\n";
return 0;
}