MIRA
|
A STL conform wrapper for libxml2 to read XML files as DOM. More...
#include <xml/XMLDom.h>
Classes | |
class | attribute_iterator |
Iterator for iterating over attributes. More... | |
class | const_attribute_iterator |
Const iterator for iterating over attributes. More... | |
class | const_data_iterator |
Const iterator for iterating over data nodes. More... | |
class | const_sibling_iterator |
Const sibling_iterator for iterating over xml nodes that have the same parent (siblings) More... | |
class | data_iterator |
Iterator for iterating over data nodes. More... | |
class | iterator_base |
Base iterator for iterating over xml nodes with the same parent (siblings) More... | |
struct | NameSpace |
Namespace information of a node. More... | |
class | sibling_iterator |
Iterator for iterating over xml nodes that have the same parent (sibligs) More... | |
Public Types | |
typedef sibling_iterator | iterator |
typedefs for backward compatibility More... | |
typedef const_sibling_iterator | const_iterator |
Public types. | |
typedef std::pair< std::string, std::string > | Attribute |
An XML attribute. More... | |
Public Member Functions | |
void | clear () |
Clears the whole content of this XMLDom document, i.e. More... | |
std::string | uri () const |
Get the URL of the document (i.e. More... | |
void | setUri (const std::string &uri) |
Set the URL of the document (i.e. More... | |
std::string | encoding () const |
Get the initial encoding of the document. More... | |
Constructor and destructor. | |
XMLDom (const std::string &rootNodeName="root") | |
Constructor for creating a new empty document. More... | |
~XMLDom () | |
Destructor. More... | |
XMLDom (XMLDom &&other) noexcept | |
Move constructor. More... | |
XMLDom & | operator= (XMLDom &&other) noexcept |
Move assignment operator. More... | |
I/O operations. | |
void | loadFromString (const std::string &buffer) |
Load and parse an XML document from memory. More... | |
void | loadFromFile (const Path &filename, bool resolve=true) |
Load and parse an XML document from a file. More... | |
void | saveToFile (const Path &filename, const std::string &encoding="UTF-8", bool resolve=true) const |
Save the XML document to a file. More... | |
void | saveToFile (const Path &filename, bool resolve) const |
Save the XML document to a file, using encoding UTF-8. More... | |
std::string | saveToString (const std::string &encoding="UTF-8") const |
Save the XML document to a string. More... | |
Iterators. | |
const_sibling_iterator | croot () const |
Return a const sibling_iterator to the root node of the XML document. More... | |
const_sibling_iterator | root () const |
Return a const sibling_iterator to the root node of the XML document. More... | |
sibling_iterator | root () |
Return a sibling_iterator to the root node of the XML document. More... | |
Iterator types. | |
typedef const_data_iterator< COMMENT_NODE > | const_comment_iterator |
STL-conform typedefs. More... | |
typedef const_data_iterator< TEXT_NODE > | const_content_iterator |
The const iterator for content. More... | |
typedef data_iterator< COMMENT_NODE > | comment_iterator |
The iterator for comments. More... | |
typedef data_iterator< TEXT_NODE > | content_iterator |
The iterator for content. More... | |
class MIRA_BASE_EXPORT | sibling_iterator |
class MIRA_BASE_EXPORT | const_sibling_iterator |
A STL conform wrapper for libxml2 to read XML files as DOM.
typedef std::pair<std::string, std::string> Attribute |
An XML attribute.
typedef sibling_iterator iterator |
typedefs for backward compatibility
typedef const_sibling_iterator const_iterator |
XMLDom | ( | const std::string & | rootNodeName = "root" | ) |
Constructor for creating a new empty document.
The name of the root node can specified as optional parameter. The default name is "root".
~XMLDom | ( | ) |
Destructor.
void clear | ( | ) |
void loadFromString | ( | const std::string & | buffer | ) |
Load and parse an XML document from memory.
XIO | if the document could not be loaded. |
[in] | buffer | The buffer. |
void loadFromFile | ( | const Path & | filename, |
bool | resolve = true |
||
) |
Load and parse an XML document from a file.
XFileNotFound | if file is not found. |
XIO | if the file/document could not be loaded. |
[in] | filename | The file name. |
[in] | resolve | Should the filename be resolved (resolvePath())? Set to false if already resolved. |
void saveToFile | ( | const Path & | filename, |
const std::string & | encoding = "UTF-8" , |
||
bool | resolve = true |
||
) | const |
Save the XML document to a file.
XInvalidConfig | if the document is empty. |
XIO | if the file could not be saved. |
[in] | filename | The file name. |
[in] | encoding | The desired encoding. |
[in] | resolve | Should the filename be resolved (resolvePath())? Set to false if already resolved. |
void saveToFile | ( | const Path & | filename, |
bool | resolve | ||
) | const |
Save the XML document to a file, using encoding UTF-8.
XInvalidConfig | if the document is empty. |
XIO | if the file could not be saved. |
[in] | filename | The file name. |
[in] | resolve | Should the filename be resolved (resolvePath())? Set to false if already resolved. |
std::string saveToString | ( | const std::string & | encoding = "UTF-8" | ) | const |
Save the XML document to a string.
XInvalidConfig | if the document is empty. |
XIO | if the file could not be saved. |
[in] | encoding | The desired encoding. |
const_sibling_iterator croot | ( | ) | const |
Return a const sibling_iterator to the root node of the XML document.
|
inline |
Return a const sibling_iterator to the root node of the XML document.
sibling_iterator root | ( | ) |
Return a sibling_iterator to the root node of the XML document.
std::string uri | ( | ) | const |
Get the URL of the document (i.e.
the filename if loaded from file)
void setUri | ( | const std::string & | uri | ) |
Set the URL of the document (i.e.
the filename if loaded from file)
std::string encoding | ( | ) | const |
Get the initial encoding of the document.