hemocell
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
hemo::XMLElement Class Reference

#include <config.h>

Public Member Functions

 XMLElement (tinyxml2::XMLElement *orig_)
 
XMLElement operator[] (std::string name) const
 
template<typename T >
T read ()
 Read the text of this element as a value of type T.
 
tinyxml2::XMLElement * getOrig ()
 
std::string path () const
 Path of this element from the root, e.g. hemocell/sim/tmax.
 

Private Member Functions

std::string where () const
 "<file>, line <n>: <path>" of this element, for error messages.
 

Static Private Member Functions

template<typename V >
static bool parseValue (const std::string &text, V &value)
 
static bool parseValue (const std::string &text, bool &value)
 
static bool parseValue (const std::string &text, std::string &value)
 

Private Attributes

tinyxml2::XMLElement * orig
 

Constructor & Destructor Documentation

◆ XMLElement()

hemo::XMLElement::XMLElement ( tinyxml2::XMLElement *  orig_)
inline

Member Function Documentation

◆ getOrig()

tinyxml2::XMLElement * hemo::XMLElement::getOrig ( )
inline

◆ operator[]()

XMLElement hemo::XMLElement::operator[] ( std::string  name) const

The child element name.

Exceptions
std::invalid_argumentif there is none; the message names the file, the element path (e.g. hemocell/sim) and its line.

◆ parseValue() [1/3]

bool hemo::XMLElement::parseValue ( const std::string &  text,
bool &  value 
)
staticprivate

◆ parseValue() [2/3]

bool hemo::XMLElement::parseValue ( const std::string &  text,
std::string &  value 
)
staticprivate

◆ parseValue() [3/3]

template<typename V >
static bool hemo::XMLElement::parseValue ( const std::string &  text,
V &  value 
)
inlinestaticprivate

◆ path()

string hemo::XMLElement::path ( ) const

Path of this element from the root, e.g. hemocell/sim/tmax.

◆ read()

template<typename T >
T hemo::XMLElement::read ( )
inline

Read the text of this element as a value of type T.

Numbers are parsed with stream extraction and must make up the whole text (surrounding whitespace is ignored), e.g. "1e6" is rejected for an integer instead of silently becoming 1. Booleans accept 0/1/true/false. Strings return the whole text with surrounding whitespace removed.

Exceptions
std::invalid_argumentif the element is empty or its text cannot be converted. Callers that treat a value as optional catch this exception (the same one that is thrown for a missing element) and use a default.

◆ where()

string hemo::XMLElement::where ( ) const
private

"<file>, line <n>: <path>" of this element, for error messages.

Member Data Documentation

◆ orig

tinyxml2::XMLElement* hemo::XMLElement::orig
private