Value stuff compiles/links with lots of placeholder functions

This commit is contained in:
Jesse Beder
2011-09-07 00:12:24 -05:00
parent 248b18a2d0
commit 1e6877043e
8 changed files with 112 additions and 7 deletions

View File

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

View File

@@ -8,6 +8,7 @@
#include "yaml-cpp/dll.h" #include "yaml-cpp/dll.h"
#include "yaml-cpp/value/ptr.h" #include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/value/detail/node_data.h"
namespace YAML namespace YAML
{ {

View File

@@ -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

View File

@@ -7,6 +7,8 @@
#include "yaml-cpp/value/value.h" #include "yaml-cpp/value/value.h"
#include "yaml-cpp/value/detail/memory.h"
#include <string>
namespace YAML namespace YAML
{ {
@@ -17,13 +19,17 @@ namespace YAML
template<typename T> template<typename T>
inline Value::Value(const T& rhs): m_pMemory(new detail::memory_holder) 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(const Value& rhs): m_pNode(rhs.m_pNode), m_pMemory(rhs.m_pMemory)
{ {
} }
inline Value::~Value()
{
}
// access // access
template<typename T> template<typename T>
inline const T Value::as() const inline const T Value::as() const
@@ -38,12 +44,32 @@ namespace YAML
template<typename T> template<typename T>
inline Value& Value::operator=(const T& rhs) inline Value& Value::operator=(const T& rhs)
{ {
AssignData(convert<T>(rhs)); Assign(rhs);
return *this; return *this;
} }
template<typename T>
inline void Value::Assign(const T& rhs)
{
AssignData(convert<T>(rhs));
}
template<> 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(); EnsureNodeExists();
m_pNode->set_scalar(rhs); m_pNode->set_scalar(rhs);
@@ -54,6 +80,7 @@ namespace YAML
if(is(*this, rhs)) if(is(*this, rhs))
return *this; return *this;
AssignNode(rhs); AssignNode(rhs);
return *this;
} }
void Value::EnsureNodeExists() void Value::EnsureNodeExists()
@@ -81,87 +108,107 @@ namespace YAML
// size/iterator // size/iterator
inline std::size_t Value::size() const inline std::size_t Value::size() const
{ {
return 0;
} }
inline const_iterator Value::begin() const inline const_iterator Value::begin() const
{ {
return const_iterator();
} }
inline iterator Value::begin() inline iterator Value::begin()
{ {
return iterator();
} }
inline const_iterator Value::end() const inline const_iterator Value::end() const
{ {
return const_iterator();
} }
inline iterator Value::end() inline iterator Value::end()
{ {
return iterator();
} }
// indexing // indexing
template<typename Key> template<typename Key>
inline const Value Value::operator[](const Key& key) const inline const Value Value::operator[](const Key& key) const
{ {
return Value();
} }
template<typename Key> template<typename Key>
inline Value Value::operator[](const Key& key) inline Value Value::operator[](const Key& key)
{ {
return Value();
} }
template<typename Key> template<typename Key>
inline bool Value::remove(const Key& key) inline bool Value::remove(const Key& key)
{ {
return false;
} }
inline const Value Value::operator[](const Value& key) const inline const Value Value::operator[](const Value& key) const
{ {
return Value();
} }
inline Value Value::operator[](const Value& key) inline Value Value::operator[](const Value& key)
{ {
return Value();
} }
inline bool Value::remove(const Value& key) inline bool Value::remove(const Value& key)
{ {
return false;
} }
inline const Value Value::operator[](const char *key) const inline const Value Value::operator[](const char *key) const
{ {
return Value();
} }
inline Value Value::operator[](const char *key) inline Value Value::operator[](const char *key)
{ {
return Value();
} }
inline bool Value::remove(const char *key) inline bool Value::remove(const char *key)
{ {
return false;
} }
inline const Value Value::operator[](char *key) const inline const Value Value::operator[](char *key) const
{ {
return Value();
} }
inline Value Value::operator[](char *key) inline Value Value::operator[](char *key)
{ {
return Value();
} }
inline bool Value::remove(char *key) inline bool Value::remove(char *key)
{ {
return false;
} }
// free functions // free functions
inline int compare(const Value& lhs, const Value& rhs) inline int compare(const Value& lhs, const Value& rhs)
{ {
return 0;
} }
inline bool operator<(const Value& lhs, const Value& rhs) inline bool operator<(const Value& lhs, const Value& rhs)
{ {
return false;
} }
inline bool is(const Value& lhs, const Value& rhs) inline bool is(const Value& lhs, const Value& rhs)
{ {
return false;
} }
} }

View File

@@ -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

View File

@@ -8,6 +8,8 @@
#include "yaml-cpp/dll.h" #include "yaml-cpp/dll.h"
#include "yaml-cpp/value/ptr.h" #include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/value/iterator.h"
#include <stdexcept>
namespace YAML namespace YAML
{ {
@@ -18,8 +20,8 @@ namespace YAML
public: public:
Value(); Value();
explicit Value(ValueType::value type); explicit Value(ValueType::value type);
explicit template<typename T> Value(const T& rhs); template<typename T> explicit Value(const T& rhs);
explicit Value(const Value& rhs); Value(const Value& rhs);
~Value(); ~Value();
ValueType::value Type() const; ValueType::value Type() const;
@@ -58,13 +60,15 @@ namespace YAML
bool remove(char *key); bool remove(char *key);
private: private:
template<typename T> void Assign(const T& rhs);
void EnsureNodeExists(); void EnsureNodeExists();
void AssignData(const Value& rhs); void AssignData(const Value& rhs);
void AssignNode(const Value& rhs); void AssignNode(const Value& rhs);
private: private:
shared_node m_pNode; detail::shared_node m_pNode;
shared_memory_holder m_pMemory; detail::shared_memory_holder m_pMemory;
}; };
int compare(const Value& lhs, const Value& rhs); int compare(const Value& lhs, const Value& rhs);

View File

@@ -1,2 +1,5 @@
add_executable(parse parse.cpp) add_executable(parse parse.cpp)
target_link_libraries(parse yaml-cpp) target_link_libraries(parse yaml-cpp)
add_executable(value value.cpp)
target_link_libraries(value yaml-cpp)

8
util/value.cpp Normal file
View File

@@ -0,0 +1,8 @@
#include "yaml-cpp/value/value.h"
int main()
{
YAML::Value value;
return 0;
}