Switched iterators to typedef's, with a bit of finagling so we can forward-declare them
This commit is contained in:
parent
9aa3eb56f2
commit
190a556756
@ -8,25 +8,13 @@
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/value/ptr.h"
|
||||
#include "yaml-cpp/value/value.h"
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <list>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
class node;
|
||||
|
||||
struct iterator_value: public Value, std::pair<Value, Value> {
|
||||
iterator_value() {}
|
||||
explicit iterator_value(const Value& rhs): Value(rhs) {}
|
||||
explicit iterator_value(const Value& key, const Value& value): std::pair<Value, Value>(key, value) {}
|
||||
};
|
||||
|
||||
struct iterator_type { enum value { None, Sequence, Map }; };
|
||||
|
||||
template<typename V, typename SeqIter, typename MapIter>
|
||||
@ -94,16 +82,6 @@ namespace YAML
|
||||
SeqIter m_seqIt;
|
||||
MapIter m_mapIt;
|
||||
};
|
||||
|
||||
typedef std::vector<node *> node_seq;
|
||||
typedef std::pair<node *, node *> kv_pair;
|
||||
typedef std::list<kv_pair> node_map;
|
||||
|
||||
typedef node_seq::iterator node_seq_iterator;
|
||||
typedef node_seq::const_iterator node_seq_const_iterator;
|
||||
|
||||
typedef node_map::iterator node_map_iterator;
|
||||
typedef node_map::const_iterator node_map_const_iterator;
|
||||
}
|
||||
}
|
||||
|
||||
|
38
include/yaml-cpp/value/detail/iterator_fwd.h
Normal file
38
include/yaml-cpp/value/detail/iterator_fwd.h
Normal file
@ -0,0 +1,38 @@
|
||||
#ifndef VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define VALUE_DETAIL_ITERATOR_FWD_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 <list>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class node;
|
||||
|
||||
namespace detail {
|
||||
struct iterator_value;
|
||||
typedef std::vector<node *> node_seq;
|
||||
typedef std::pair<node *, node *> kv_pair;
|
||||
typedef std::list<kv_pair> node_map;
|
||||
|
||||
typedef node_seq::iterator node_seq_iterator;
|
||||
typedef node_seq::const_iterator node_seq_const_iterator;
|
||||
|
||||
typedef node_map::iterator node_map_iterator;
|
||||
typedef node_map::const_iterator node_map_const_iterator;
|
||||
|
||||
template<typename V, typename SeqIter, typename MapIter> class iterator_base;
|
||||
}
|
||||
|
||||
typedef detail::iterator_base<detail::iterator_value, detail::node_seq_iterator, detail::node_map_iterator> iterator;
|
||||
|
||||
typedef detail::iterator_base<const detail::iterator_value, detail::node_seq_const_iterator, detail::node_map_const_iterator> const_iterator;
|
||||
}
|
||||
|
||||
#endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
@ -7,32 +7,22 @@
|
||||
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/value/value.h"
|
||||
#include "yaml-cpp/value/detail/iterator_fwd.h"
|
||||
#include "yaml-cpp/value/detail/iterator.h"
|
||||
#include <list>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class iterator: public detail::iterator_base<detail::iterator_value, detail::node_seq_iterator, detail::node_map_iterator>
|
||||
{
|
||||
private:
|
||||
typedef detail::iterator_base<detail::iterator_value, detail::node_seq_iterator, detail::node_map_iterator> base;
|
||||
|
||||
public:
|
||||
iterator() {}
|
||||
explicit iterator(detail::shared_memory_holder pMemory, detail::node_seq_iterator seqIt): base(pMemory, seqIt) {}
|
||||
explicit iterator(detail::shared_memory_holder pMemory, detail::node_map_iterator mapIt): base(pMemory, mapIt) {}
|
||||
};
|
||||
|
||||
class const_iterator: public detail::iterator_base<const detail::iterator_value, detail::node_seq_const_iterator, detail::node_map_const_iterator>
|
||||
{
|
||||
private:
|
||||
typedef detail::iterator_base<const detail::iterator_value, detail::node_seq_const_iterator, detail::node_map_const_iterator> base;
|
||||
|
||||
public:
|
||||
const_iterator() {}
|
||||
explicit const_iterator(detail::shared_memory_holder pMemory, detail::node_seq_const_iterator seqIt): base(pMemory, seqIt) {}
|
||||
explicit const_iterator(detail::shared_memory_holder pMemory, detail::node_map_const_iterator mapIt): base(pMemory, mapIt) {}
|
||||
explicit const_iterator(const iterator& rhs): base(rhs) {}
|
||||
namespace detail {
|
||||
struct iterator_value: public Value, std::pair<Value, Value> {
|
||||
iterator_value() {}
|
||||
explicit iterator_value(const Value& rhs): Value(rhs) {}
|
||||
explicit iterator_value(const Value& key, const Value& value): std::pair<Value, Value>(key, value) {}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
@ -9,13 +9,11 @@
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/value/ptr.h"
|
||||
#include "yaml-cpp/value/type.h"
|
||||
#include "yaml-cpp/value/detail/iterator_fwd.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class iterator;
|
||||
class const_iterator;
|
||||
|
||||
class Value
|
||||
{
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user