Started writing new iterators
This commit is contained in:
parent
7bbf712c36
commit
ff1a8fc59a
@ -9,6 +9,7 @@
|
||||
#include "yaml-cpp/value/value.h"
|
||||
#include "yaml-cpp/value/impl.h"
|
||||
#include "yaml-cpp/value/convert.h"
|
||||
#include "yaml-cpp/value/iterator.h"
|
||||
#include "yaml-cpp/value/detail/impl.h"
|
||||
|
||||
#endif // VALUE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
@ -32,7 +32,17 @@ namespace YAML
|
||||
void set_type(ValueType::value type) { m_pRef->set_type(type); }
|
||||
void set_null() { m_pRef->set_null(); }
|
||||
void set_scalar(const std::string& scalar) { m_pRef->set_scalar(scalar); }
|
||||
|
||||
// size/iterator
|
||||
std::size_t size() const { return m_pRef->size(); }
|
||||
|
||||
const_iterator begin(shared_memory_holder pMemory) const { return static_cast<const node_ref&>(*m_pRef).begin(pMemory); }
|
||||
iterator begin(shared_memory_holder pMemory) { return m_pRef->begin(pMemory); }
|
||||
|
||||
const_iterator end(shared_memory_holder pMemory) const { return static_cast<const node_ref&>(*m_pRef).end(pMemory); }
|
||||
iterator end(shared_memory_holder pMemory) { return m_pRef->end(pMemory); }
|
||||
|
||||
// sequence
|
||||
void append(node& node, shared_memory_holder pMemory) { m_pRef->append(node, pMemory); }
|
||||
|
||||
// indexing
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/value/iterator.h"
|
||||
#include "yaml-cpp/value/ptr.h"
|
||||
#include "yaml-cpp/value/type.h"
|
||||
#include <boost/utility.hpp>
|
||||
@ -30,6 +31,16 @@ namespace YAML
|
||||
ValueType::value type() const { return m_isDefined ? m_type : ValueType::Undefined; }
|
||||
const std::string& scalar() const { return m_scalar; }
|
||||
|
||||
// size/iterator
|
||||
std::size_t size() const;
|
||||
|
||||
const_iterator begin(shared_memory_holder pMemory) const;
|
||||
iterator begin(shared_memory_holder pMemory);
|
||||
|
||||
const_iterator end(shared_memory_holder pMemory) const;
|
||||
iterator end(shared_memory_holder pMemory);
|
||||
|
||||
// sequence
|
||||
void append(node& node, shared_memory_holder pMemory);
|
||||
|
||||
// indexing
|
||||
|
@ -30,6 +30,16 @@ namespace YAML
|
||||
void set_null() { ensure_data_exists(); m_pData->set_null(); }
|
||||
void set_scalar(const std::string& scalar) { ensure_data_exists(); m_pData->set_scalar(scalar); }
|
||||
|
||||
// size/iterator
|
||||
std::size_t size() const { return m_pData ? m_pData->size() : 0; }
|
||||
|
||||
const_iterator begin(shared_memory_holder pMemory) const { return m_pData ? static_cast<const node_data&>(*m_pData).begin(pMemory) : const_iterator(); }
|
||||
iterator begin(shared_memory_holder pMemory) {return m_pData ? m_pData->begin(pMemory) : iterator(); }
|
||||
|
||||
const_iterator end(shared_memory_holder pMemory) const { return m_pData ? static_cast<const node_data&>(*m_pData).end(pMemory) : const_iterator(); }
|
||||
iterator end(shared_memory_holder pMemory) {return m_pData ? m_pData->end(pMemory) : iterator(); }
|
||||
|
||||
// sequence
|
||||
void append(node& node, shared_memory_holder pMemory) { ensure_data_exists(); m_pData->append(node, pMemory); }
|
||||
|
||||
// indexing
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
|
||||
#include "yaml-cpp/value/value.h"
|
||||
#include "yaml-cpp/value/iterator.h"
|
||||
#include "yaml-cpp/value/detail/memory.h"
|
||||
#include "yaml-cpp/value/detail/node.h"
|
||||
#include <string>
|
||||
@ -127,27 +128,27 @@ namespace YAML
|
||||
// size/iterator
|
||||
inline std::size_t Value::size() const
|
||||
{
|
||||
return 0;
|
||||
return m_pNode->size();
|
||||
}
|
||||
|
||||
inline const_iterator Value::begin() const
|
||||
{
|
||||
return const_iterator();
|
||||
return static_cast<const detail::node&>(*m_pNode).begin(m_pMemory);
|
||||
}
|
||||
|
||||
inline iterator Value::begin()
|
||||
{
|
||||
return iterator();
|
||||
return m_pNode->begin(m_pMemory);
|
||||
}
|
||||
|
||||
inline const_iterator Value::end() const
|
||||
{
|
||||
return const_iterator();
|
||||
return static_cast<const detail::node&>(*m_pNode).end(m_pMemory);
|
||||
}
|
||||
|
||||
inline iterator Value::end()
|
||||
{
|
||||
return iterator();
|
||||
return m_pNode->end(m_pMemory);
|
||||
}
|
||||
|
||||
// sequence
|
||||
|
@ -7,11 +7,12 @@
|
||||
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/value/detail/iterator.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
struct iterator {};
|
||||
struct const_iterator {};
|
||||
class iterator: public detail::iterator_base<detail::iterator_value, detail::node_seq_iterator, detail::node_map_iterator> {};
|
||||
class const_iterator: public detail::iterator_base<const detail::iterator_value, detail::node_seq_const_iterator, detail::node_map_const_iterator> {};
|
||||
}
|
||||
|
||||
#endif // VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
@ -7,13 +7,15 @@
|
||||
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/value/iterator.h"
|
||||
#include "yaml-cpp/value/ptr.h"
|
||||
#include "yaml-cpp/value/type.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class iterator;
|
||||
class const_iterator;
|
||||
|
||||
class Value
|
||||
{
|
||||
public:
|
||||
|
@ -60,6 +60,49 @@ namespace YAML
|
||||
m_scalar = scalar;
|
||||
}
|
||||
|
||||
// size/iterator
|
||||
std::size_t node_data::size() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const_iterator node_data::begin(shared_memory_holder pMemory) const
|
||||
{
|
||||
switch(m_type) {
|
||||
case ValueType::Sequence: return const_iterator(pMemory, m_sequence.begin());
|
||||
case ValueType::Map: return const_iterator(pMemory, m_map.begin());
|
||||
default: return const_iterator();
|
||||
}
|
||||
}
|
||||
|
||||
iterator node_data::begin(shared_memory_holder pMemory)
|
||||
{
|
||||
switch(m_type) {
|
||||
case ValueType::Sequence: return iterator(pMemory, m_sequence.begin());
|
||||
case ValueType::Map: return iterator(pMemory, m_map.begin());
|
||||
default: return iterator();
|
||||
}
|
||||
}
|
||||
|
||||
const_iterator node_data::end(shared_memory_holder pMemory) const
|
||||
{
|
||||
switch(m_type) {
|
||||
case ValueType::Sequence: return const_iterator(pMemory, m_sequence.end());
|
||||
case ValueType::Map: return const_iterator(pMemory, m_map.end());
|
||||
default: return const_iterator();
|
||||
}
|
||||
}
|
||||
|
||||
iterator node_data::end(shared_memory_holder pMemory)
|
||||
{
|
||||
switch(m_type) {
|
||||
case ValueType::Sequence: return iterator(pMemory, m_sequence.end());
|
||||
case ValueType::Map: return iterator(pMemory, m_map.end());
|
||||
default: return iterator();
|
||||
}
|
||||
}
|
||||
|
||||
// sequence
|
||||
void node_data::append(node& node, shared_memory_holder /* pMemory */)
|
||||
{
|
||||
if(m_type != ValueType::Sequence)
|
||||
|
Loading…
Reference in New Issue
Block a user