26 #ifndef __UTILS__XML_PARSER_EX_H__INCL__
27 #define __UTILS__XML_PARSER_EX_H__INCL__
41 template<
typename T >
44 template<
typename T >
54 template<
typename T >
55 void AddMemberParser(
const char* name, T& instance,
bool ( T::* method )(
const TiXmlElement* ) )
66 template<
typename T >
79 template<
typename T >
80 void AddMemberParser(
const char* name,
bool ( T::* method )(
const TiXmlElement* ) )
82 AddMemberParser< T >( name,
static_cast< T&
>( *this ), method );
91 template<
typename T >
93 :
public ElementParser
99 typedef bool ( Class::*
Method )(
const TiXmlElement* );
121 bool Parse(
const TiXmlElement* field )
138 template<
typename T >
164 bool Parse(
const TiXmlElement* field )
167 const TiXmlNode* contents = field->FirstChild();
168 if( NULL == contents || TiXmlNode::TINYXML_TEXT != contents->Type() )
170 sLog.Error(
"XMLParser",
"Expected a text element in element '%s' at line %d.", field->Value(), field->Row() );
175 mValue = str2< Value >( contents->Value() );
T Value
Type of parsed value.
bool Parse(const TiXmlElement *field)
Invokes parser method.
bool Parse(const TiXmlElement *field)
Parse the value and store it.
Value & mValue
Reference to storage variable.
An implementation of ElementParser for member method parsers.
void AddMemberParser(const char *name, bool(T::*method)(const TiXmlElement *))
Adds a member parser, assuming that instance is this.
#define sLog
Evaluates to a NewLog instance.
A somewhat extended version of XMLParser.
This virtual interface must be implemented by all parsers.
Utility for parsing XML files.
const Method mMethod
The parser method.
ValueParser(Value &value)
Primary constructor.
Class & mInstance
The instance that the method should be invoked upon.
void AddParser(const char *name, ElementParser *parser)
Adds a parser.
bool(Class::* Method)(const TiXmlElement *)
Type of method.
void AddValueParser(const char *name, T &value)
Adds a value parser.
MemberElementParser(Class &instance, const Method &method)
Primary constructor.
Parses and stores a value.
void AddMemberParser(const char *name, T &instance, bool(T::*method)(const TiXmlElement *))
Adds a member parser.