EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
XMLParserEx::ValueParser< T > Class Template Reference

Parses and stores a value. More...

#include "XMLParserEx.h"

Inheritance diagram for XMLParserEx::ValueParser< T >:
Collaboration diagram for XMLParserEx::ValueParser< T >:

Public Types

typedef T Value
 Type of parsed value. More...
 

Public Member Functions

 ValueParser (Value &value)
 Primary constructor. More...
 
bool Parse (const TiXmlElement *field)
 Parse the value and store it. More...
 

Protected Attributes

ValuemValue
 Reference to storage variable. More...
 

Detailed Description

template<typename T>
class XMLParserEx::ValueParser< T >

Parses and stores a value.

Author
Bloody.Rabbit

Definition at line 45 of file XMLParserEx.h.

Member Typedef Documentation

template<typename T >
typedef T XMLParserEx::ValueParser< T >::Value

Type of parsed value.

Definition at line 144 of file XMLParserEx.h.

Constructor & Destructor Documentation

template<typename T >
XMLParserEx::ValueParser< T >::ValueParser ( Value value)
inline

Primary constructor.

Parameters
[in]valueA variable to which the result is stored.

Definition at line 151 of file XMLParserEx.h.

152  : mValue( value )
153  {
154  }
Value & mValue
Reference to storage variable.
Definition: XMLParserEx.h:183

Member Function Documentation

template<typename T >
bool XMLParserEx::ValueParser< T >::Parse ( const TiXmlElement *  field)
inline

Parse the value and store it.

Parameters
[in]fieldThe element to be parsed.
Return values
trueParsing successful.
falseParsing failed.

Definition at line 164 of file XMLParserEx.h.

References XMLParserEx::ValueParser< T >::mValue, and sLog.

165  {
166  // obtain the text element
167  const TiXmlNode* contents = field->FirstChild();
168  if( NULL == contents || TiXmlNode::TINYXML_TEXT != contents->Type() )
169  {
170  sLog.Error( "XMLParser", "Expected a text element in element '%s' at line %d.", field->Value(), field->Row() );
171  return false;
172  }
173 
174  // parse the text
175  mValue = str2< Value >( contents->Value() );
176 
177  // return
178  return true;
179  }
Value & mValue
Reference to storage variable.
Definition: XMLParserEx.h:183
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250

Member Data Documentation

template<typename T >
Value& XMLParserEx::ValueParser< T >::mValue
protected

Reference to storage variable.

Definition at line 183 of file XMLParserEx.h.

Referenced by XMLParserEx::ValueParser< T >::Parse().


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