RobWorkProject  23.9.11-
Public Member Functions | List of all members
BoostDOMElem Class Reference

DOMElem based on Boost PropertyTree xml parser. More...

#include <BoostXMLParser.hpp>

Inherits DOMElem.

Public Member Functions

 BoostDOMElem (const std::string &key, rw::core::Ptr< boost::property_tree::ptree > ptree, rw::core::Ptr< boost::property_tree::ptree > parent, rw::core::Ptr< boost::property_tree::ptree > root, BoostXMLParser *parser)
 Construct new element. More...
 
bool isName (const std::string &elemname) const
 test if name of this elem equals elemname More...
 
void setName (const std::string &val)
 Set the name of this element. More...
 
const std::string & getName () const
 get name of this DOMElem More...
 
std::string getValue () const
 get string value of this DOMElem More...
 
int getValueAsInt () const
 get value as an integer, throws an exception if this is not an int value. More...
 
double getValueAsDouble () const
 get value as an double floating point, throws an exception if this is not an double value. More...
 
std::vector< std::string > getValueAsStringList (char stringseperator=';') const
 get value as a list of strings, throws an exception if this is not a list of strings. The default string seperator is semicolon (;). More...
 
std::vector< double > getValueAsDoubleList () const
 get value as a list of doubles, throws an exception if this is not a list of doubles. The default string seperator is space ( ). More...
 
std::vector< double > getValueAsDoubleList (int size) const
 get value as a list of N doubles, throws an exception if this is not a list of N doubles. The default string seperator is space ( ). More...
 
DOMElem::Ptr getChild (const std::string &name, bool optional=false)
 get a child with a specific name. If more children with the same name occur then it cannot be guaranteed which is returned. If optional is false then an exception will be thrown if the child cannot be found. If optional is true then NULL is returned if child is not found. More...
 
DOMElem::Ptr getAttribute (const std::string &name, bool optional=false)
 get a attribute with a specific name. If more attributes with the same name occur then it cannot be guaranteed which is returned. If optional is false then an exception will be thrown if the child cannot be found. If optional is true then NULL is returned if child is not found. More...
 
bool hasChildren () const
 test if this DOMElem has any children More...
 
bool hasChild (const std::string &name) const
 test if this DOMElem has a child by name name. More...
 
bool hasAttribute (const std::string &name) const
 test if this DOMElem has an attribute by name name. More...
 
rw::core::Ptr< DOMElemaddChild (const std::string &name)
 Add a child element. More...
 
rw::core::Ptr< DOMElemaddAttribute (const std::string &name)
 Add an attribute element. More...
 
void setValue (const std::string &val)
 Set the value of this element. More...
 
DOMElem::IteratorPair getChildren ()
 Get iterator to child elements. More...
 
DOMElem::IteratorPair getAttributes ()
 Get iterator to attributes. More...
 
DOMElem::Iterator begin ()
 Get iterator to first child element. More...
 
DOMElem::Iterator end ()
 Get iterator to last child element. More...
 
rw::core::Ptr< boost::property_tree::ptree > getRoot ()
 Get the root Boost PropertyTree element. More...
 
- Public Member Functions inherited from DOMElem
virtual ~DOMElem ()
 destructor
 
std::string getAttributeValue (const std::string &name)
 Get the value of attribute as a string. More...
 
std::string getAttributeValue (const std::string &name, const std::string &default_value)
 Get the value of attribute as a string. More...
 
int getAttributeValueAsInt (const std::string &name)
 Get the value of attribute as an integer. More...
 
int getAttributeValueAsInt (const std::string &name, int default_value)
 Get the value of attribute as an integer. More...
 
double getAttributeValueAsDouble (const std::string &name)
 Get the value of attribute as an double. More...
 
double getAttributeValueAsDouble (const std::string &name, double default_value)
 Get the value of attribute as an double. More...
 
bool getValueAsBool ()
 Get the value as a boolean. More...
 
bool getAttributeValueAsBool (const std::string &name)
 Get the value of attribute as an boolean. More...
 
bool getAttributeValueAsBool (const std::string &name, bool default_value)
 Get the value of attribute as an boolean. More...
 
virtual rw::core::Ptr< DOMElemaddChild ()
 Add a child with an empty name. More...
 
virtual void setValue (bool val)
 Set the value of this element. More...
 
virtual void setValue (int val)
 Set the value of this element. More...
 
virtual void setValue (double val)
 Set the value of this element. More...
 
virtual void setValue (const char *val)
 Set the value of this element. More...
 
virtual void setValueString (std::string val)
 Set the value of this element. More...
 

Additional Inherited Members

- Public Types inherited from DOMElem
typedef rw::core::Ptr< DOMElemPtr
 smart pointer type
 
typedef rw::core::iter_pair< class IteratorIteratorPair
 DOMElem Iterator Pair type.
 

Detailed Description

DOMElem based on Boost PropertyTree xml parser.

Constructor & Destructor Documentation

◆ BoostDOMElem()

BoostDOMElem ( const std::string &  key,
rw::core::Ptr< boost::property_tree::ptree >  ptree,
rw::core::Ptr< boost::property_tree::ptree >  parent,
rw::core::Ptr< boost::property_tree::ptree >  root,
BoostXMLParser parser 
)
inline

Construct new element.

Parameters
key[in] the key.
ptree[in] boost property tree.
parent[in] boost property tree.
root[in] boost property tree.
parser[in] the BoostXMLParser.

Member Function Documentation

◆ addAttribute()

rw::core::Ptr<DOMElem> addAttribute ( const std::string &  name)
virtual

Add an attribute element.

Parameters
name[in] name of the attribute.
Returns
pointer to the new attribute.

Implements DOMElem.

◆ addChild()

rw::core::Ptr<DOMElem> addChild ( const std::string &  name)
virtual

Add a child element.

Parameters
name[in] name of child.
Returns
pointer to the new child element.

Implements DOMElem.

◆ begin()

DOMElem::Iterator begin ( )
virtual

Get iterator to first child element.

Returns
iterator.

Implements DOMElem.

◆ end()

DOMElem::Iterator end ( )
virtual

Get iterator to last child element.

Returns
iterator.

Implements DOMElem.

◆ getAttribute()

DOMElem::Ptr getAttribute ( const std::string &  name,
bool  optional = false 
)
virtual

get a attribute with a specific name. If more attributes with the same name occur then it cannot be guaranteed which is returned. If optional is false then an exception will be thrown if the child cannot be found. If optional is true then NULL is returned if child is not found.

Parameters
name[in] name of the attribute to find
optional[in]
Returns
the DOMElem attribute if found, else either NULL (is optional) or an exception is thrown.

Implements DOMElem.

◆ getAttributes()

DOMElem::IteratorPair getAttributes ( )
virtual

Get iterator to attributes.

Returns
iterator pair for the first and last attributes.

Implements DOMElem.

◆ getChild()

DOMElem::Ptr getChild ( const std::string &  name,
bool  optional = false 
)
virtual

get a child with a specific name. If more children with the same name occur then it cannot be guaranteed which is returned. If optional is false then an exception will be thrown if the child cannot be found. If optional is true then NULL is returned if child is not found.

Parameters
name[in] name of the child to find
optional[in]
Returns
the DOMElem child if found, else either NULL (is optional) or an exception is thrown.

Implements DOMElem.

◆ getChildren()

DOMElem::IteratorPair getChildren ( )
virtual

Get iterator to child elements.

Returns
iterator pair for the first and last elements.

Implements DOMElem.

◆ getName()

const std::string& getName ( ) const
inlinevirtual

get name of this DOMElem

Returns
name of DOMElem

Implements DOMElem.

◆ getRoot()

rw::core::Ptr<boost::property_tree::ptree> getRoot ( )
inline

Get the root Boost PropertyTree element.

Returns
pointer to the tree.

◆ getValue()

std::string getValue ( ) const
virtual

get string value of this DOMElem

Returns
string value of this elem

Implements DOMElem.

◆ getValueAsDouble()

double getValueAsDouble ( ) const
virtual

get value as an double floating point, throws an exception if this is not an double value.

Returns
the double value

Implements DOMElem.

◆ getValueAsDoubleList() [1/2]

std::vector<double> getValueAsDoubleList ( ) const
virtual

get value as a list of doubles, throws an exception if this is not a list of doubles. The default string seperator is space ( ).

Returns
list of doubles

Implements DOMElem.

◆ getValueAsDoubleList() [2/2]

std::vector<double> getValueAsDoubleList ( int  size) const
virtual

get value as a list of N doubles, throws an exception if this is not a list of N doubles. The default string seperator is space ( ).

Returns
list of N doubles

Implements DOMElem.

◆ getValueAsInt()

int getValueAsInt ( ) const
virtual

get value as an integer, throws an exception if this is not an int value.

Returns
the int value

Implements DOMElem.

◆ getValueAsStringList()

std::vector<std::string> getValueAsStringList ( char  stringseperator = ';') const
virtual

get value as a list of strings, throws an exception if this is not a list of strings. The default string seperator is semicolon (;).

Returns
list of strings

Implements DOMElem.

◆ hasAttribute()

bool hasAttribute ( const std::string &  name) const
virtual

test if this DOMElem has an attribute by name name.

Parameters
name[in] name of the attribute DOMElem
Returns
true if this DOMElem has an attribute with name name

Implements DOMElem.

◆ hasChild()

bool hasChild ( const std::string &  name) const
virtual

test if this DOMElem has a child by name name.

Parameters
name[in] name of the child DOMElem
Returns
true if this DOMElem has a child with name name

Implements DOMElem.

◆ hasChildren()

bool hasChildren ( ) const
virtual

test if this DOMElem has any children

Returns
true if this DOMElem has any children

Implements DOMElem.

◆ isName()

bool isName ( const std::string &  elemname) const
inlinevirtual

test if name of this elem equals elemname

Parameters
elemname[in] string name to test with
Returns
true if elemname equals name of this DOMElem, false otherwise

Implements DOMElem.

◆ setName()

void setName ( const std::string &  val)
virtual

Set the name of this element.

Parameters
val[in] new name.

Implements DOMElem.

◆ setValue()

void setValue ( const std::string &  val)
virtual

Set the value of this element.

Parameters
val[in] new value.

Implements DOMElem.


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