TinyURDF 1.0.0
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 ()
 
 ~PropertyParser ()
 
std::string toString () const override
 
bool empty () const override
 
void clear () override
 
const char * getTypename () const override
 
bool isA (const char *name) const override
 
void parse (const tinyxml2::XMLElement *xml)
 
std::shared_ptr< std::unordered_map< std::string, T > > get () override
 
- Public Member Functions inherited from ParserBase< std::unordered_map< std::string, T > >
const char * getNameOf (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.

Template Parameters
Tdata type can be char*, string , double, ...
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 ( )

◆ ~PropertyParser()

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

Member Function Documentation

◆ clear()

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

Implements ObjectBase.

◆ empty()

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

Implements ObjectBase.

◆ get()

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

◆ getTypename()

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

Implements ObjectBase.

◆ isA()

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

Implements ObjectBase.

◆ parse()

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

◆ toString()

template<typename T >
std::string PropertyParser< T >::toString ( ) const
overridevirtual

Implements ObjectBase.


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