47 #ifndef _MIRA_XMLDOM_H_ 48 #define _MIRA_XMLDOM_H_ 53 #include <boost/noncopyable.hpp> 86 typedef std::pair<std::string, std::string>
Attribute;
92 NameSpace(
const std::string& p,
const std::string& h=
"") :
173 std::string name()
const;
178 std::string value()
const;
189 _xmlAttr* mAttribute;
260 std::string name()
const;
265 std::string value()
const;
278 _xmlAttr* mAttribute;
339 std::string operator*()
const;
411 std::string operator*()
const;
465 std::string operator*()
const;
470 void setName(
const std::string& name);
477 std::string uri()
const;
483 void setUri(
const std::string& uri);
601 return attribute_cbegin();
609 return attribute_cend();
624 return find_attribute(name) != attribute_end();
632 template <
typename T>
636 if ( a == attribute_end() )
637 MIRA_THROW(XInvalidConfig,
"The attribute '" << name
638 <<
"' could not be found in node '" << *(*
this) <<
"'");
639 return fromString<T>((*a).second);
650 template <
typename T>
654 if ( a == attribute_end() )
656 return fromString<T>((*a).second);
714 return mNode == other.
mNode;
722 return mNode != other.
mNode;
800 return mNode == other.
mNode;
808 return mNode != other.
mNode;
927 const std::string& value);
934 template <
typename T>
937 return add_attribute(name,
toString(value));
948 template <
typename T>
1123 XMLDom(
const std::string& rootNodeName =
"root");
1157 void loadFromString(
const std::string& buffer);
1167 void loadFromFile(
const Path& filename,
1168 bool resolve =
true);
1179 void saveToFile(
const Path& filename,
1180 const std::string& encoding =
"UTF-8",
1181 bool resolve =
true)
const;
1191 void saveToFile(
const Path& filename,
1192 bool resolve)
const;
1201 std::string saveToString(
const std::string& encoding =
"UTF-8")
const;
1216 sibling_iterator root();
1224 std::string uri()
const;
1228 void setUri(
const std::string& uri);
1234 std::string encoding()
const;
1238 void loadFromPath(
const Path& filename);
1241 void saveToPath(
const Path& filename,
1242 const std::string& encoding)
const;
1244 _xmlDoc* mXMLDocument;
std::string value_type
STL-conform typedefs.
Definition: XMLDom.h:765
T get_attribute(const std::string &name) const
Return an attribute value cast to a given type.
Definition: XMLDom.h:633
std::string value_type
STL-conform typedefs.
Definition: XMLDom.h:121
_xmlNode * mNode
The node pointer.
Definition: XMLDom.h:661
const_attribute_iterator attribute_begin() const
Get the const iterator to the first attribute.
Definition: XMLDom.h:599
std::string value_type
STL-conform typedefs.
Definition: XMLDom.h:359
Iterator for iterating over data nodes.
Definition: XMLDom.h:352
const_sibling_iterator root() const
Return a const sibling_iterator to the root node of the XML document.
Definition: XMLDom.h:1213
A STL conform wrapper for libxml2 to read XML files as DOM.
Definition: XMLDom.h:73
bool has_attribute(const std::string &name) const
Returns true if node contains the attribute with name name.
Definition: XMLDom.h:622
Typedefs for OS independent basic data types.
const std::string & reference
The reference type.
Definition: XMLDom.h:297
ptrdiff_t difference_type
The difference type.
Definition: XMLDom.h:127
std::string * pointer
The pointer type.
Definition: XMLDom.h:361
const_sibling_iterator end() const
Get the const end node sibling_iterator.
Definition: XMLDom.h:542
std::string & reference
The reference type.
Definition: XMLDom.h:769
data_iterator< COMMENT_NODE > comment_iterator
The iterator for comments.
Definition: XMLDom.h:441
Const iterator for iterating over data nodes.
Definition: XMLDom.h:286
std::string & reference
The reference type.
Definition: XMLDom.h:363
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:679
const std::string & reference
The reference type.
Definition: XMLDom.h:683
std::bidirectional_iterator_tag iterator_category
The iterator category.
Definition: XMLDom.h:687
const_content_iterator content_end() const
Get the const end content iterator.
Definition: XMLDom.h:562
std::string * pointer
The pointer type.
Definition: XMLDom.h:205
const std::string * pointer
The pointer type.
Definition: XMLDom.h:681
const_comment_iterator comment_end() const
Get the const end comment iterator.
Definition: XMLDom.h:583
Iterator for iterating over attributes.
Definition: XMLDom.h:196
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:92
bool operator==(const const_sibling_iterator &other) const
Compare two iterators.
Definition: XMLDom.h:713
const_content_iterator content_begin() const
Get the const iterator to the first content.
Definition: XMLDom.h:557
const_data_iterator< TEXT_NODE > const_content_iterator
The const iterator for content.
Definition: XMLDom.h:436
ptrdiff_t difference_type
The difference type.
Definition: XMLDom.h:365
Base iterator for iterating over xml nodes with the same parent (siblings)
Definition: XMLDom.h:452
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:82
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:530
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:256
Const sibling_iterator for iterating over xml nodes that have the same parent (siblings) ...
Definition: XMLDom.h:671
sibling_iterator iterator
typedefs for backward compatibility
Definition: XMLDom.h:1112
Const iterator for iterating over attributes.
Definition: XMLDom.h:114
Namespace information of a node.
Definition: XMLDom.h:89
const std::string * pointer
The pointer type.
Definition: XMLDom.h:295
const std::string & reference
The reference type.
Definition: XMLDom.h:125
Commonly used exception classes.
std::pair< std::string, std::string > Attribute
An XML attribute.
Definition: XMLDom.h:86
bool operator!=(const sibling_iterator &other) const
Compare two iterators.
Definition: XMLDom.h:807
const_sibling_iterator(const const_sibling_iterator &other)
Copy-constructor.
Definition: XMLDom.h:703
std::string value_type
STL-conform typedefs.
Definition: XMLDom.h:203
std::bidirectional_iterator_tag iterator_category
The iterator category.
Definition: XMLDom.h:301
std::bidirectional_iterator_tag iterator_category
The iterator category.
Definition: XMLDom.h:367
const_sibling_iterator begin() const
Get the const sibling_iterator to the first sub node.
Definition: XMLDom.h:516
const std::string * pointer
The pointer type.
Definition: XMLDom.h:123
bool operator==(const ImgIteratorBase &a, const ImgIteratorBase &b)
Definition: ImgIterator.h:225
Iterator for iterating over xml nodes that have the same parent (sibligs)
Definition: XMLDom.h:758
std::string mName
the node name (optional)
Definition: XMLDom.h:663
NameSpace()
Definition: XMLDom.h:91
XMLDom::sibling_iterator & add_attribute(const std::string &name, const T &value)
Add an attribute to this node.
Definition: XMLDom.h:935
ptrdiff_t difference_type
The difference type.
Definition: XMLDom.h:771
data_iterator< TEXT_NODE > content_iterator
The iterator for content.
Definition: XMLDom.h:446
const_sibling_iterator const_iterator
Definition: XMLDom.h:1113
const_sibling_iterator parent() const
Get the const parent node sibling_iterator for this node.
Definition: XMLDom.h:506
std::string & reference
The reference type.
Definition: XMLDom.h:207
std::bidirectional_iterator_tag iterator_category
The iterator category.
Definition: XMLDom.h:211
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:651
ptrdiff_t difference_type
The difference type.
Definition: XMLDom.h:685
std::string prefix
Definition: XMLDom.h:96
sibling_iterator(const sibling_iterator &other)
Copy-constructor.
Definition: XMLDom.h:789
Functions for modifying file system paths.
PropertyHint precision(int p)
Sets the attribute "precision".
Definition: PropertyHint.h:285
bool operator!=(const ImgIteratorBase &a, const ImgIteratorBase &b)
Definition: ImgIterator.h:228
std::string * pointer
The pointer type.
Definition: XMLDom.h:767
const_data_iterator< COMMENT_NODE > const_comment_iterator
STL-conform typedefs.
Definition: XMLDom.h:431
bool operator!=(const const_sibling_iterator &other) const
Compare two iterators.
Definition: XMLDom.h:721
std::string value_type
STL-conform typedefs.
Definition: XMLDom.h:293
std::string href
Definition: XMLDom.h:97
const_attribute_iterator attribute_end() const
Get the const end attribute iterator.
Definition: XMLDom.h:607
ptrdiff_t difference_type
The difference type.
Definition: XMLDom.h:299
XMLDom::sibling_iterator & add_attribute(const std::string &name, const T &value, int precision)
Add an attribute to this node.
Definition: XMLDom.h:949
ptrdiff_t difference_type
The difference type.
Definition: XMLDom.h:209
bool operator==(const sibling_iterator &other) const
Compare two iterators.
Definition: XMLDom.h:799
const_comment_iterator comment_begin() const
Get the const iterator to the first comment.
Definition: XMLDom.h:578
std::bidirectional_iterator_tag iterator_category
The iterator category.
Definition: XMLDom.h:129
std::bidirectional_iterator_tag iterator_category
The iterator category.
Definition: XMLDom.h:773