mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Started implementing node_data
This commit is contained in:
@@ -55,7 +55,11 @@ 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")
|
||||
file(GLOB sources
|
||||
"src/[a-zA-Z]*.cpp"
|
||||
"src/value/[a-zA-Z]*.cpp"
|
||||
"src/value/detail/[a-zA-Z]*.cpp"
|
||||
)
|
||||
file(GLOB public_headers
|
||||
"include/yaml-cpp/[a-zA-Z]*.h"
|
||||
"include/yaml-cpp/value/[a-zA-Z]*.h"
|
||||
|
@@ -7,6 +7,7 @@
|
||||
|
||||
|
||||
#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"
|
||||
|
||||
@@ -19,6 +20,7 @@ namespace YAML
|
||||
public:
|
||||
node();
|
||||
|
||||
ValueType::value type() const;
|
||||
void assign_data(const node& rhs);
|
||||
void set_scalar(const std::string& data);
|
||||
|
||||
@@ -30,6 +32,11 @@ namespace YAML
|
||||
{
|
||||
}
|
||||
|
||||
inline ValueType::value node::type() const
|
||||
{
|
||||
return m_pData ? m_pData->type() : ValueType::Null;
|
||||
}
|
||||
|
||||
inline void node::assign_data(const node& rhs)
|
||||
{
|
||||
m_pData = rhs.m_pData;
|
||||
|
@@ -7,7 +7,10 @@
|
||||
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/value/type.h"
|
||||
#include "yaml-cpp/value/ptr.h"
|
||||
#include <pair>
|
||||
#include <vector>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
@@ -16,7 +19,25 @@ namespace YAML
|
||||
class node_data
|
||||
{
|
||||
public:
|
||||
explicit node_data(const std::string& data) {}
|
||||
explicit node_data(const std::string& scalar);
|
||||
|
||||
ValueType::value type() const { return m_type; }
|
||||
const std::string scalar() const { return m_data; }
|
||||
|
||||
private:
|
||||
ValueType::value m_type;
|
||||
|
||||
// scalar
|
||||
std::string m_scalar;
|
||||
|
||||
// sequence
|
||||
typedef std::vector<shared_node> node_seq;
|
||||
node_seq m_sequence;
|
||||
|
||||
// map
|
||||
typedef std::pair<shared_node, shared_node> kv_pair;
|
||||
typedef std::vector<kv_pair> node_map;
|
||||
node_map m_map;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@ namespace YAML
|
||||
{
|
||||
inline Value::Value(): m_pMemory(new detail::memory_holder)
|
||||
{
|
||||
EnsureNodeExists();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -30,6 +31,11 @@ namespace YAML
|
||||
{
|
||||
}
|
||||
|
||||
inline ValueType::value Value::Type() const
|
||||
{
|
||||
return m_pNode ? m_pNode->type() : ValueType::Undefined;
|
||||
}
|
||||
|
||||
// access
|
||||
template<typename T>
|
||||
inline const T Value::as() const
|
||||
|
14
include/yaml-cpp/value/type.h
Normal file
14
include/yaml-cpp/value/type.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef 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
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
struct ValueType { enum value { Undefined, Null, Scalar, Sequence, Map }; };
|
||||
}
|
||||
|
||||
#endif // VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
@@ -7,14 +7,13 @@
|
||||
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/value/ptr.h"
|
||||
#include "yaml-cpp/value/iterator.h"
|
||||
#include "yaml-cpp/value/ptr.h"
|
||||
#include "yaml-cpp/value/type.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
struct ValueType { enum value { Undefined, Null, Scalar, Sequence, Map }; };
|
||||
|
||||
class Value
|
||||
{
|
||||
public:
|
||||
|
11
src/value/detail/node_data.cpp
Normal file
11
src/value/detail/node_data.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "yaml-cpp/value/detail/node_data.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
node_data::node_data(const std::string& scalar): m_type(ValueType::Scalar), m_scalar(scalar)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,7 +3,7 @@
|
||||
int main()
|
||||
{
|
||||
YAML::Value value;
|
||||
value = "Hello";
|
||||
value["key"] = "value";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user