← Documentation
ADS-IDAC Engine 5.0.0
faulttree::xml::Element Struct Reference

One XML element with its attributes and child elements. More...

#include <xml_lite.hpp>

Public Member Functions

const std::string * attribute (const std::string &name) const
 
std::string attributeOr (const std::string &name, const std::string &fallback) const
 
const Element * child (const std::string &name) const
 
std::vector< const Element * > childrenNamed (const std::string &name) const
 

Public Attributes

std::string name
 tag name as written More...
 
std::vector< Attribute > attributes
 in document order More...
 
std::vector< Element > children
 child elements in document order More...
 

Detailed Description

One XML element with its attributes and child elements.

Text content is not kept. An Element owns its children by value, so the pointers returned by the lookup helpers stay valid as long as the element they were taken from is neither modified nor destroyed.

Definition at line 53 of file xml_lite.hpp.

Member Function Documentation

◆ attribute()

const std::string * faulttree::xml::Element::attribute ( const std::string &  name) const

Returns the attribute value, or nullptr when absent.

Parameters
nameAttribute name, compared exactly. If the element repeats an attribute name, the first one is returned.

Definition at line 9 of file xml_lite.cpp.

References attributes, and name.

Referenced by attributeOr().

Here is the caller graph for this function:

◆ attributeOr()

std::string faulttree::xml::Element::attributeOr ( const std::string &  name,
const std::string &  fallback 
) const

Returns the attribute value, or fallback when absent.

Parameters
nameAttribute name, compared exactly.
fallbackValue returned when the attribute is absent.

Definition at line 16 of file xml_lite.cpp.

References attribute(), and name.

Here is the call graph for this function:

◆ child()

const Element * faulttree::xml::Element::child ( const std::string &  name) const

First child element with this tag name, or nullptr.

Parameters
nameTag name, compared exactly. Only direct children are searched.

Definition at line 22 of file xml_lite.cpp.

References children, and name.

◆ childrenNamed()

std::vector< const Element * > faulttree::xml::Element::childrenNamed ( const std::string &  name) const

All child elements with this tag name, in document order.

Parameters
nameTag name, compared exactly. Only direct children are searched.
Returns
Pointers into children; empty when there is no match.

Definition at line 30 of file xml_lite.cpp.

References children, and name.

Member Data Documentation

◆ attributes

std::vector<Attribute> faulttree::xml::Element::attributes

in document order

Definition at line 55 of file xml_lite.hpp.

Referenced by attribute().

◆ children

std::vector<Element> faulttree::xml::Element::children

child elements in document order

Definition at line 56 of file xml_lite.hpp.

Referenced by child(), and childrenNamed().

◆ name

std::string faulttree::xml::Element::name

tag name as written

Definition at line 54 of file xml_lite.hpp.

Referenced by attribute(), attributeOr(), child(), and childrenNamed().


The documentation for this struct was generated from the following files: