ADTF
3.18.2
|
Representation for an element in the DOM. More...
Public Member Functions | |
DOMElement () | |
CTOR. | |
~DOMElement () | |
DTOR. | |
DOMElement (const DOMElement &element) | |
Copy constructor. More... | |
DOMElement & | operator= (const DOMElement &element) |
Copy assignment operator. More... | |
std::string | getAttribute (const std::string &name, const std::string &def_value=std::string()) const |
Returns the value of an attribute with name . More... | |
DOMAttributes | getAttributes () const |
Get a map of all attributes of this element. More... | |
DOMElement | getChild (const std::string &name) const |
Get the first child mathing the name of this element. More... | |
DOMElementList | getChildren () const |
Get a list of all child elements of the element. More... | |
std::string | getData () const |
Get the data of the element. More... | |
DOM | getDocument () const |
Get the DOM document this element belongs to. More... | |
std::string | getName () const |
Get the name of the element. More... | |
DOMElement | getParent () const |
Get this elements parent element. More... | |
std::string | getPath () const |
Get current path of the element. More... | |
bool | setAttribute (const std::string &name, const std::string &strValue) |
Sets an attribute. More... | |
bool | setData (const std::string &data) |
Sets the data of the element. More... | |
bool | setName (const std::string &name) |
Sets the name of the element. More... | |
bool | hasAttribute (const std::string &name) const |
Checks if an attribute exists. More... | |
bool | eraseAttribute (const std::string &name) |
Removes an attribute. More... | |
bool | findNode (const std::string &query, DOMElement &element_ptr) const |
Finds a node based on a query. More... | |
bool | findNodes (const std::string &query, DOMElementList &elements) const |
Finds nodes based on a query. More... | |
bool | sortNodes (const std::string &query, SortingOrder order) |
Sort the queried nodes by name example: More... | |
bool | sortNodes (const std::string &query, SortingOrder order, std::size_t number_of_nodes) |
Sort all queried nodes by name example: More... | |
std::size_t | sortNodes (const std::string &query, const std::string &attribute, SortingOrder order) |
Sort the queried nodes by attribute example: More... | |
bool | sortNodes (const std::string &query, const std::string &attribute, SortingOrder order, std::size_t number_of_nodes) |
Sort all queried nodes by attribute example: More... | |
DOMElement | createChild (const std::string &name) |
Creates a new child element. More... | |
DOMElement | createChildBefore (const std::string &name, const DOMElement &before) |
Creates a new child element before an existing child element. More... | |
bool | removeChild (const std::string &name) |
Erases the first child of that name in this element. More... | |
bool | isNull () const |
Check whether this DOMElement is empty. More... | |
Private Attributes | |
memory::StackPtr< Implementation, 16 > | _impl |
Representation for an element in the DOM.
Definition at line 47 of file workspace/conan/dev_essential/1.3.3/dw/stable/package/37682420cd166e229516a41c8d6a139a0b13e1e1/include/a_util/xml/dom.h.
DOMElement | ( | const DOMElement & | element | ) |
Copy constructor.
[in] | element | The object to copy from |
DOMElement createChild | ( | const std::string & | name | ) |
Creates a new child element.
[in] | name | The name of the child |
DOMElement createChildBefore | ( | const std::string & | name, |
const DOMElement & | before | ||
) |
Creates a new child element before an existing child element.
[in] | name | The name of the child |
[in] | before | The existing child element |
bool eraseAttribute | ( | const std::string & | name | ) |
Removes an attribute.
[in] | name | The name of the attribute |
true
if the attribute was erased, false
otherwise bool findNode | ( | const std::string & | query, |
DOMElement & | element_ptr | ||
) | const |
Finds a node based on a query.
Some basic syntax:
Here are some examples of search queries.
[in] | query | The query string |
[out] | element_ptr | This will point to the found element |
false
if no matching node is found or the query is invalid, true
otherwise bool findNodes | ( | const std::string & | query, |
DOMElementList & | elements | ||
) | const |
Finds nodes based on a query.
See findNode() for the syntax.
[in] | query | The query string |
[out] | elements | This list will be filled with the found elements |
false
if no matching node is found or the query is invalid, true
otherwise std::string getAttribute | ( | const std::string & | name, |
const std::string & | def_value = std::string() |
||
) | const |
Returns the value of an attribute with name
.
[in] | name | The name of the attribute |
[in] | def_value | A default value that is returned if the attribute does not exist |
DOMAttributes getAttributes | ( | ) | const |
Get a map of all attributes of this element.
DOMElement getChild | ( | const std::string & | name | ) | const |
Get the first child mathing the name
of this element.
[in] | name | The name of the child element |
nullptr
if not found DOMElementList getChildren | ( | ) | const |
Get a list of all child elements of the element.
std::string getData | ( | ) | const |
Get the data of the element.
DOM getDocument | ( | ) | const |
Get the DOM document this element belongs to.
std::string getName | ( | ) | const |
Get the name of the element.
DOMElement getParent | ( | ) | const |
Get this elements parent element.
std::string getPath | ( | ) | const |
Get current path of the element.
bool hasAttribute | ( | const std::string & | name | ) | const |
Checks if an attribute exists.
[in] | name | The name of the attribute |
true
if attribute exists, otherwise false
bool isNull | ( | ) | const |
Check whether this DOMElement is empty.
true
if empty, false
otherwise DOMElement& operator= | ( | const DOMElement & | element | ) |
Copy assignment operator.
[in] | element | The element to copy from |
bool removeChild | ( | const std::string & | name | ) |
Erases the first child of that name in this element.
name | [in] The name of the child element |
true
if the child was removed, false
otherwise bool setAttribute | ( | const std::string & | name, |
const std::string & | strValue | ||
) |
Sets an attribute.
Setting an attribute on an DOMElement object not created from an existing DOM will fail as a DOMElement needs to be linked to a valid DOM
[in] | name | The attribute name |
[in] | strValue | The value of the attribute |
false
if its an invalid attribute name, true
otherwise bool setData | ( | const std::string & | data | ) |
Sets the data of the element.
Setting the data on an DOMElement object not created from an existing DOM will fail as a DOMElement needs to be linked to a valid DOM
[in] | data | The new data |
true
if the data was set, false
otherwise bool setName | ( | const std::string & | name | ) |
Sets the name of the element.
Setting the name on an DOMElement object not created from an existing DOM will fail as a DOMElement needs to be linked to a valid DOM
[in] | name | The new name |
true
if the name was set, false
otherwise. std::size_t sortNodes | ( | const std::string & | query, |
const std::string & | attribute, | ||
SortingOrder | order | ||
) |
Sort the queried nodes by attribute example:
[in] | query | Xpath that describes the nodes to sort |
[in] | attribute | Attribute name of nodes to sort in specified order |
[in] | order | Sort nodes in ascending or descending order |
bool sortNodes | ( | const std::string & | query, |
const std::string & | attribute, | ||
SortingOrder | order, | ||
std::size_t | number_of_nodes | ||
) |
Sort all queried nodes by attribute example:
'[*]' in query will be replaced successively by numbers in range [1]..[n]
[in] | query | Xpath that describes all nodes to sort |
[in] | attribute | Attribute name of nodes to sort in specified order |
[in] | order | Sort nodes of queries in ascending/descending order |
[in] | number_of_nodes | Number of nodes to be sorted successively |
bool sortNodes | ( | const std::string & | query, |
SortingOrder | order | ||
) |
Sort the queried nodes by name example:
[in] | query | Xpath that describes the nodes to sort |
[in] | order | Sort nodes in ascending or descending order |
bool sortNodes | ( | const std::string & | query, |
SortingOrder | order, | ||
std::size_t | number_of_nodes | ||
) |
Sort all queried nodes by name example:
'[*]' in query will be replaced successively by numbers in range [1]..[n]
[in] | query | Xpath that describes all nodes to sort |
[in] | order | Sort nodes of queries in ascending/descending order |
[in] | number_of_nodes | Number of nodes to be sorted successively |