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

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

#include <Elements.h>

Public Types

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

Public Member Functions

 Element (const Handle_t &e)
 Constructor from JsonElement handle. More...
 
 Element (const Element &e)
 Constructor from JsonElement handle. More...
 
Elementoperator= (const Element &c)
 Assignment operator. More...
 
Elementoperator= (Handle_t handle)
 Assignment operator. More...
 
 operator bool () const
 operator bool: check handle validity More...
 
bool operator! () const
 operator NOT: check handle validity More...
 
 operator Handle_t () const
 Automatic conversion to DOM element handle. More...
 
 operator Elt_t () const
 Automatic conversion to JsonElement pointer. More...
 
Elt_t ptr () const
 Access to JsonElement pointer. More...
 
std::string tag () const
 Access the tag name of this element. More...
 
const char * tagName () const
 Access the tag name of this element. More...
 
std::string text () const
 Access the tag name of this element. More...
 
bool hasAttr (const char *name) const
 Check for the existence of a named attribute. More...
 
template<class T >
attr (const char *tag_value) const
 Access attribute with implicit return type conversion. More...
 
const char * attr_name (const Attribute a) const
 Access attribute name (throws exception if not present) More...
 
const char * attr_value (const Attribute a) const
 Access attribute value by the attribute (throws exception if not present) More...
 
size_t numChildren (const char *tag_value, bool exc=true) const
 Access the number of children of this element with a given tag name. More...
 
std::vector< Attributeattributes () const
 Retrieve a collection of all attributes of this element. More...
 
Attribute getAttr (const char *name) const
 Access single attribute by its name. More...
 
Handle_t child (const char *tag_value, bool except=true) const
 Access child by tag name. Thow an exception if required in case the child is not present. More...
 
bool hasChild (const char *tag_value) const
 Check the existence of a child with a given tag name. More...
 

Public Attributes

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

Detailed Description

User abstraction class to manipulate JSON 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 json documents for constructing sub-detectors etc.

Author
M.Frank
Version
1.0

Definition at line 358 of file Elements.h.

Member Typedef Documentation

◆ Elt_t

Simplification type declarations.

Definition at line 361 of file Elements.h.

Constructor & Destructor Documentation

◆ Element() [1/2]

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

Constructor from JsonElement handle.

Definition at line 367 of file Elements.h.

◆ Element() [2/2]

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

Constructor from JsonElement handle.

Definition at line 369 of file Elements.h.

Member Function Documentation

◆ attr()

template<class T >
T dd4hep::json::Element::attr ( const char *  tag_value) const
inline

Access attribute with implicit return type conversion.

Definition at line 400 of file Elements.h.

◆ attr_name()

const char* dd4hep::json::Element::attr_name ( const Attribute  a) const
inline

Access attribute name (throws exception if not present)

Definition at line 403 of file Elements.h.

◆ attr_value()

const char* dd4hep::json::Element::attr_value ( const Attribute  a) const
inline

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

Definition at line 406 of file Elements.h.

◆ attributes()

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

Retrieve a collection of all attributes of this element.

Definition at line 412 of file Elements.h.

◆ child()

Handle_t dd4hep::json::Element::child ( const char *  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 417 of file Elements.h.

◆ getAttr()

Attribute Element::getAttr ( const char *  name) const

Access single attribute by its name.

Definition at line 378 of file Elements.cpp.

◆ hasAttr()

bool dd4hep::json::Element::hasAttr ( const char *  name) const
inline

Check for the existence of a named attribute.

Definition at line 398 of file Elements.h.

◆ hasChild()

bool dd4hep::json::Element::hasChild ( const char *  tag_value) const
inline

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

Definition at line 420 of file Elements.h.

◆ numChildren()

size_t dd4hep::json::Element::numChildren ( const char *  tag_value,
bool  exc = true 
) const
inline

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

Definition at line 409 of file Elements.h.

◆ operator bool()

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

operator bool: check handle validity

Definition at line 382 of file Elements.h.

◆ operator Elt_t()

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

Automatic conversion to JsonElement pointer.

Definition at line 388 of file Elements.h.

◆ operator Handle_t()

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

Automatic conversion to DOM element handle.

Definition at line 386 of file Elements.h.

◆ operator!()

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

operator NOT: check handle validity

Definition at line 384 of file Elements.h.

◆ operator=() [1/2]

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

Assignment operator.

Definition at line 372 of file Elements.h.

◆ operator=() [2/2]

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

Assignment operator.

Definition at line 377 of file Elements.h.

◆ ptr()

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

Access to JsonElement pointer.

Definition at line 390 of file Elements.h.

◆ tag()

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

Access the tag name of this element.

Definition at line 392 of file Elements.h.

◆ tagName()

const char* dd4hep::json::Element::tagName ( ) const
inline

Access the tag name of this element.

Definition at line 394 of file Elements.h.

◆ text()

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

Access the tag name of this element.

Definition at line 396 of file Elements.h.

Member Data Documentation

◆ m_element

Handle_t dd4hep::json::Element::m_element

The underlying object holding the JsonElement pointer.

Definition at line 364 of file Elements.h.


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