liblcf
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
XmlReader Class Reference

#include <reader_xml.h>

+ Collaboration diagram for XmlReader:

Public Member Functions

 XmlReader (const std::string &filename)
 
 ~XmlReader ()
 
void Open ()
 
void Close ()
 
bool IsOk () const
 
void Error (const char *fmt,...)
 
void Parse ()
 
void SetHandler (XmlHandler *handler)
 
void StartElement (const char *name, const char **atts)
 
void CharacterData (const char *s, int len)
 
void EndElement (const char *name)
 
template<>
void Read (bool &val, const std::string &data)
 
template<>
void Read (int &val, const std::string &data)
 
template<>
void Read (uint8_t &val, const std::string &data)
 
template<>
void Read (int16_t &val, const std::string &data)
 
template<>
void Read (uint32_t &val, const std::string &data)
 
template<>
void Read (double &val, const std::string &data)
 

Static Public Member Functions

template<class T >
static void Read (T &ref, const std::string &data)
 
template<class T >
static void ReadVector (std::vector< T > &ref, const std::string &data)
 

Protected Attributes

std::string filename
 
FILE * stream
 
void * parser
 
int nesting
 
std::vector< XmlHandler * > handlers
 
std::string buffer
 

Detailed Description

XmlReader class template.

Definition at line 28 of file reader_xml.h.

Constructor & Destructor Documentation

XmlReader::XmlReader ( const std::string &  filename)

Constructs a new File Reader.

Parameters
filenamefile to open.

Definition at line 30 of file reader_xml.cpp.

References Open().

+ Here is the call graph for this function:

XmlReader::~XmlReader ( )

Destructor. Closes the opened file.

Definition at line 38 of file reader_xml.cpp.

References Close().

+ Here is the call graph for this function:

Member Function Documentation

void XmlReader::CharacterData ( const char *  s,
int  len 
)

Character data callback.

Definition at line 103 of file reader_xml.cpp.

References buffer.

void XmlReader::Close ( )

Closes the opened file.

Definition at line 55 of file reader_xml.cpp.

References parser, and stream.

Referenced by ~XmlReader().

+ Here is the caller graph for this function:

void XmlReader::EndElement ( const char *  name)

End element callback.

Definition at line 107 of file reader_xml.cpp.

References buffer, XmlHandler::CharacterData(), and handlers.

+ Here is the call graph for this function:

bool XmlReader::IsOk ( ) const

Checks if the file is readable and if no error occured.

Returns
true if the stream is okay.

Definition at line 67 of file reader_xml.cpp.

References parser, and stream.

Referenced by LMU_Reader::LoadXml(), LMT_Reader::LoadXml(), LSD_Reader::LoadXml(), LDB_Reader::LoadXml(), and Parse().

+ Here is the caller graph for this function:

void XmlReader::Open ( )

Definition at line 42 of file reader_xml.cpp.

References filename, handlers, parser, and stream.

Referenced by XmlReader().

+ Here is the caller graph for this function:

void XmlReader::Parse ( )

Parses the XML file.

Definition at line 79 of file reader_xml.cpp.

References buffer, Error(), IsOk(), parser, and stream.

Referenced by LMU_Reader::LoadXml(), LMT_Reader::LoadXml(), LSD_Reader::LoadXml(), and LDB_Reader::LoadXml().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
static void XmlReader::Read ( T &  ref,
const std::string &  data 
)
static
template<>
void XmlReader::Read ( bool &  val,
const std::string &  data 
)

Definition at line 119 of file reader_xml.cpp.

References Data::data.

template<>
void XmlReader::Read ( int &  val,
const std::string &  data 
)

Definition at line 127 of file reader_xml.cpp.

References Data::data.

template<>
void XmlReader::Read ( uint8_t &  val,
const std::string &  data 
)

Definition at line 133 of file reader_xml.cpp.

References Data::data.

template<>
void XmlReader::Read ( int16_t &  val,
const std::string &  data 
)

Definition at line 141 of file reader_xml.cpp.

References Data::data.

template<>
void XmlReader::Read ( uint32_t &  val,
const std::string &  data 
)

Definition at line 147 of file reader_xml.cpp.

References Data::data.

template<>
void XmlReader::Read ( double &  val,
const std::string &  data 
)

Definition at line 153 of file reader_xml.cpp.

References Data::data.

template<class T >
void XmlReader::ReadVector ( std::vector< T > &  ref,
const std::string &  data 
)
static

Parses a vector of primitive type.

Definition at line 186 of file reader_xml.cpp.

void XmlReader::StartElement ( const char *  name,
const char **  atts 
)

Start element callback.

Definition at line 96 of file reader_xml.cpp.

References buffer, and handlers.

Member Data Documentation

std::string XmlReader::buffer
protected

Text buffer.

Definition at line 118 of file reader_xml.h.

Referenced by CharacterData(), EndElement(), Parse(), and StartElement().

std::string XmlReader::filename
protected

Name of the file that is associated with the stream.

Definition at line 104 of file reader_xml.h.

Referenced by Open().

std::vector<XmlHandler*> XmlReader::handlers
protected

Handler stack.

Definition at line 116 of file reader_xml.h.

Referenced by EndElement(), Open(), SetHandler(), and StartElement().

int XmlReader::nesting
protected

Nesting depth.

Definition at line 114 of file reader_xml.h.

void* XmlReader::parser
protected

Expat XML parser object.

Definition at line 111 of file reader_xml.h.

Referenced by Close(), IsOk(), Open(), and Parse().

FILE* XmlReader::stream
protected

File-stream managed by this Reader.

Definition at line 106 of file reader_xml.h.

Referenced by Close(), IsOk(), Open(), and Parse().


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