Class that catch XML Parser events for a specific tag and build the corresponding Object.
More...
#include <hpp/util/parser.hh>
Class that catch XML Parser events for a specific tag and build the corresponding Object.
Derive this class if you wish to extend the Parser. The event callbacks are called in the following order:
- Note
- The derived class must have the following construtor
◆ ObjectFactoryList
◆ ObjectFactory() [1/3]
hpp::util::parser::ObjectFactory::ObjectFactory |
( |
ObjectFactory * |
parent = NULL , |
|
|
const XMLElement * |
element = NULL |
|
) |
| |
◆ ~ObjectFactory()
virtual hpp::util::parser::ObjectFactory::~ObjectFactory |
( |
| ) |
|
|
inlinevirtual |
◆ ObjectFactory() [2/3]
hpp::util::parser::ObjectFactory::ObjectFactory |
( |
const std::string & |
tagName, |
|
|
ObjectFactory * |
parent = NULL |
|
) |
| |
Constructor for writing objects from scratch.
◆ ObjectFactory() [3/3]
hpp::util::parser::ObjectFactory::ObjectFactory |
( |
ObjectFactory * |
root | ) |
|
|
protected |
◆ addAttribute()
void hpp::util::parser::ObjectFactory::addAttribute |
( |
const std::string & |
name, |
|
|
const std::string & |
value |
|
) |
| |
◆ addChild()
void hpp::util::parser::ObjectFactory::addChild |
( |
ObjectFactory * |
child | ) |
|
|
protected |
◆ addTextChild()
void hpp::util::parser::ObjectFactory::addTextChild |
( |
const XMLText * |
text | ) |
|
|
virtual |
◆ as()
template<typename T >
T* hpp::util::parser::ObjectFactory::as |
( |
| ) |
|
|
inline |
Cast this class to any child class.
◆ finishAttributes()
bool hpp::util::parser::ObjectFactory::finishAttributes |
( |
| ) |
|
|
virtual |
Called when all the attributes have been processed.
- Returns
- True to continue parsing this tag, False otherwise.
◆ finishFile()
void hpp::util::parser::ObjectFactory::finishFile |
( |
| ) |
|
|
virtual |
Called when parsing is finished.
◆ finishTags()
void hpp::util::parser::ObjectFactory::finishTags |
( |
| ) |
|
|
virtual |
Called when all the child tags have been processed.
◆ getAttribute()
std::string hpp::util::parser::ObjectFactory::getAttribute |
( |
const std::string & |
attr | ) |
const |
Return a given attributes.
◆ getChildOfType()
bool hpp::util::parser::ObjectFactory::getChildOfType |
( |
std::string |
type, |
|
|
ObjectFactory *& |
o |
|
) |
| |
Get the ObjectFactory whose tag name is type.
- Parameters
-
[out] | o | Set to the first element of the requested type. |
- Returns
- true if there was only element of the requested type. false if there are more than one.
- Exceptions
-
std::invalid_argument | if no ObjectFactory of the requested type exists. |
◆ getChildrenOfType()
std::list< ObjectFactory * > hpp::util::parser::ObjectFactory::getChildrenOfType |
( |
std::string |
type | ) |
|
◆ hasAttribute()
bool hpp::util::parser::ObjectFactory::hasAttribute |
( |
const std::string & |
attr | ) |
const |
Check if an attribute was set.
◆ hasParent()
bool hpp::util::parser::ObjectFactory::hasParent |
( |
| ) |
const |
|
protected |
◆ impl_setAttribute()
void hpp::util::parser::ObjectFactory::impl_setAttribute |
( |
const XMLAttribute * |
attr | ) |
|
|
protectedvirtual |
◆ impl_write()
void hpp::util::parser::ObjectFactory::impl_write |
( |
XMLElement * |
element | ) |
const |
|
protectedvirtual |
◆ init()
bool hpp::util::parser::ObjectFactory::init |
( |
| ) |
|
|
virtual |
◆ name() [1/3]
std::string hpp::util::parser::ObjectFactory::name |
( |
| ) |
const |
Return the content of the attribute name, or an empty string.
◆ name() [2/3]
void hpp::util::parser::ObjectFactory::name |
( |
const std::string & |
n | ) |
|
Set the name. The default value is the value of the attribute "name" of the XML tag or an empty string if this does not exist.
◆ name() [3/3]
void hpp::util::parser::ObjectFactory::name |
( |
const char * |
n | ) |
|
◆ parent()
◆ print()
std::ostream & hpp::util::parser::ObjectFactory::print |
( |
std::ostream & |
os | ) |
const |
|
protectedvirtual |
◆ root()
◆ setAttribute()
void hpp::util::parser::ObjectFactory::setAttribute |
( |
const XMLAttribute * |
attr | ) |
|
Called for each attribute. A few reserved name are automatocally catched. The reserved names are "name" and "id". "name" expects a string. "id" expects an unsigned integer and can be use to define pointers to elements.
◆ tagName()
std::string hpp::util::parser::ObjectFactory::tagName |
( |
| ) |
const |
Return tag name of the element is any. Returns "No element" otherwise.
◆ write()
XMLNode * hpp::util::parser::ObjectFactory::write |
( |
XMLNode * |
node | ) |
const |
Get a new XMLElement from the content of this factory.
Add this factory as child of the node argument. Tags are handled throught children so you should add children before calling this function. If you factory must write something different from tags (XMLText or XMLComment), reimplement method impl_write.
◆ XMLelement()
const XMLElement * hpp::util::parser::ObjectFactory::XMLelement |
( |
| ) |
|
|
protected |
◆ operator<<
std::ostream& operator<< |
( |
std::ostream & |
os, |
|
|
const ObjectFactory & |
o |
|
) |
| |
|
friend |
The documentation for this class was generated from the following files: