ADTF
Loading...
Searching...
No Matches
a_util::xml::DOM Class Reference

XML parser to read and write standard XML files. More...

#include <dom.h>

Public Member Functions

 DOM ()
 CTOR.
 
 ~DOM ()
 DTOR.
 
 DOM (const DOM &dom)
 
DOMoperator= (const DOM &dom)
 
bool load (const std::string &file_path)
 
bool save (const std::string &file_path) const
 
bool fromString (const std::string &xml)
 
std::string toString () const
 
void reset ()
 
DOMElement getRoot () const
 
bool findNode (const std::string &query, DOMElement &element_ptr) const
 
bool findNodes (const std::string &query, DOMElementList &elements) const
 
std::string getLastError () const
 
bool isNull () const
 

Friends

class DOMElement
 

Detailed Description

XML parser to read and write standard XML files.

Constructor & Destructor Documentation

◆ DOM()

a_util::xml::DOM::DOM ( const DOM & dom)

Copy constructor

Parameters
[in]domThe object to copy from

Member Function Documentation

◆ findNode()

bool a_util::xml::DOM::findNode ( const std::string & query,
DOMElement & element_ptr ) const

Finds a node based on a query See DOMElement::findNode() for the syntax.

Parameters
[in]queryThe query string
[out]element_ptrThis will point to the found element.
Returns
Whether or not the node was found

◆ findNodes()

bool a_util::xml::DOM::findNodes ( const std::string & query,
DOMElementList & elements ) const

Finds nodes based on a query. See DOMElement::findNode() for the syntax.

Parameters
[in]queryThe query string
[out]elementsThis list will be filled with the found elements
Returns
Whether or not any nodes where found

◆ fromString()

bool a_util::xml::DOM::fromString ( const std::string & xml)

Create the dom from an input string

Parameters
[in]xmlString which must have a valid XML syntax
Returns
false string is invalid (check DOM::getLastError()), otherwise true

◆ getLastError()

std::string a_util::xml::DOM::getLastError ( ) const

Get the last error description occurred

Returns
The last occurred error

◆ getRoot()

DOMElement a_util::xml::DOM::getRoot ( ) const

Get root element of the dom

Returns
The root element of the dom

◆ isNull()

bool a_util::xml::DOM::isNull ( ) const

Check whether this DOM is empty

Returns
true if empty, false otherwise

◆ load()

bool a_util::xml::DOM::load ( const std::string & file_path)

Loads an xml file

Parameters
[in]file_pathPath to the filename
Returns
false if file could not be loaded (check DOM::getLastError()), otherwise true

◆ operator=()

DOM & a_util::xml::DOM::operator= ( const DOM & dom)

Copy assignment

Parameters
[in]domThe element to copy from
Returns
Reference to *this

◆ reset()

void a_util::xml::DOM::reset ( )

Resets the instance to the empty state

Postcondition
this->IsNull()

◆ save()

bool a_util::xml::DOM::save ( const std::string & file_path) const

save document to an xml file

Parameters
[in]file_pathPath to the file to save
Returns
false if file could not be safed (check DOM::getLastError()), otherwise true

◆ toString()

std::string a_util::xml::DOM::toString ( ) const

Creates an xml string representation of the dom

Returns
XML string representation of the dom

The documentation for this class was generated from the following file: