From 74ffe6a61b4c0d6749cfa7148ae7df0c7054fb61 Mon Sep 17 00:00:00 2001 From: beder Date: Wed, 7 Sep 2011 00:12:24 -0500 Subject: [PATCH] Value stuff compiles/links with lots of placeholder functions --- include/yaml-cpp/value/detail/memory.h | 1 + include/yaml-cpp/value/detail/node.h | 1 + include/yaml-cpp/value/detail/node_data.h | 24 ++++++++++ include/yaml-cpp/value/impl.h | 53 +++++++++++++++++++++-- include/yaml-cpp/value/iterator.h | 17 ++++++++ include/yaml-cpp/value/value.h | 12 +++-- util/CMakeLists.txt | 3 ++ util/value.cpp | 8 ++++ 8 files changed, 112 insertions(+), 7 deletions(-) create mode 100644 include/yaml-cpp/value/detail/node_data.h create mode 100644 include/yaml-cpp/value/iterator.h create mode 100644 util/value.cpp diff --git a/include/yaml-cpp/value/detail/memory.h b/include/yaml-cpp/value/detail/memory.h index 2d35b08..2a7ba14 100644 --- a/include/yaml-cpp/value/detail/memory.h +++ b/include/yaml-cpp/value/detail/memory.h @@ -6,6 +6,7 @@ #endif #include "yaml-cpp/value/ptr.h" +#include "yaml-cpp/value/detail/node.h" #include #include diff --git a/include/yaml-cpp/value/detail/node.h b/include/yaml-cpp/value/detail/node.h index 49c4422..358e435 100644 --- a/include/yaml-cpp/value/detail/node.h +++ b/include/yaml-cpp/value/detail/node.h @@ -8,6 +8,7 @@ #include "yaml-cpp/dll.h" #include "yaml-cpp/value/ptr.h" +#include "yaml-cpp/value/detail/node_data.h" namespace YAML { diff --git a/include/yaml-cpp/value/detail/node_data.h b/include/yaml-cpp/value/detail/node_data.h new file mode 100644 index 0000000..9cf7e28 --- /dev/null +++ b/include/yaml-cpp/value/detail/node_data.h @@ -0,0 +1,24 @@ +#ifndef 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 +#pragma once +#endif + + +#include "yaml-cpp/dll.h" +#include "yaml-cpp/value/ptr.h" + +namespace YAML +{ + namespace detail + { + class node_data + { + public: + explicit node_data(const std::string& data); + }; + } +} + +#endif // VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/include/yaml-cpp/value/impl.h b/include/yaml-cpp/value/impl.h index d813d93..d6046d3 100644 --- a/include/yaml-cpp/value/impl.h +++ b/include/yaml-cpp/value/impl.h @@ -7,6 +7,8 @@ #include "yaml-cpp/value/value.h" +#include "yaml-cpp/value/detail/memory.h" +#include namespace YAML { @@ -17,12 +19,16 @@ namespace YAML template inline Value::Value(const T& rhs): m_pMemory(new detail::memory_holder) { - operator=(rhs); + Assign(rhs); } inline Value::Value(const Value& rhs): m_pNode(rhs.m_pNode), m_pMemory(rhs.m_pMemory) { } + + inline Value::~Value() + { + } // access template @@ -38,12 +44,32 @@ namespace YAML template inline Value& Value::operator=(const T& rhs) { - AssignData(convert(rhs)); + Assign(rhs); return *this; } + template + inline void Value::Assign(const T& rhs) + { + AssignData(convert(rhs)); + } + template<> - inline Value& Value::operator=(const std::string& rhs) + inline void Value::Assign(const std::string& rhs) + { + EnsureNodeExists(); + m_pNode->set_scalar(rhs); + } + + template<> + inline void Value::Assign(const char * const & rhs) + { + EnsureNodeExists(); + m_pNode->set_scalar(rhs); + } + + template<> + inline void Value::Assign(char * const & rhs) { EnsureNodeExists(); m_pNode->set_scalar(rhs); @@ -54,6 +80,7 @@ namespace YAML if(is(*this, rhs)) return *this; AssignNode(rhs); + return *this; } void Value::EnsureNodeExists() @@ -81,87 +108,107 @@ namespace YAML // size/iterator inline std::size_t Value::size() const { + return 0; } inline const_iterator Value::begin() const { + return const_iterator(); } inline iterator Value::begin() { + return iterator(); } inline const_iterator Value::end() const { + return const_iterator(); } inline iterator Value::end() { + return iterator(); } // indexing template inline const Value Value::operator[](const Key& key) const { + return Value(); } template inline Value Value::operator[](const Key& key) { + return Value(); } template inline bool Value::remove(const Key& key) { + return false; } inline const Value Value::operator[](const Value& key) const { + return Value(); } inline Value Value::operator[](const Value& key) { + return Value(); } inline bool Value::remove(const Value& key) { + return false; } inline const Value Value::operator[](const char *key) const { + return Value(); } inline Value Value::operator[](const char *key) { + return Value(); } inline bool Value::remove(const char *key) { + return false; } inline const Value Value::operator[](char *key) const { + return Value(); } inline Value Value::operator[](char *key) { + return Value(); } inline bool Value::remove(char *key) { + return false; } // free functions inline int compare(const Value& lhs, const Value& rhs) { + return 0; } inline bool operator<(const Value& lhs, const Value& rhs) { + return false; } inline bool is(const Value& lhs, const Value& rhs) { + return false; } } diff --git a/include/yaml-cpp/value/iterator.h b/include/yaml-cpp/value/iterator.h new file mode 100644 index 0000000..ba9887f --- /dev/null +++ b/include/yaml-cpp/value/iterator.h @@ -0,0 +1,17 @@ +#ifndef 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 +#pragma once +#endif + + +#include "yaml-cpp/dll.h" + +namespace YAML +{ + struct iterator {}; + struct const_iterator {}; +} + +#endif // VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/include/yaml-cpp/value/value.h b/include/yaml-cpp/value/value.h index d3a4146..5e61755 100644 --- a/include/yaml-cpp/value/value.h +++ b/include/yaml-cpp/value/value.h @@ -8,6 +8,8 @@ #include "yaml-cpp/dll.h" #include "yaml-cpp/value/ptr.h" +#include "yaml-cpp/value/iterator.h" +#include namespace YAML { @@ -18,8 +20,8 @@ namespace YAML public: Value(); explicit Value(ValueType::value type); - explicit template Value(const T& rhs); - explicit Value(const Value& rhs); + template explicit Value(const T& rhs); + Value(const Value& rhs); ~Value(); ValueType::value Type() const; @@ -58,13 +60,15 @@ namespace YAML bool remove(char *key); private: + template void Assign(const T& rhs); + void EnsureNodeExists(); void AssignData(const Value& rhs); void AssignNode(const Value& rhs); private: - shared_node m_pNode; - shared_memory_holder m_pMemory; + detail::shared_node m_pNode; + detail::shared_memory_holder m_pMemory; }; int compare(const Value& lhs, const Value& rhs); diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index 22339f0..792dcfc 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -1,2 +1,5 @@ add_executable(parse parse.cpp) target_link_libraries(parse yaml-cpp) + +add_executable(value value.cpp) +target_link_libraries(value yaml-cpp) diff --git a/util/value.cpp b/util/value.cpp new file mode 100644 index 0000000..e7038a1 --- /dev/null +++ b/util/value.cpp @@ -0,0 +1,8 @@ +#include "yaml-cpp/value/value.h" + +int main() +{ + YAML::Value value; + + return 0; +}