DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Public Types | Public Member Functions | Public Attributes | List of all members
dd4hep::xml::Element Class Reference

User abstraction class to manipulate XML elements within a document. More...

#include <XMLElements.h>

Inheritance diagram for dd4hep::xml::Element:
dd4hep::xml::LayeringCnv dd4hep::xml::RefElement

Public Types

typedef Handle_t::Elt_t Elt_t
 Simplification type declarations. More...
 

Public Member Functions

 Element (const Handle_t &e)
 Constructor from XmlElement handle. More...
 
 Element (const Element &e)
 Constructor from XmlElement handle. More...
 
 Element (const Document &document, const XmlChar *type)
 Constructor from DOM document entity. More...
 
Document document () const
 Access the hosting document handle of this DOM element. More...
 
 operator bool () const
 operator bool: check handle validity More...
 
bool operator! () const
 operator NOT: check handle validity More...
 
Elementoperator= (const Element &c)
 Assignment operator. More...
 
Elementoperator= (Handle_t handle)
 Assignment operator. More...
 
 operator Handle_t () const
 Automatic conversion to DOM element handle. More...
 
 operator Elt_t () const
 Automatic conversion to XmlElement pointer. More...
 
Elt_t ptr () const
 Access to XmlElement pointer. More...
 
Handle_t parent () const
 Access the XmlElements parent. More...
 
Elt_t parentElement () const
 Access the XmlElements parent. More...
 
std::string tag () const
 Access the tag name of this DOM element. More...
 
const XmlChartagName () const
 Access the tag name of this DOM element. More...
 
std::string text () const
 Access the tag name of this DOM element. More...
 
void text (const std::string value) const
 Set text attribute to the XML node. More...
 
void append (Handle_t handle) const
 Append a new element to the existing tree. More...
 
Handle_t clone (const Document &new_doc) const
 Clone the DOMelement. More...
 
bool hasAttr (const XmlChar *name) const
 Check for the existence of a named attribute. More...
 
template<class T >
attr (const XmlAttr *att) const
 Access attribute with implicit return type conversion. More...
 
template<class T >
attr (const XmlChar *tag_value) const
 Access attribute with implicit return type conversion. More...
 
template<class T >
attr (const XmlChar *tag_value, T default_value) const
 Access attribute with implicit return type conversion. More...
 
template<class T >
attr (const char *name) const
 Access typed attribute value by its name. More...
 
template<class T >
attr (const char *name, T default_value) const
 Access typed attribute value by its name. More...
 
const XmlCharattr_name (const Attribute a) const
 Access attribute name (throws exception if not present) More...
 
const XmlCharattr_value (const Attribute a) const
 Access attribute value by the attribute (throws exception if not present) More...
 
size_t numChildren (const XmlChar *tag_value, bool exc=true) const
 Access the number of children of this DOM element with a given tag name. More...
 
void setAttrs (Handle_t e) const
 Remove own attributes and copy all attributes from handle 'e'. More...
 
void removeAttrs () const
 Remove all attributes of this element. More...
 
std::vector< Attributeattributes () const
 Retrieve a collection of all attributes of this DOM element. More...
 
Attribute getAttr (const XmlChar *name) const
 Access single attribute by its name. More...
 
template<class T >
Attribute setAttr (const XmlChar *nam, const T &val) const
 Set single attribute. More...
 
template<class T >
void setValue (const T &val) const
 Set element value. More...
 
Handle_t clone (Handle_t h) const
 Clone the DOM element tree. More...
 
Handle_t addChild (const XmlChar *tag) const
 Add a new child to the DOM node. More...
 
Handle_t setChild (const XmlChar *tag) const
 Check if a child with the required tag exists - if not create it and add it to the current node. More...
 
Handle_t child (const Strng_t &tag_value, bool except=true) const
 Access child by tag name. Thow an exception if required in case the child is not present. More...
 
Handle_t remove (Handle_t node) const
 Remove a child node identified by its handle. More...
 
bool hasChild (const XmlChar *tag_value) const
 Check the existence of a child with a given tag name. More...
 
Attribute setRef (const XmlChar *tag, const XmlChar *refname) const
 Set the reference attribute to the node (adds attribute ref="ref-name") More...
 
Attribute setRef (const XmlChar *tag, const std::string &refname) const
 Set the reference attribute to the node (adds attribute ref="ref-name") More...
 
const XmlChargetRef (const XmlChar *tag) const
 Access the value of the reference attribute of the node (attribute ref="ref-name") More...
 
void addComment (const XmlChar *text) const
 Add comment node to the element. More...
 
void addComment (const char *text) const
 Add comment node to the element. More...
 
void addComment (const std::string &text_value) const
 Add comment node to the element. More...
 

Public Attributes

Handle_t m_element
 The underlying object holding the XmlElement pointer. More...
 

Detailed Description

User abstraction class to manipulate XML elements within a document.

User class encapsulating a DOM element using the Handle_t helper. This is the main class we interact with when analysing the xml documents for constructing sub-detectors etc.

Author
M.Frank
Version
1.0

Definition at line 769 of file XMLElements.h.

Member Typedef Documentation

◆ Elt_t

Simplification type declarations.

Definition at line 772 of file XMLElements.h.

Constructor & Destructor Documentation

◆ Element() [1/3]

dd4hep::xml::Element::Element ( const Handle_t e)
inline

Constructor from XmlElement handle.

Definition at line 778 of file XMLElements.h.

◆ Element() [2/3]

dd4hep::xml::Element::Element ( const Element e)
inline

Constructor from XmlElement handle.

Definition at line 780 of file XMLElements.h.

◆ Element() [3/3]

Element::Element ( const Document document,
const XmlChar type 
)

Constructor from DOM document entity.

Definition at line 1075 of file XMLElements.cpp.

Member Function Documentation

◆ addChild()

Handle_t Element::addChild ( const XmlChar tag) const

Add a new child to the DOM node.

Definition at line 1121 of file XMLElements.cpp.

◆ addComment() [1/3]

void Element::addComment ( const char *  text) const

Add comment node to the element.

Definition at line 1141 of file XMLElements.cpp.

◆ addComment() [2/3]

void Element::addComment ( const std::string &  text_value) const

Add comment node to the element.

Definition at line 1150 of file XMLElements.cpp.

◆ addComment() [3/3]

void Element::addComment ( const XmlChar text) const

Add comment node to the element.

Definition at line 1135 of file XMLElements.cpp.

◆ append()

void dd4hep::xml::Element::append ( Handle_t  handle) const
inline

Append a new element to the existing tree.

Definition at line 839 of file XMLElements.h.

◆ attr() [1/5]

template<class T >
T dd4hep::xml::Element::attr ( const char *  name) const
inline

Access typed attribute value by its name.

Definition at line 864 of file XMLElements.h.

◆ attr() [2/5]

template<class T >
T dd4hep::xml::Element::attr ( const char *  name,
default_value 
) const
inline

Access typed attribute value by its name.

Definition at line 868 of file XMLElements.h.

◆ attr() [3/5]

template<class T >
T dd4hep::xml::Element::attr ( const XmlAttr *  att) const
inline

Access attribute with implicit return type conversion.

Definition at line 851 of file XMLElements.h.

◆ attr() [4/5]

template<class T >
T dd4hep::xml::Element::attr ( const XmlChar tag_value) const
inline

Access attribute with implicit return type conversion.

Definition at line 855 of file XMLElements.h.

◆ attr() [5/5]

template<class T >
T dd4hep::xml::Element::attr ( const XmlChar tag_value,
default_value 
) const
inline

Access attribute with implicit return type conversion.

Definition at line 859 of file XMLElements.h.

◆ attr_name()

const XmlChar* dd4hep::xml::Element::attr_name ( const Attribute  a) const
inline

Access attribute name (throws exception if not present)

Definition at line 873 of file XMLElements.h.

◆ attr_value()

const XmlChar* dd4hep::xml::Element::attr_value ( const Attribute  a) const
inline

Access attribute value by the attribute (throws exception if not present)

Definition at line 877 of file XMLElements.h.

◆ attributes()

std::vector<Attribute> dd4hep::xml::Element::attributes ( ) const
inline

Retrieve a collection of all attributes of this DOM element.

Definition at line 893 of file XMLElements.h.

◆ child()

Handle_t dd4hep::xml::Element::child ( const Strng_t tag_value,
bool  except = true 
) const
inline

Access child by tag name. Thow an exception if required in case the child is not present.

Definition at line 914 of file XMLElements.h.

◆ clone() [1/2]

Handle_t dd4hep::xml::Element::clone ( const Document new_doc) const
inline

Clone the DOMelement.

Definition at line 843 of file XMLElements.h.

◆ clone() [2/2]

Handle_t Element::clone ( Handle_t  h) const

Clone the DOM element tree.

Definition at line 1094 of file XMLElements.cpp.

◆ document()

Document Element::document ( ) const

Access the hosting document handle of this DOM element.

Definition at line 1089 of file XMLElements.cpp.

◆ getAttr()

Attribute Element::getAttr ( const XmlChar name) const

Access single attribute by its name.

Definition at line 1101 of file XMLElements.cpp.

◆ getRef()

const XmlChar * Element::getRef ( const XmlChar tag) const

Access the value of the reference attribute of the node (attribute ref="ref-name")

Definition at line 1116 of file XMLElements.cpp.

◆ hasAttr()

bool dd4hep::xml::Element::hasAttr ( const XmlChar name) const
inline

Check for the existence of a named attribute.

Definition at line 847 of file XMLElements.h.

◆ hasChild()

bool dd4hep::xml::Element::hasChild ( const XmlChar tag_value) const
inline

Check the existence of a child with a given tag name.

Definition at line 922 of file XMLElements.h.

◆ numChildren()

size_t dd4hep::xml::Element::numChildren ( const XmlChar tag_value,
bool  exc = true 
) const
inline

Access the number of children of this DOM element with a given tag name.

Definition at line 881 of file XMLElements.h.

◆ operator bool()

dd4hep::xml::Element::operator bool ( ) const
inline

operator bool: check handle validity

Definition at line 787 of file XMLElements.h.

◆ operator Elt_t()

dd4hep::xml::Element::operator Elt_t ( ) const
inline

Automatic conversion to XmlElement pointer.

Definition at line 809 of file XMLElements.h.

◆ operator Handle_t()

dd4hep::xml::Element::operator Handle_t ( ) const
inline

Automatic conversion to DOM element handle.

Definition at line 805 of file XMLElements.h.

◆ operator!()

bool dd4hep::xml::Element::operator! ( ) const
inline

operator NOT: check handle validity

Definition at line 791 of file XMLElements.h.

◆ operator=() [1/2]

Element& dd4hep::xml::Element::operator= ( const Element c)
inline

Assignment operator.

Definition at line 795 of file XMLElements.h.

◆ operator=() [2/2]

Element& dd4hep::xml::Element::operator= ( Handle_t  handle)
inline

Assignment operator.

Definition at line 800 of file XMLElements.h.

◆ parent()

Handle_t dd4hep::xml::Element::parent ( ) const
inline

Access the XmlElements parent.

Definition at line 817 of file XMLElements.h.

◆ parentElement()

Element::Elt_t Element::parentElement ( ) const

Access the XmlElements parent.

Definition at line 1080 of file XMLElements.cpp.

◆ ptr()

Elt_t dd4hep::xml::Element::ptr ( ) const
inline

Access to XmlElement pointer.

Definition at line 813 of file XMLElements.h.

◆ remove()

Handle_t dd4hep::xml::Element::remove ( Handle_t  node) const
inline

Remove a child node identified by its handle.

Definition at line 918 of file XMLElements.h.

◆ removeAttrs()

void dd4hep::xml::Element::removeAttrs ( ) const
inline

Remove all attributes of this element.

Definition at line 889 of file XMLElements.h.

◆ setAttr()

template<class T >
Attribute dd4hep::xml::Element::setAttr ( const XmlChar nam,
const T &  val 
) const
inline

Set single attribute.

Definition at line 900 of file XMLElements.h.

◆ setAttrs()

void dd4hep::xml::Element::setAttrs ( Handle_t  e) const
inline

Remove own attributes and copy all attributes from handle 'e'.

Definition at line 885 of file XMLElements.h.

◆ setChild()

Handle_t Element::setChild ( const XmlChar tag) const

Check if a child with the required tag exists - if not create it and add it to the current node.

Definition at line 1128 of file XMLElements.cpp.

◆ setRef() [1/2]

Attribute Element::setRef ( const XmlChar tag,
const std::string &  refname 
) const

Set the reference attribute to the node (adds attribute ref="ref-name")

Definition at line 1111 of file XMLElements.cpp.

◆ setRef() [2/2]

Attribute Element::setRef ( const XmlChar tag,
const XmlChar refname 
) const

Set the reference attribute to the node (adds attribute ref="ref-name")

Definition at line 1106 of file XMLElements.cpp.

◆ setValue()

template<class T >
void dd4hep::xml::Element::setValue ( const T &  val) const
inline

Set element value.

Definition at line 904 of file XMLElements.h.

◆ tag()

std::string dd4hep::xml::Element::tag ( ) const
inline

Access the tag name of this DOM element.

Definition at line 823 of file XMLElements.h.

◆ tagName()

const XmlChar* dd4hep::xml::Element::tagName ( ) const
inline

Access the tag name of this DOM element.

Definition at line 827 of file XMLElements.h.

◆ text() [1/2]

std::string dd4hep::xml::Element::text ( ) const
inline

Access the tag name of this DOM element.

Definition at line 831 of file XMLElements.h.

◆ text() [2/2]

void dd4hep::xml::Element::text ( const std::string  value) const
inline

Set text attribute to the XML node.

Definition at line 835 of file XMLElements.h.

Member Data Documentation

◆ m_element

Handle_t dd4hep::xml::Element::m_element

The underlying object holding the XmlElement pointer.

Definition at line 775 of file XMLElements.h.


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