herwig is hosted by Hepforge, IPPP Durham
Herwig  7.1.5
XML::Element Class Reference

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.
 
Elementoperator= (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 >
Elementoperator<< (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.
 
Elementoperator<< (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.
 
Elementappend (const Element &)
 Append a child element to this element.
 
Elementprepend (const Element &)
 Prepend a child element to this element.
 
Elementoperator<< (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 Member Functions

void index ()
 Index elements by type and name.
 
void assertContent () const
 Assert that this element got a character content.
 
void assertNamed () const
 Assert that this element is named.
 
void assertAttributes () const
 Assert that this element contains attributes.
 
void assertChildren () const
 Assert that this element contains children elements.
 

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< ElementtheChildren
 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. More...
 
bool operator!= (const XML::Element &one, const XML::Element &two)
 
XML::Element operator+ (const XML::Element &one, const XML::Element &two)
 Combine operator. More...
 

Detailed Description

Element represents a (tree of) XML elements.

Author
Simon Platzer

Definition at line 56 of file Element.h.

Friends And Related Function Documentation

◆ operator+

XML::Element operator+ ( const XML::Element one,
const XML::Element two 
)
friend

Combine operator.

Operator checks if type and name is equal otherwises throws exception

◆ operator==

bool operator== ( const XML::Element one,
const XML::Element two 
)
friend

Comparison operator.


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