Reorganized so that we don't have cyclic include problems

This commit is contained in:
Jesse Beder
2011-09-07 02:59:58 -05:00
parent fed95c5da4
commit f0174ca08b
10 changed files with 105 additions and 47 deletions

13
include/yaml-cpp/value.h Normal file
View File

@@ -0,0 +1,13 @@
#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

View File

@@ -0,0 +1,43 @@
#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

View File

@@ -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();
@@ -37,35 +23,16 @@ namespace YAML
Nodes m_nodes;
};
inline memory_holder::memory_holder(): m_pMemory(new memory)
{
}
class memory_holder {
public:
memory_holder(): m_pMemory(new memory) {}
inline shared_node memory_holder::create_node()
{
return m_pMemory->create_node();
}
shared_node create_node() { return m_pMemory->create_node(); }
void merge(memory_holder& rhs);
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());
}
private:
boost::shared_ptr<memory> m_pMemory;
};
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,29 @@
#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());
}
}
}

View File

@@ -1,4 +1,4 @@
#include "yaml-cpp/value/value.h"
#include "yaml-cpp/value.h"
int main()
{