liblcf
XmlReader Class Reference

#include <reader_xml.h>

+ Collaboration diagram for XmlReader:

Public Member Functions

 XmlReader (std::istream &filestream)
 
 ~XmlReader ()
 
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 (int32_t &val, const std::string &data)
 
template<>
void Read (int8_t &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::istream & stream
 
void * parser
 
int nesting
 
std::vector< XmlHandler * > handlers
 
std::string buffer
 

Detailed Description

XmlReader class template.

Definition at line 31 of file reader_xml.h.

Constructor & Destructor Documentation

◆ XmlReader()

XmlReader::XmlReader ( std::istream &  filestream)

Constructs a new File Reader.

Parameters
filestreamalready opened filestream.

Definition at line 32 of file reader_xml.cpp.

References handlers, and parser.

◆ ~XmlReader()

XmlReader::~XmlReader ( )

Destructor. Closes the opened file.

Definition at line 47 of file reader_xml.cpp.

References parser.

Member Function Documentation

◆ CharacterData()

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

Character data callback.

Definition at line 91 of file reader_xml.cpp.

References buffer.

◆ EndElement()

void XmlReader::EndElement ( const char *  name)

End element callback.

Definition at line 95 of file reader_xml.cpp.

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

+ Here is the call graph for this function:

◆ Error()

◆ IsOk()

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 55 of file reader_xml.cpp.

References parser, and stream.

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

+ Here is the caller graph for this function:

◆ Parse()

void XmlReader::Parse ( )

Parses the XML file.

Definition at line 67 of file reader_xml.cpp.

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

Referenced by LMT_Reader::LoadXml(), LMU_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:

◆ Read() [1/8]

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

Parses a primitive type.

Referenced by RectXmlHandler::CharacterData(), EquipmentXmlHandler::CharacterData(), Primitive< T >::ParseXml(), Primitive< std::vector< T > >::ParseXml(), Primitive< int32_t >::ParseXml(), and Primitive< std::string >::ParseXml().

+ Here is the caller graph for this function:

◆ Read() [2/8]

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

Definition at line 107 of file reader_xml.cpp.

References Data::data.

◆ Read() [3/8]

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

Definition at line 115 of file reader_xml.cpp.

References Data::data.

◆ Read() [4/8]

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

Definition at line 121 of file reader_xml.cpp.

References Data::data.

◆ Read() [5/8]

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

Definition at line 129 of file reader_xml.cpp.

References Data::data.

◆ Read() [6/8]

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

Definition at line 137 of file reader_xml.cpp.

References Data::data.

◆ Read() [7/8]

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

Definition at line 143 of file reader_xml.cpp.

References Data::data.

◆ Read() [8/8]

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

Definition at line 149 of file reader_xml.cpp.

References Data::data.

◆ ReadVector()

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

Parses a vector of primitive type.

Definition at line 182 of file reader_xml.cpp.

References Data::data.

◆ SetHandler()

◆ StartElement()

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

Start element callback.

Definition at line 84 of file reader_xml.cpp.

References buffer, and handlers.

Member Data Documentation

◆ buffer

std::string XmlReader::buffer
protected

Text buffer.

Definition at line 109 of file reader_xml.h.

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

◆ handlers

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

Handler stack.

Definition at line 107 of file reader_xml.h.

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

◆ nesting

int XmlReader::nesting
protected

Nesting depth.

Definition at line 105 of file reader_xml.h.

◆ parser

void* XmlReader::parser
protected

Expat XML parser object.

Definition at line 102 of file reader_xml.h.

Referenced by IsOk(), Parse(), XmlReader(), and ~XmlReader().

◆ stream

std::istream& XmlReader::stream
protected

File-stream managed by this Reader.

Definition at line 97 of file reader_xml.h.

Referenced by IsOk(), and Parse().


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