1 #ifndef VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 #define VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 4 #if defined(_MSC_VER) || \ 5 (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 10 #include "yaml-cpp/dll.h" 11 #include "yaml-cpp/node/ptr.h" 22 enum value { None, Sequence, Map };
27 typedef std::pair<V*, V*> kv;
33 V& operator*()
const {
return *pNode; }
34 V& operator->()
const {
return *pNode; }
39 typedef std::vector<node*> node_seq;
40 typedef std::vector<std::pair<node*, node*>> node_map;
44 typedef node_seq::iterator seq;
45 typedef node_map::iterator map;
50 typedef node_seq::const_iterator seq;
51 typedef node_map::const_iterator map;
56 :
public std::iterator<std::forward_iterator_tag, node_iterator_value<V>,
57 std::ptrdiff_t, node_iterator_value<V>*,
58 node_iterator_value<V>> {
71 typedef typename node_iterator_type<V>::seq SeqIter;
72 typedef typename node_iterator_type<V>::map MapIter;
76 : m_type(iterator_type::None), m_seqIt(), m_mapIt(), m_mapEnd() {}
78 : m_type(iterator_type::Sequence),
83 : m_type(iterator_type::Map),
87 m_mapIt = increment_until_defined(m_mapIt);
92 typename std::enable_if<std::is_convertible<W*, V*>::value,
93 enabler>::type = enabler())
97 m_mapEnd(rhs.m_mapEnd) {}
102 template <
typename W>
104 if (m_type != rhs.m_type)
108 case iterator_type::None:
110 case iterator_type::Sequence:
111 return m_seqIt == rhs.m_seqIt;
112 case iterator_type::Map:
113 return m_mapIt == rhs.m_mapIt;
118 template <
typename W>
120 return !(*
this == rhs);
125 case iterator_type::None:
127 case iterator_type::Sequence:
130 case iterator_type::Map:
132 m_mapIt = increment_until_defined(m_mapIt);
144 value_type operator*()
const {
146 case iterator_type::None:
148 case iterator_type::Sequence:
149 return value_type(**m_seqIt);
150 case iterator_type::Map:
151 return value_type(*m_mapIt->first, *m_mapIt->second);
156 proxy operator->()
const {
return proxy(**
this); }
158 MapIter increment_until_defined(MapIter it) {
159 while (it != m_mapEnd && !is_defined(it))
164 bool is_defined(MapIter it)
const {
165 return it->first->is_defined() && it->second->is_defined();
169 typename iterator_type::value m_type;
172 MapIter m_mapIt, m_mapEnd;
180 #endif // VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 Definition: node_iterator.h:43
Definition: node_iterator.h:26
Definition: node_iterator.h:55
Definition: node_iterator.h:21
Definition: DrawableObjectLoader.h:10