Herwig 7.3.0
|
Element represents a (tree of) XML elements. More...
#include <Element.h>
Classes | |
struct | Attribute |
Represent an attribute. More... | |
Public Member Functions | |
Element () | |
The default constructor. | |
Element (int newType, const std::string &newNameOrContent="") | |
The standard constructor. | |
Element (const Element &other) | |
The copy constructor. | |
Element & | operator= (const Element &other) |
Assignment. | |
int | type () const |
Return the type of this element. | |
const std::string & | name () const |
Return the name of this element. | |
const std::string & | content () const |
Return the content of this element. | |
std::string & | content () |
Access the content of this element. | |
template<class T > | |
Element & | operator<< (const T &t) |
Append to the content of this element. | |
bool | hasAttributes () const |
Return true, if this element has attributes. | |
bool | hasAttribute (const std::string &) const |
Return true, if this element contains an attribute of the given name. | |
const std::map< std::string, std::string > & | attributes () const |
Return the attributes. | |
const std::string & | attribute (const std::string &) const |
Return the attribute of the given name. | |
std::string & | attribute (const std::string &) |
Access the attribute of the given name. | |
Element & | operator<< (const Attribute &) |
Append an attribute to this element. | |
template<class T > | |
void | appendAttribute (const std::string &name, const T &t) |
Append an attribute to this element. | |
template<class T > | |
void | getFromAttribute (const std::string &name, T &t) const |
Get a value from an attribute. | |
bool | hasChildren () const |
Return true, if this element has children. | |
const std::list< Element > & | children () const |
Return the list of children elements. | |
std::list< Element > & | children () |
Access the list of children elements. | |
Element & | append (const Element &) |
Append a child element to this element. | |
Element & | prepend (const Element &) |
Prepend a child element to this element. | |
Element & | operator<< (const Element &) |
Append a child element to this element. | |
void | insert (std::list< Element >::iterator, const Element &) |
Insert an element before the given position. | |
void | erase (std::list< Element >::iterator) |
Erase an element at the given position. | |
std::list< Element >::const_iterator | findFirst (int type, const std::string &name) const |
Find the first element of the given type and name. | |
std::pair< std::multimap< std::pair< int, std::string >, std::list< Element >::iterator >::const_iterator, std::multimap< std::pair< int, std::string >, std::list< Element >::iterator >::const_iterator > | findAll (int type, const std::string &name) const |
Find all elements of the given type and name. | |
Private Attributes | |
int | theType |
The type of this element. | |
std::string | theNameOrContent |
The name or character content of the element. | |
std::map< std::string, std::string > | theAttributes |
The attributes of this element. | |
std::list< Element > | theChildren |
The children elements of this element. | |
std::multimap< std::pair< int, std::string >, std::list< Element >::iterator > | theIndex |
Index children elements by type and name. | |
Friends | |
bool | operator== (const XML::Element &one, const XML::Element &two) |
Comparison operator. | |
bool | operator!= (const XML::Element &one, const XML::Element &two) |
XML::Element | operator+ (const XML::Element &one, const XML::Element &two) |
Combine operator. | |
Element represents a (tree of) XML elements.
|
inlineexplicit |
|
inline |
|
inline |
Get a value from an attribute.
Definition at line 224 of file Element.h.
References attribute(), and name().
|
inline |
Return true, if this element has attributes.
Definition at line 139 of file Element.h.
References XML::ElementTypes::Element, XML::ElementTypes::EmptyElement, and type().
|
inline |
Return true, if this element has children.
Definition at line 234 of file Element.h.
References XML::ElementTypes::Element, XML::ElementTypes::Root, and type().
|
inline |
Append to the content of this element.
Definition at line 126 of file Element.h.
References assertContent(), and theNameOrContent.
|
inline |
Return the type of this element.
Definition at line 103 of file Element.h.
References theType.
Referenced by hasAttributes(), and hasChildren().
|
friend |
Combine operator.
Operator checks if type and name is equal otherwises throws exception
|
friend |
Comparison operator.
|
private |
|
private |
|
private |
|
private |
The name or character content of the element.
Definition at line 298 of file Element.h.
Referenced by operator<<().
|
private |