diff --git a/include/yaml-cpp/value/detail/iterator.h b/include/yaml-cpp/value/detail/iterator.h index 2a4bb86..eafab01 100644 --- a/include/yaml-cpp/value/detail/iterator.h +++ b/include/yaml-cpp/value/detail/iterator.h @@ -8,25 +8,13 @@ #include "yaml-cpp/dll.h" #include "yaml-cpp/value/ptr.h" -#include "yaml-cpp/value/value.h" #include #include -#include -#include -#include namespace YAML { namespace detail { - class node; - - struct iterator_value: public Value, std::pair { - iterator_value() {} - explicit iterator_value(const Value& rhs): Value(rhs) {} - explicit iterator_value(const Value& key, const Value& value): std::pair(key, value) {} - }; - struct iterator_type { enum value { None, Sequence, Map }; }; template @@ -94,16 +82,6 @@ namespace YAML SeqIter m_seqIt; MapIter m_mapIt; }; - - typedef std::vector node_seq; - typedef std::pair kv_pair; - typedef std::list 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; } } diff --git a/include/yaml-cpp/value/detail/iterator_fwd.h b/include/yaml-cpp/value/detail/iterator_fwd.h new file mode 100644 index 0000000..023e5af --- /dev/null +++ b/include/yaml-cpp/value/detail/iterator_fwd.h @@ -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 +#include +#include + +namespace YAML +{ + class node; + + namespace detail { + struct iterator_value; + typedef std::vector node_seq; + typedef std::pair kv_pair; + typedef std::list 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 class iterator_base; + } + + typedef detail::iterator_base iterator; + + typedef detail::iterator_base const_iterator; +} + +#endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/include/yaml-cpp/value/iterator.h b/include/yaml-cpp/value/iterator.h index d687368..6055294 100644 --- a/include/yaml-cpp/value/iterator.h +++ b/include/yaml-cpp/value/iterator.h @@ -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 +#include +#include namespace YAML { - class iterator: public detail::iterator_base - { - private: - typedef detail::iterator_base 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 - { - private: - typedef detail::iterator_base 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 { + iterator_value() {} + explicit iterator_value(const Value& rhs): Value(rhs) {} + explicit iterator_value(const Value& key, const Value& value): std::pair(key, value) {} + }; + } } #endif // VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/include/yaml-cpp/value/value.h b/include/yaml-cpp/value/value.h index 51f6b19..bb4f404 100644 --- a/include/yaml-cpp/value/value.h +++ b/include/yaml-cpp/value/value.h @@ -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 namespace YAML { - class iterator; - class const_iterator; - class Value { public: