iterator.cpp
Go to the documentation of this file.
1 #include "yaml-cpp-pm/node.h"
3 #include "iterpriv.h"
4 
5 namespace YAML_PM
6 {
7  Iterator::Iterator(): m_pData(new IterPriv)
8  {
9  }
10 
11  Iterator::Iterator(std::auto_ptr<IterPriv> pData): m_pData(pData)
12  {
13  }
14 
16  {
17  }
18 
20  {
21  if(this == &rhs)
22  return *this;
23 
24  m_pData.reset(new IterPriv(*rhs.m_pData));
25  return *this;
26  }
27 
29  {
30  }
31 
33  {
34  if(m_pData->type == IterPriv::IT_SEQ)
35  ++m_pData->seqIter;
36  else if(m_pData->type == IterPriv::IT_MAP)
37  ++m_pData->mapIter;
38 
39  return *this;
40  }
41 
43  {
44  Iterator temp = *this;
45 
46  if(m_pData->type == IterPriv::IT_SEQ)
47  ++m_pData->seqIter;
48  else if(m_pData->type == IterPriv::IT_MAP)
49  ++m_pData->mapIter;
50 
51  return temp;
52  }
53 
54  const Node& Iterator::operator * () const
55  {
56  if(m_pData->type == IterPriv::IT_SEQ)
57  return **m_pData->seqIter;
58 
59  throw BadDereference();
60  }
61 
63  {
64  if(m_pData->type == IterPriv::IT_SEQ)
65  return *m_pData->seqIter;
66 
67  throw BadDereference();
68  }
69 
70  const Node& Iterator::first() const
71  {
72  if(m_pData->type == IterPriv::IT_MAP)
73  return *m_pData->mapIter->first;
74 
75  throw BadDereference();
76  }
77 
78  const Node& Iterator::second() const
79  {
80  if(m_pData->type == IterPriv::IT_MAP)
81  return *m_pData->mapIter->second;
82 
83  throw BadDereference();
84  }
85 
86  bool operator == (const Iterator& it, const Iterator& jt)
87  {
88  if(it.m_pData->type != jt.m_pData->type)
89  return false;
90 
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;
95 
96  return true;
97  }
98 
99  bool operator != (const Iterator& it, const Iterator& jt)
100  {
101  return !(it == jt);
102  }
103 }
friend YAML_CPP_API bool operator==(const Iterator &it, const Iterator &jt)
Definition: iterator.cpp:86
Iterator & operator++()
Definition: iterator.cpp:32
const Node * operator->() const
Definition: iterator.cpp:62
const Node & operator*() const
Definition: iterator.cpp:54
const Node & second() const
Definition: iterator.cpp:78
std::auto_ptr< IterPriv > m_pData
Definition: iterator.h:36
friend YAML_CPP_API bool operator!=(const Iterator &it, const Iterator &jt)
Definition: iterator.cpp:99
const Node & first() const
Definition: iterator.cpp:70
Iterator & operator=(const Iterator &rhs)
Definition: iterator.cpp:19


libpointmatcher
Author(s):
autogenerated on Sat May 27 2023 02:38:02