TinyURDF 1.0.0
A Modern C++ Library for Parsing and Visualizing URDF Model Files
Loading...
Searching...
No Matches
PropertyParser< T > Class Template Reference

A basic parser for general property value definitions in XML. Parses a single XML element where a property is defined by a list of values. These values can be numeric or strings. It fills a vector with these values and returns a pointer to it. The parser can handle any number of values. More...

#include <property_parser.h>

Inheritance diagram for PropertyParser< T >:
[legend]
Collaboration diagram for PropertyParser< T >:
[legend]

Public Member Functions

 PropertyParser ()
 
void print (std::ostream &os) override
 
bool empty () const override
 
void clear () override
 
const char * getTypename () override
 
bool isA (const char *name) override
 
void parse (const tinyxml2::XMLElement *xml)
 
std::shared_ptr< std::unordered_map< std::string, T > > get () override
 
 ~PropertyParser ()
 
- Public Member Functions inherited from ParserBase< std::unordered_map< std::string, T > >
const char * getNameOf (const tinyxml2::XMLElement *xml)
 
void parse (const tinyxml2::XMLElement *xml)
 
void parse (const tinyxml2::XMLElement *xml)
 

Additional Inherited Members

- Protected Member Functions inherited from ParserBase< std::unordered_map< std::string, T > >
 ParserBase ()
 
virtual ~ParserBase ()
 
- Protected Member Functions inherited from ObjectBase
 ObjectBase ()
 
virtual ~ObjectBase ()
 
virtual ObjectBasegetPointer ()
 
- Protected Attributes inherited from ParserBase< std::unordered_map< std::string, T > >
std::shared_ptr< std::unordered_map< std::string, T > > Tptr
 

Detailed Description

template<typename T>
class PropertyParser< T >

A basic parser for general property value definitions in XML. Parses a single XML element where a property is defined by a list of values. These values can be numeric or strings. It fills a vector with these values and returns a pointer to it. The parser can handle any number of values.

Returns
An unordered map where keys are the attribute names (stored as std::string for safety by default) and values are of type T (which can be std::string, const char*, or double—only these types are acceptable).
<density value="1.0" />
...
<controller kP="10" kI="15" Kd="-2.0" ... />
Template Parameters
TAccepts either std::string or double.
Warning
This parser does not support mixed property type parsing at once. It can handle an XML element with either all string or all double values. Mixed parsing of attributes will be addressed in future versions.
Note
A conversion error from str2double will occur when parsing mixed attribute properties with a propertyParser<double> instance. This issue is currently ignored.
Todo:
Fix the bug related to mixed attribute property parsing.

Constructor & Destructor Documentation

◆ PropertyParser()

template<typename T >
PropertyParser< T >::PropertyParser ( )
inline

◆ ~PropertyParser()

template<typename T >
PropertyParser< T >::~PropertyParser ( )
inline

Member Function Documentation

◆ clear()

template<typename T >
void PropertyParser< T >::clear ( )
inlineoverridevirtual

Implements ObjectBase.

◆ empty()

template<typename T >
bool PropertyParser< T >::empty ( ) const
inlineoverridevirtual

Implements ObjectBase.

◆ get()

template<typename T >
std::shared_ptr< std::unordered_map< std::string, T > > PropertyParser< T >::get ( )
inlineoverridevirtual

◆ getTypename()

template<typename T >
const char * PropertyParser< T >::getTypename ( )
inlineoverridevirtual

Implements ObjectBase.

◆ isA()

template<typename T >
bool PropertyParser< T >::isA ( const char *  name)
inlineoverridevirtual

Implements ObjectBase.

◆ parse()

template<typename T >
void PropertyParser< T >::parse ( const tinyxml2::XMLElement *  xml)
inlinevirtual

◆ print()

template<typename T >
void PropertyParser< T >::print ( std::ostream &  os)
inlineoverridevirtual

Implements ObjectBase.


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