1 #include "yaml-cpp/node.h"
2 #include "yaml-cpp/exceptions.h"
7 Iterator::Iterator(): m_pData(new IterPriv
)
11 Iterator::Iterator(std::auto_ptr
<IterPriv
> pData
): m_pData(pData
)
15 Iterator::Iterator(const Iterator
& rhs
): m_pData(new IterPriv(*rhs
.m_pData
))
19 Iterator
& Iterator::operator = (const Iterator
& rhs
)
24 m_pData
.reset(new IterPriv(*rhs
.m_pData
));
32 Iterator
& Iterator::operator ++ ()
34 if(m_pData
->type
== IterPriv::IT_SEQ
)
36 else if(m_pData
->type
== IterPriv::IT_MAP
)
42 Iterator
Iterator::operator ++ (int)
44 Iterator temp
= *this;
46 if(m_pData
->type
== IterPriv::IT_SEQ
)
48 else if(m_pData
->type
== IterPriv::IT_MAP
)
54 const Node
& Iterator::operator * () const
56 if(m_pData
->type
== IterPriv::IT_SEQ
)
57 return **m_pData
->seqIter
;
59 throw BadDereference();
62 const Node
*Iterator::operator -> () const
64 if(m_pData
->type
== IterPriv::IT_SEQ
)
65 return *m_pData
->seqIter
;
67 throw BadDereference();
70 const Node
& Iterator::first() const
72 if(m_pData
->type
== IterPriv::IT_MAP
)
73 return *m_pData
->mapIter
->first
;
75 throw BadDereference();
78 const Node
& Iterator::second() const
80 if(m_pData
->type
== IterPriv::IT_MAP
)
81 return *m_pData
->mapIter
->second
;
83 throw BadDereference();
86 bool operator == (const Iterator
& it
, const Iterator
& jt
)
88 if(it
.m_pData
->type
!= jt
.m_pData
->type
)
91 if(it
.m_pData
->type
== IterPriv::IT_SEQ
)
92 return it
.m_pData
->seqIter
== jt
.m_pData
->seqIter
;
93 else if(it
.m_pData
->type
== IterPriv::IT_MAP
)
94 return it
.m_pData
->mapIter
== jt
.m_pData
->mapIter
;
99 bool operator != (const Iterator
& it
, const Iterator
& jt
)