MIRA
XMLDom.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 by
3  * MetraLabs GmbH (MLAB), GERMANY
4  * and
5  * Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6  * All rights reserved.
7  *
8  * Contact: info@mira-project.org
9  *
10  * Commercial Usage:
11  * Licensees holding valid commercial licenses may use this file in
12  * accordance with the commercial license agreement provided with the
13  * software or, alternatively, in accordance with the terms contained in
14  * a written agreement between you and MLAB or NICR.
15  *
16  * GNU General Public License Usage:
17  * Alternatively, this file may be used under the terms of the GNU
18  * General Public License version 3.0 as published by the Free Software
19  * Foundation and appearing in the file LICENSE.GPL3 included in the
20  * packaging of this file. Please review the following information to
21  * ensure the GNU General Public License version 3.0 requirements will be
22  * met: http://www.gnu.org/copyleft/gpl.html.
23  * Alternatively you may (at your option) use any later version of the GNU
24  * General Public License if such license has been publicly approved by
25  * MLAB and NICR (or its successors, if any).
26  *
27  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
28  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
29  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
30  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
33  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
34  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
35  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
36  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
37  */
38 
47 #ifndef _MIRA_XMLDOM_H_
48 #define _MIRA_XMLDOM_H_
49 
50 #include <iostream>
51 #include <string>
52 #ifndef Q_MOC_RUN
53 #include <boost/noncopyable.hpp>
54 #endif
55 
56 #include <error/Exceptions.h>
57 #include <platform/Types.h>
58 #include <utils/Path.h>
59 #include <utils/ToString.h>
60 
61 struct _xmlNode;
62 struct _xmlAttr;
63 struct _xmlDoc;
64 struct _xmlNs;
65 
66 namespace mira {
67 
69 
74 class XMLDom : boost::noncopyable
75 {
76 private:
77  enum
78  {
79  TEXT_NODE,
80  COMMENT_NODE
81  };
82 public:
85 
87  typedef std::pair<std::string, std::string> Attribute;
88 
90  struct NameSpace
91  {
92  NameSpace() {}
93  NameSpace(const std::string& p, const std::string& h="") :
94  prefix(p),
95  href(h) {}
96 
97  std::string prefix;
98  std::string href;
99  };
100 
102 
103 public:
106 
107  // forward decl.
108  class sibling_iterator;
110 
111  static constexpr size_t npos = std::numeric_limits<size_t>::max();
112 
118  {
119  public:
123  typedef std::string value_type;
126  typedef const std::string* pointer;
128  typedef const std::string& reference;
130  typedef ptrdiff_t difference_type;
132  typedef std::bidirectional_iterator_tag iterator_category;
133 
138 
144  const_attribute_iterator(_xmlNode* iNode, _xmlAttr* iAttribute);
145 
151  bool operator==(const const_attribute_iterator& other) const;
157  bool operator!=(const const_attribute_iterator& other) const;
166 
171  Attribute operator*() const;
176  std::string name() const;
181  std::string value() const;
186  NameSpace nameSpace() const;
187 
188  private:
190  _xmlNode* mNode;
192  _xmlAttr* mAttribute;
193  };
194 
200  {
201  public:
205  typedef std::string value_type;
208  typedef std::string* pointer;
210  typedef std::string& reference;
212  typedef ptrdiff_t difference_type;
214  typedef std::bidirectional_iterator_tag iterator_category;
215 
220 
226  attribute_iterator(_xmlNode* iNode, _xmlAttr* iAttribute);
227 
232  const attribute_iterator& operator=(const std::string& value);
238  bool operator==(const attribute_iterator& other) const;
244  bool operator!=(const attribute_iterator& other) const;
253 
258  Attribute operator*() const;
263  std::string name() const;
268  std::string value() const;
273  NameSpace nameSpace() const;
274 
275  private:
276  friend class sibling_iterator; // sibling_iterator needs direct access on in remove
277 
279  _xmlNode* mNode;
281  _xmlAttr* mAttribute;
282  };
283 
289  {
290  public:
294  using value_type = std::string;
297  using pointer = std::string *;
299  using reference = std::string &;
301  using difference_type = ptrdiff_t;
303  using iterator_category = std::bidirectional_iterator_tag;
304 
308  namespace_iterator() = default;
309 
315  namespace_iterator(_xmlNs* ns) : mNamespace(ns) {}
316 
321 
327  bool operator==(const namespace_iterator& other) const;
333  bool operator!=(const namespace_iterator& other) const;
334 
339  [[nodiscard]] std::string prefix() const;
344  [[nodiscard]] std::string href() const;
345 
346  private:
348  _xmlNs* mNamespace = nullptr;
349  };
350 
355  template <int Type>
357  {
358  public:
362  typedef std::string value_type;
365  typedef const std::string* pointer;
367  typedef const std::string& reference;
369  typedef ptrdiff_t difference_type;
371  typedef std::bidirectional_iterator_tag iterator_category;
372 
377 
382  const_data_iterator(_xmlNode* iNode);
383 
388  uint32 line() const;
389 
393  size_t position() const;
394 
400  bool operator==(const const_data_iterator& other) const;
406  bool operator!=(const const_data_iterator& other) const;
415 
420  std::string operator*() const;
421 
422  private:
423 
424  friend class sibling_iterator;
426  _xmlNode* mNode;
427  };
428 
432  template <int Type>
434  {
435  public:
439  typedef std::string value_type;
442  typedef std::string* pointer;
444  typedef std::string& reference;
446  typedef ptrdiff_t difference_type;
448  typedef std::bidirectional_iterator_tag iterator_category;
449 
450 
454  data_iterator();
455 
460  data_iterator(_xmlNode* iNode);
461 
466  const data_iterator& operator=(const std::string& value);
472  bool operator==(const data_iterator& other) const;
478  bool operator!=(const data_iterator& other) const;
487 
492  std::string operator*() const;
493 
498  data_iterator remove();
499 
500  private:
502  _xmlNode* mNode;
503  };
504 
528 
534  {
535  public:
541  iterator_base(_xmlNode* node, const std::string& name);
546  std::string operator*() const;
547 
551  void setName(const std::string& name);
552 
558  std::string uri() const;
559 
564  void setUri(const std::string& uri);
565 
570  NameSpace nameSpace() const;
571 
576  uint32 line() const;
577 
581  size_t position() const;
582 
592  const_sibling_iterator parent() const { return cparent(); }
602  const_sibling_iterator begin() const { return cbegin(); }
609  const_sibling_iterator cbegin(const std::string& name) const;
616  const_sibling_iterator begin(const std::string& name) const {
617  return cbegin(name);
618  }
628  const_sibling_iterator end() const { return cend(); }
649 
670 
686  {
687  return attribute_cbegin();
688  }
694  {
695  return attribute_cend();
696  }
702  const_attribute_iterator find_attribute(const std::string& name) const;
708  bool has_attribute(const std::string& name) const
709  {
710  return find_attribute(name) != attribute_end();
711  }
718  template <typename T>
719  T get_attribute(const std::string& name) const
720  {
722  if ( a == attribute_end() )
723  MIRA_THROW(XInvalidConfig, "The attribute '" << name
724  << "' could not be found in node '" << *(*this) << "'");
725  return fromString<T>((*a).second);
726  }
727 
736  template <typename T>
737  T get_attribute(const std::string& name, const T& defaultValue) const
738  {
740  if ( a == attribute_end() )
741  return defaultValue;
742  return fromString<T>((*a).second);
743  }
744 
746  [[nodiscard]] namespace_iterator ns_begin() const;
747 
749  [[nodiscard]] namespace_iterator ns_end() const;
750 
751  protected:
753  _xmlNode* mNode;
755  std::string mName;
756  };
757 
764  {
765  public:
769  friend class sibling_iterator;
771  typedef std::string value_type;
773  typedef const std::string* pointer;
775  typedef const std::string& reference;
777  typedef ptrdiff_t difference_type;
779  typedef std::bidirectional_iterator_tag iterator_category;
780 
789  const_sibling_iterator(_xmlNode* iNode, const std::string& name = "");
790 
796  iterator_base(other.mNode, other.mName)
797  {
798  }
799 
805  bool operator==(const const_sibling_iterator& other) const {
806  return mNode == other.mNode;
807  }
813  bool operator!=(const const_sibling_iterator& other) const {
814  return mNode != other.mNode;
815  }
823  const_sibling_iterator& operator+=(std::size_t increment);
827  const_sibling_iterator operator+(std::size_t increment) const;
832 
843  const_sibling_iterator find(const std::string& name, std::size_t nth = 0) const;
844  };
845 
851  {
852  public:
856  typedef std::string value_type;
859  typedef std::string* pointer;
861  typedef std::string& reference;
863  typedef ptrdiff_t difference_type;
865  typedef std::bidirectional_iterator_tag iterator_category;
866 
875  sibling_iterator(_xmlNode* iNode, const std::string& name = "");
876 
882  iterator_base(other.mNode, other.mName)
883  {
884  }
885 
891  bool operator==(const sibling_iterator& other) const {
892  return mNode == other.mNode;
893  }
899  bool operator!=(const sibling_iterator& other) const {
900  return mNode != other.mNode;
901  }
902 
906  operator const_sibling_iterator() const
907  {
909  }
910 
916  const sibling_iterator& operator=(const std::string& name);
924  sibling_iterator& operator+=(std::size_t increment);
928  sibling_iterator operator+(std::size_t increment) const;
933 
951  sibling_iterator begin(const std::string& name);
957 
968  sibling_iterator find(const std::string& name, std::size_t nth = 0);
969 
1005  attribute_iterator find_attribute(const std::string& name);
1018  XMLDom::sibling_iterator& add_attribute(const std::string& name,
1019  const std::string& value);
1026  template <typename T>
1027  XMLDom::sibling_iterator& add_attribute(const std::string& name, const T& value)
1028  {
1029  return add_attribute(name, toString(value));
1030  }
1031 
1040  template <typename T>
1041  XMLDom::sibling_iterator& add_attribute(const std::string& name, const T& value,
1042  int precision)
1043  {
1044  return add_attribute(name, toString(value,precision));
1045  }
1046 
1053 
1059  XMLDom::sibling_iterator& add_comment(const std::string& comment);
1065  XMLDom::sibling_iterator& add_content(const std::string& content);
1066 
1072  XMLDom::sibling_iterator& add_cdata_content(const std::string& cdata_content);
1073 
1079  XMLDom::sibling_iterator add_child(const std::string& name, const NameSpace& ns = NameSpace());
1097  XMLDom::sibling_iterator insert_before(const std::string& name, const NameSpace& ns = NameSpace());
1109  XMLDom::sibling_iterator insert_after(const std::string& name, const NameSpace& ns = NameSpace());
1121  XMLDom::sibling_iterator replace(const std::string& name, const NameSpace& ns = NameSpace());
1133  XMLDom::sibling_iterator& insert_comment_before(const std::string& comment);
1145  XMLDom::sibling_iterator& insert_comment_after(const std::string& comment);
1157  XMLDom::sibling_iterator& insert_content_before(const std::string& content);
1169  XMLDom::sibling_iterator& insert_content_after(const std::string& content);
1181  XMLDom::sibling_iterator replace_by_comment(const std::string& comment);
1193  XMLDom::sibling_iterator replace_by_content(const std::string& content);
1198  XMLDom::sibling_iterator remove();
1199  };
1200 
1202 
1206 
1207 public:
1210 
1215  XMLDom(const std::string& rootNodeName = "root");
1216 
1218  ~XMLDom();
1219 
1221  XMLDom(XMLDom&& other) noexcept;
1222 
1224  XMLDom& operator=(XMLDom&& other) noexcept;
1225 
1227 
1228 public:
1229 
1238  void clear();
1239 
1243  XMLDom clone();
1244 
1245 public:
1248 
1254  void loadFromString(const std::string& buffer);
1255 
1264  void loadFromFile(const Path& filename,
1265  bool resolve = true);
1266 
1276  void saveToFile(const Path& filename,
1277  const std::string& encoding = "UTF-8",
1278  bool resolve = true) const;
1279 
1288  void saveToFile(const Path& filename,
1289  bool resolve) const;
1290 
1298  std::string saveToString(const std::string& encoding = "UTF-8") const;
1299 
1301 
1302 public:
1305 
1307  const_sibling_iterator croot() const;
1308 
1310  const_sibling_iterator root() const { return croot(); }
1311 
1313  sibling_iterator root();
1314 
1316 
1321  std::string uri() const;
1325  void setUri(const std::string& uri);
1326 
1331  std::string encoding() const;
1332 
1333 private:
1335  void loadFromPath(const Path& filename);
1336 
1338  void saveToPath(const Path& filename,
1339  const std::string& encoding) const;
1340 
1341  _xmlDoc* mXMLDocument;
1342 };
1343 
1345 
1346 }
1347 
1348 #endif
bool operator==(const attribute_iterator &other) const
Compare two attribute iterators.
std::string value_type
STL-conform typedefs.
Definition: XMLDom.h:857
T get_attribute(const std::string &name) const
Return an attribute value cast to a given type.
Definition: XMLDom.h:719
std::string value_type
STL-conform typedefs.
Definition: XMLDom.h:124
const_attribute_iterator & operator--()
Predecrement.
XMLDom & operator=(XMLDom &&other) noexcept
Move assignment operator.
_xmlNode * mNode
The node pointer.
Definition: XMLDom.h:753
const_attribute_iterator attribute_begin() const
Get the const iterator to the first attribute.
Definition: XMLDom.h:685
std::string value_type
STL-conform typedefs.
Definition: XMLDom.h:440
Iterator for iterating over data nodes.
Definition: XMLDom.h:433
const_sibling_iterator root() const
Return a const sibling_iterator to the root node of the XML document.
Definition: XMLDom.h:1310
A STL conform wrapper for libxml2 to read XML files as DOM.
Definition: XMLDom.h:74
XMLDom::sibling_iterator & insert_content_after(const XMLDom::const_content_iterator &content)
Insert content after this node.
bool has_attribute(const std::string &name) const
Returns true if node contains the attribute with name name.
Definition: XMLDom.h:708
sibling_iterator & operator--()
Predecrement.
namespace_iterator()=default
Constructor.
const_sibling_iterator cparent() const
Get the const parent node sibling_iterator for this node.
void saveToFile(const Path &filename, const std::string &encoding="UTF-8", bool resolve=true) const
Save the XML document to a file.
const std::string & reference
The reference type.
Definition: XMLDom.h:367
ptrdiff_t difference_type
The difference type.
Definition: XMLDom.h:130
std::string * pointer
The pointer type.
Definition: XMLDom.h:442
const_sibling_iterator end() const
Get the const end node sibling_iterator.
Definition: XMLDom.h:628
std::string & reference
The reference type.
Definition: XMLDom.h:861
Attribute operator*() const
Dereference operator to Attribute.
attribute_iterator find_attribute(const std::string &name)
Find an attribute with the name name.
data_iterator< COMMENT_NODE > comment_iterator
The iterator for comments.
Definition: XMLDom.h:522
std::string encoding() const
Get the initial encoding of the document.
Const iterator for iterating over data nodes.
Definition: XMLDom.h:356
bool operator==(const data_iterator &other) const
Compare two iterators.
std::string uri() const
Return the uri of the node.
attribute_iterator attribute_begin()
Get the iterator to the first attribute.
std::string & reference
The reference type.
Definition: XMLDom.h:444
const_sibling_iterator operator+(std::size_t increment) const
Increment by given value.
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
boost::filesystem::path Path
Typedef of a Path (shorter version for boost::filesystem::path)
Definition: Path.h:69
std::string value_type
The value type.
Definition: XMLDom.h:771
const std::string & reference
The reference type.
Definition: XMLDom.h:775
std::bidirectional_iterator_tag iterator_category
The iterator category.
Definition: XMLDom.h:779
const_content_iterator content_end() const
Get the const end content iterator.
Definition: XMLDom.h:648
std::string * pointer
The pointer type.
Definition: XMLDom.h:208
ptrdiff_t difference_type
The difference type.
Definition: XMLDom.h:301
content_iterator content_begin()
Get the iterator to the first content.
sibling_iterator operator+(std::size_t increment) const
Increment by given value.
XMLDom::sibling_iterator insert_before(const XMLDom::const_sibling_iterator &node)
Inserts a given node before this node.
void setUri(const std::string &uri)
Set the uri of the node.
attribute_iterator attribute_end()
Get the end attribute iterator.
const std::string * pointer
The pointer type.
Definition: XMLDom.h:773
data_iterator & operator++()
Preincrement.
const_comment_iterator comment_end() const
Get the const end comment iterator.
Definition: XMLDom.h:669
NameSpace nameSpace() const
Return the namespace information of the node.
uint32_t uint32
Definition: Types.h:64
Iterator for iterating over attributes.
Definition: XMLDom.h:199
Contains toString and fromString functions for converting data types to strings and the other way rou...
NameSpace(const std::string &p, const std::string &h="")
Definition: XMLDom.h:93
bool operator==(const const_sibling_iterator &other) const
Compare two iterators.
Definition: XMLDom.h:805
const_content_iterator content_begin() const
Get the const iterator to the first content.
Definition: XMLDom.h:643
namespace_iterator & operator++()
Preincrement.
void loadFromFile(const Path &filename, bool resolve=true)
Load and parse an XML document from a file.
const_data_iterator< TEXT_NODE > const_content_iterator
The const iterator for content.
Definition: XMLDom.h:517
ptrdiff_t difference_type
The difference type.
Definition: XMLDom.h:446
attribute_iterator & operator--()
Predecrement.
sibling_iterator end()
Get the end node sibling_iterator.
const_sibling_iterator & operator--()
Predecrement.
static constexpr size_t npos
Definition: XMLDom.h:111
sibling_iterator find(const std::string &name, std::size_t nth=0)
Find the nth subnode with a given name.
const_sibling_iterator & operator+=(std::size_t increment)
Increment self by given value.
const_sibling_iterator & operator++()
Preincrement.
std::string name() const
Get the name of the attribute.
Base iterator for iterating over xml nodes with the same parent (siblings)
Definition: XMLDom.h:533
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:78
Attribute operator*() const
Dereference operator Attribute.
const_sibling_iterator begin(const std::string &name) const
Get the const sibling_same_name_iterator to the first sub node with the given name.
Definition: XMLDom.h:616
bool operator!=(const namespace_iterator &other) const
Compare two iterators.
std::string toString(const T &value, int precision=-1)
Converts any data type to string (the data type must support the stream << operator).
Definition: ToString.h:252
void clear()
Clears the whole content of this XMLDom document, i.e.
std::string uri() const
Get the URL of the document (i.e.
Const sibling_iterator for iterating over xml nodes that have the same parent (siblings) ...
Definition: XMLDom.h:763
sibling_iterator iterator
typedefs for backward compatibility
Definition: XMLDom.h:1204
const_attribute_iterator & operator++()
Preincrement.
std::string value() const
Get the value of the attribute.
sibling_iterator begin()
Get the sibling_iterator to the first sub node.
namespace_iterator(_xmlNs *ns)
Constructor.
Definition: XMLDom.h:315
NameSpace nameSpace() const
Return the namespace information of the attribute.
Const iterator for iterating over attributes.
Definition: XMLDom.h:117
XMLDom::sibling_iterator & add_content(const std::string &content)
Add content to this node.
Namespace information of a node.
Definition: XMLDom.h:90
const std::string * pointer
The pointer type.
Definition: XMLDom.h:365
Iterator for iterating over xmlns declarations.
Definition: XMLDom.h:288
bool operator==(const const_data_iterator &other) const
Compare two iterators.
const std::string & reference
The reference type.
Definition: XMLDom.h:128
bool operator!=(const data_iterator &other) const
Compare two iterators.
Commonly used exception classes.
std::pair< std::string, std::string > Attribute
An XML attribute.
Definition: XMLDom.h:87
bool operator!=(const sibling_iterator &other) const
Compare two iterators.
Definition: XMLDom.h:899
std::string operator*() const
Dereference operator to std::string.
XMLDom::sibling_iterator & add_cdata_content(const std::string &cdata_content)
Add a cdata content block to this node.
std::bidirectional_iterator_tag iterator_category
The iterator category.
Definition: XMLDom.h:303
const_data_iterator & operator++()
Preincrement.
XMLDom::sibling_iterator & add_attribute(const Attribute &attribute)
Add an attribute to this node.
const_sibling_iterator(const const_sibling_iterator &other)
Copy-constructor.
Definition: XMLDom.h:795
std::string value_type
STL-conform typedefs.
Definition: XMLDom.h:206
std::bidirectional_iterator_tag iterator_category
The iterator category.
Definition: XMLDom.h:371
XMLDom::sibling_iterator & insert_content_before(const XMLDom::const_content_iterator &content)
Insert content before this node.
std::string href() const
Get the href of the ns.
NameSpace nameSpace() const
Return the namespace information of the node.
const attribute_iterator & operator=(const std::string &value)
Set the value of the attribute.
const_attribute_iterator attribute_cend() const
Get the const end attribute iterator.
std::bidirectional_iterator_tag iterator_category
The iterator category.
Definition: XMLDom.h:448
const_data_iterator & operator--()
Predecrement.
const_sibling_iterator begin() const
Get the const sibling_iterator to the first sub node.
Definition: XMLDom.h:602
sibling_iterator()
Default-constructor.
const_sibling_iterator cend() const
Get the const end node sibling_iterator.
const std::string * pointer
The pointer type.
Definition: XMLDom.h:126
XMLDom::sibling_iterator & add_comment(const std::string &comment)
Add a comment to this node.
uint32 line() const
Gets the underlying line number of the loaded document for this node.
namespace_iterator ns_end() const
XMLDom::sibling_iterator & insert_comment_before(const XMLDom::const_comment_iterator &comment)
Insert a comment before this node.
Iterator for iterating over xml nodes that have the same parent (sibligs)
Definition: XMLDom.h:850
std::string mName
the node name (optional)
Definition: XMLDom.h:755
bool operator==(const const_attribute_iterator &other) const
Compare two attribute iterators.
NameSpace()
Definition: XMLDom.h:92
XMLDom::sibling_iterator & add_attribute(const std::string &name, const T &value)
Add an attribute to this node.
Definition: XMLDom.h:1027
bool operator!=(const attribute_iterator &other) const
Compare two attribute iterators.
std::string value() const
Get the value of the attribute.
const_comment_iterator comment_cend() const
Get the const end comment iterator.
ptrdiff_t difference_type
The difference type.
Definition: XMLDom.h:863
XMLDom(const std::string &rootNodeName="root")
Constructor for creating a new empty document.
const_comment_iterator comment_cbegin() const
Get the const iterator to the first comment.
~XMLDom()
Destructor.
content_iterator content_end()
Get the end content iterator.
data_iterator< TEXT_NODE > content_iterator
The iterator for content.
Definition: XMLDom.h:527
comment_iterator comment_begin()
Get the iterator to the first comment.
void setUri(const std::string &uri)
Set the URL of the document (i.e.
std::string prefix() const
Get the prefix of the ns.
bool operator!=(const const_data_iterator &other) const
Compare two iterators.
const_sibling_iterator cbegin() const
Get the const sibling_iterator to the first sub node.
const_attribute_iterator attribute_cbegin() const
Get the const iterator to the first attribute.
const data_iterator & operator=(const std::string &value)
Set the data value of the node.
const_sibling_iterator const_iterator
Definition: XMLDom.h:1205
const_sibling_iterator parent() const
Get the const parent node sibling_iterator for this node.
Definition: XMLDom.h:592
std::string & reference
The reference type.
Definition: XMLDom.h:210
sibling_iterator & operator+=(std::size_t increment)
Increment self by given value.
uint32 line() const
Gets the underlying line number of the loaded document for this node.
std::bidirectional_iterator_tag iterator_category
The iterator category.
Definition: XMLDom.h:214
T get_attribute(const std::string &name, const T &defaultValue) const
Return an attribute value casted to a given type If the attribute could not be found the given defaul...
Definition: XMLDom.h:737
ptrdiff_t difference_type
The difference type.
Definition: XMLDom.h:777
std::string prefix
Definition: XMLDom.h:97
sibling_iterator(const sibling_iterator &other)
Copy-constructor.
Definition: XMLDom.h:881
sibling_iterator parent()
Get the parent node sibling_iterator for this node.
Functions for modifying file system paths.
const_content_iterator content_cend() const
Get the const end content iterator.
std::string * pointer
The pointer type.
Definition: XMLDom.h:297
void remove_attribute(attribute_iterator it)
Removes the attribute the given iterator points on from this node, if it exists.
PropertyHint precision(int p)
Sets the attribute "precision".
Definition: PropertyHint.h:285
const_attribute_iterator find_attribute(const std::string &name) const
Find an attribute with the name name.
std::string name() const
Get the name of the attribute.
std::string operator*() const
Dereference operator to get the name of the node.
comment_iterator comment_end()
Get the end comment sibling_iterator.
std::string & reference
The reference type.
Definition: XMLDom.h:299
XMLDom::sibling_iterator add_child(const std::string &name, const NameSpace &ns=NameSpace())
Add a sub node to this node.
XMLDom::sibling_iterator replace_by_content(const XMLDom::const_content_iterator &node)
Replaces this node by content node.
const_content_iterator content_cbegin() const
Get the const iterator to the first content.
XMLDom::sibling_iterator insert_after(const XMLDom::const_sibling_iterator &node)
Inserts a given node after this node.
namespace_iterator ns_begin() const
iterator_base(_xmlNode *node, const std::string &name)
Constructor.
std::string value_type
STL-conform typedefs.
Definition: XMLDom.h:295
XMLDom clone()
Create and return a copy of the document.
bool operator==(const namespace_iterator &other) const
Compare two iterators.
void loadFromString(const std::string &buffer)
Load and parse an XML document from memory.
std::string * pointer
The pointer type.
Definition: XMLDom.h:859
attribute_iterator & operator++()
Preincrement.
void setName(const std::string &name)
Change the node&#39;s name.
const_data_iterator< COMMENT_NODE > const_comment_iterator
STL-conform typedefs.
Definition: XMLDom.h:512
bool operator!=(const const_sibling_iterator &other) const
Compare two iterators.
Definition: XMLDom.h:813
bool operator!=(const const_attribute_iterator &other) const
Compare two attribute iterators.
std::string value_type
STL-conform typedefs.
Definition: XMLDom.h:363
std::string href
Definition: XMLDom.h:98
sibling_iterator & operator++()
Preincrement.
const_attribute_iterator attribute_end() const
Get the const end attribute iterator.
Definition: XMLDom.h:693
ptrdiff_t difference_type
The difference type.
Definition: XMLDom.h:369
XMLDom::sibling_iterator & add_attribute(const std::string &name, const T &value, int precision)
Add an attribute to this node.
Definition: XMLDom.h:1041
ptrdiff_t difference_type
The difference type.
Definition: XMLDom.h:212
data_iterator()
Constructor.
XMLDom::sibling_iterator replace_by_comment(const XMLDom::const_comment_iterator &node)
Replaces this node by comment node.
const_sibling_iterator croot() const
Return a const sibling_iterator to the root node of the XML document.
bool operator==(const sibling_iterator &other) const
Compare two iterators.
Definition: XMLDom.h:891
XMLDom::sibling_iterator replace(const XMLDom::const_sibling_iterator &node)
Replaces this node by a recursive copy of iNode.
const_comment_iterator comment_begin() const
Get the const iterator to the first comment.
Definition: XMLDom.h:664
std::string saveToString(const std::string &encoding="UTF-8") const
Save the XML document to a string.
XMLDom::sibling_iterator & insert_comment_after(const XMLDom::const_comment_iterator &comment)
Insert a comment after this node.
const sibling_iterator & operator=(const std::string &name)
Change the name of this node.
data_iterator & operator--()
Predecrement.
std::bidirectional_iterator_tag iterator_category
The iterator category.
Definition: XMLDom.h:132
std::bidirectional_iterator_tag iterator_category
The iterator category.
Definition: XMLDom.h:865
std::string operator*() const
Dereference operator to std::string.
const_sibling_iterator find(const std::string &name, std::size_t nth=0) const
Find the nth subnode with a given name.