You need to sign in or sign up before continuing.
Commit f0174ca0 authored by Jesse Beder's avatar Jesse Beder
Browse files

Reorganized so that we don't have cyclic include problems

parent fed95c5d
#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/detail/impl.h"
#endif // VALUE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#ifndef VALUE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_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"
namespace YAML
{
namespace detail
{
// indexing
template<typename Key>
inline shared_node node_data::operator[](const Key& key) const
{
if(m_type != ValueType::Map)
return shared_node(new node);
for(node_map::const_iterator it=m_map.begin();it!=m_map.end();++it) {
if(it->first->equals(key))
return it->second;
}
return shared_node(new node);
}
template<typename Key>
inline shared_node node_data::operator[](const Key& key)
{
}
template<typename Key>
inline bool node_data::remove(const Key& key)
{
}
}
}
#endif // VALUE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
......@@ -6,7 +6,6 @@
#endif
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/value/detail/node.h"
#include <set>
#include <boost/shared_ptr.hpp>
......@@ -14,19 +13,6 @@ namespace YAML
{
namespace detail
{
class memory;
class memory_holder {
public:
memory_holder();
shared_node create_node();
void merge(memory_holder& rhs);
private:
boost::shared_ptr<memory> m_pMemory;
};
class memory {
public:
shared_node create_node();
......@@ -36,36 +22,17 @@ namespace YAML
typedef std::set<shared_node> Nodes;
Nodes m_nodes;
};
inline memory_holder::memory_holder(): m_pMemory(new memory)
{
}
inline shared_node memory_holder::create_node()
{
return m_pMemory->create_node();
}
inline void memory_holder::merge(memory_holder& rhs)
{
if(m_pMemory == rhs.m_pMemory)
return;
m_pMemory->merge(*rhs.m_pMemory);
rhs.m_pMemory = m_pMemory;
}
shared_node memory::create_node()
{
shared_node pNode(new node);
m_nodes.insert(pNode);
return pNode;
}
inline void memory::merge(const memory& rhs)
{
m_nodes.insert(rhs.m_nodes.begin(), rhs.m_nodes.end());
}
class memory_holder {
public:
memory_holder(): m_pMemory(new memory) {}
shared_node create_node() { return m_pMemory->create_node(); }
void merge(memory_holder& rhs);
private:
boost::shared_ptr<memory> m_pMemory;
};
}
}
......
......@@ -28,6 +28,8 @@ namespace YAML
void set_null() { m_pData->set_null(); }
void set_scalar(const std::string& scalar) { m_pData->set_scalar(scalar); }
template<typename T> bool equals(const T& rhs) const;
// indexing
template<typename Key> shared_node operator[](const Key& key) const { return (static_cast<const node_data&>(*m_pData))[key]; }
template<typename Key> shared_node operator[](const Key& key) { return (*m_pData)[key]; }
......@@ -40,6 +42,11 @@ namespace YAML
private:
shared_node_data m_pData;
};
template<typename T>
inline bool node::equals(const T& rhs) const
{
}
}
}
......
......@@ -7,8 +7,8 @@
#include "yaml-cpp/dll.h"
#include "yaml-cpp/value/type.h"
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/value/type.h"
#include <list>
#include <utility>
#include <vector>
......
......@@ -8,6 +8,7 @@
#include "yaml-cpp/value/value.h"
#include "yaml-cpp/value/detail/memory.h"
#include "yaml-cpp/value/detail/node.h"
#include <string>
namespace YAML
......
......@@ -85,6 +85,4 @@ namespace YAML
bool convert(const Value& value, T& rhs);
}
#include "yaml-cpp/value/impl.h"
#endif // VALUE_VALUE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#include "yaml-cpp/value/detail/memory.h"
#include "yaml-cpp/value/detail/node.h"
namespace YAML
{
namespace detail
{
void memory_holder::merge(memory_holder& rhs)
{
if(m_pMemory == rhs.m_pMemory)
return;
m_pMemory->merge(*rhs.m_pMemory);
rhs.m_pMemory = m_pMemory;
}
shared_node memory::create_node()
{
shared_node pNode(new node);
m_nodes.insert(pNode);
return pNode;
}
void memory::merge(const memory& rhs)
{
m_nodes.insert(rhs.m_nodes.begin(), rhs.m_nodes.end());
}
}
}
#include "yaml-cpp/value/value.h"
#include "yaml-cpp/value.h"
int main()
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment