cphot 0.1
A C++ tool for computing photometry from spectra.
rapidxml_iterators.hpp
Go to the documentation of this file.
1 #ifndef RAPIDXML_ITERATORS_HPP_INCLUDED
2 #define RAPIDXML_ITERATORS_HPP_INCLUDED
3 
4 // Copyright (C) 2006, 2009 Marcin Kalicinski
5 // Version 1.13
6 // Revision $DateTime: 2009/05/13 01:46:17 $
7 //! \file rapidxml_iterators.hpp This file contains rapidxml iterators
8 
9 #include "rapidxml.hpp"
10 
11 namespace rapidxml
12 {
13 
14  //! Iterator of child nodes of xml_node
15  template<class Ch>
17  {
18 
19  public:
20 
21  typedef typename xml_node<Ch> value_type;
22  typedef typename xml_node<Ch> &reference;
23  typedef typename xml_node<Ch> *pointer;
24  typedef std::ptrdiff_t difference_type;
25  typedef std::bidirectional_iterator_tag iterator_category;
26 
28  : m_node(0)
29  {
30  }
31 
33  : m_node(node->first_node())
34  {
35  }
36 
38  {
39  assert(m_node);
40  return *m_node;
41  }
42 
44  {
45  assert(m_node);
46  return m_node;
47  }
48 
50  {
51  assert(m_node);
52  m_node = m_node->next_sibling();
53  return *this;
54  }
55 
57  {
58  node_iterator tmp = *this;
59  ++this;
60  return tmp;
61  }
62 
64  {
65  assert(m_node && m_node->previous_sibling());
66  m_node = m_node->previous_sibling();
67  return *this;
68  }
69 
71  {
72  node_iterator tmp = *this;
73  ++this;
74  return tmp;
75  }
76 
77  bool operator ==(const node_iterator<Ch> &rhs)
78  {
79  return m_node == rhs.m_node;
80  }
81 
82  bool operator !=(const node_iterator<Ch> &rhs)
83  {
84  return m_node != rhs.m_node;
85  }
86 
87  private:
88 
89  xml_node<Ch> *m_node;
90 
91  };
92 
93  //! Iterator of child attributes of xml_node
94  template<class Ch>
96  {
97 
98  public:
99 
100  typedef typename xml_attribute<Ch> value_type;
101  typedef typename xml_attribute<Ch> &reference;
102  typedef typename xml_attribute<Ch> *pointer;
103  typedef std::ptrdiff_t difference_type;
104  typedef std::bidirectional_iterator_tag iterator_category;
105 
107  : m_attribute(0)
108  {
109  }
110 
112  : m_attribute(node->first_attribute())
113  {
114  }
115 
117  {
118  assert(m_attribute);
119  return *m_attribute;
120  }
121 
123  {
124  assert(m_attribute);
125  return m_attribute;
126  }
127 
129  {
130  assert(m_attribute);
131  m_attribute = m_attribute->next_attribute();
132  return *this;
133  }
134 
136  {
137  attribute_iterator tmp = *this;
138  ++this;
139  return tmp;
140  }
141 
143  {
144  assert(m_attribute && m_attribute->previous_attribute());
145  m_attribute = m_attribute->previous_attribute();
146  return *this;
147  }
148 
150  {
151  attribute_iterator tmp = *this;
152  ++this;
153  return tmp;
154  }
155 
157  {
158  return m_attribute == rhs.m_attribute;
159  }
160 
162  {
163  return m_attribute != rhs.m_attribute;
164  }
165 
166  private:
167 
168  xml_attribute<Ch> *m_attribute;
169 
170  };
171 
172 }
173 
174 #endif
rapidxml::attribute_iterator::operator*
reference operator*() const
Definition: rapidxml_iterators.hpp:116
rapidxml::node_iterator::operator*
reference operator*() const
Definition: rapidxml_iterators.hpp:37
rapidxml::attribute_iterator::operator==
bool operator==(const attribute_iterator< Ch > &rhs)
Definition: rapidxml_iterators.hpp:156
rapidxml::attribute_iterator
Iterator of child attributes of xml_node.
Definition: rapidxml_iterators.hpp:95
rapidxml::node_iterator::iterator_category
std::bidirectional_iterator_tag iterator_category
Definition: rapidxml_iterators.hpp:25
rapidxml::node_iterator::node_iterator
node_iterator(xml_node< Ch > *node)
Definition: rapidxml_iterators.hpp:32
rapidxml::attribute_iterator::operator++
attribute_iterator operator++(int)
Definition: rapidxml_iterators.hpp:135
rapidxml::node_iterator::operator!=
bool operator!=(const node_iterator< Ch > &rhs)
Definition: rapidxml_iterators.hpp:82
rapidxml::attribute_iterator::reference
xml_attribute< Ch > & reference
Definition: rapidxml_iterators.hpp:101
rapidxml::attribute_iterator::pointer
xml_attribute< Ch > * pointer
Definition: rapidxml_iterators.hpp:102
rapidxml::attribute_iterator::operator--
attribute_iterator & operator--()
Definition: rapidxml_iterators.hpp:142
rapidxml::attribute_iterator::operator--
attribute_iterator operator--(int)
Definition: rapidxml_iterators.hpp:149
rapidxml::node_iterator::operator==
bool operator==(const node_iterator< Ch > &rhs)
Definition: rapidxml_iterators.hpp:77
rapidxml::xml_attribute
Class representing attribute node of XML document.
Definition: rapidxml.hpp:141
rapidxml::node_iterator::operator++
node_iterator & operator++()
Definition: rapidxml_iterators.hpp:49
rapidxml::node_iterator::value_type
xml_node< Ch > value_type
Definition: rapidxml_iterators.hpp:21
rapidxml::node_iterator::node_iterator
node_iterator()
Definition: rapidxml_iterators.hpp:27
rapidxml::attribute_iterator::difference_type
std::ptrdiff_t difference_type
Definition: rapidxml_iterators.hpp:103
rapidxml
Definition: rapidxml.hpp:59
rapidxml::node_iterator
Iterator of child nodes of xml_node.
Definition: rapidxml_iterators.hpp:16
rapidxml::attribute_iterator::operator->
pointer operator->() const
Definition: rapidxml_iterators.hpp:122
rapidxml::attribute_iterator::operator++
attribute_iterator & operator++()
Definition: rapidxml_iterators.hpp:128
rapidxml::node_iterator::difference_type
std::ptrdiff_t difference_type
Definition: rapidxml_iterators.hpp:24
rapidxml::xml_node
Class representing a node of XML document.
Definition: rapidxml.hpp:140
rapidxml::node_iterator::operator->
pointer operator->() const
Definition: rapidxml_iterators.hpp:43
rapidxml::attribute_iterator::attribute_iterator
attribute_iterator()
Definition: rapidxml_iterators.hpp:106
rapidxml::attribute_iterator::value_type
xml_attribute< Ch > value_type
Definition: rapidxml_iterators.hpp:100
rapidxml::node_iterator::pointer
xml_node< Ch > * pointer
Definition: rapidxml_iterators.hpp:23
rapidxml::node_iterator::operator--
node_iterator & operator--()
Definition: rapidxml_iterators.hpp:63
rapidxml::attribute_iterator::attribute_iterator
attribute_iterator(xml_node< Ch > *node)
Definition: rapidxml_iterators.hpp:111
rapidxml.hpp
rapidxml::node_iterator::reference
xml_node< Ch > & reference
Definition: rapidxml_iterators.hpp:22
rapidxml::attribute_iterator::iterator_category
std::bidirectional_iterator_tag iterator_category
Definition: rapidxml_iterators.hpp:104
rapidxml::node_iterator::operator--
node_iterator operator--(int)
Definition: rapidxml_iterators.hpp:70
rapidxml::attribute_iterator::operator!=
bool operator!=(const attribute_iterator< Ch > &rhs)
Definition: rapidxml_iterators.hpp:161
rapidxml::node_iterator::operator++
node_iterator operator++(int)
Definition: rapidxml_iterators.hpp:56