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:
Jesse Beder
2011-09-10 17:57:23 -05:00
parent ac81d7c883
commit 0d1b5224c8
30 changed files with 387 additions and 364 deletions

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