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

#include <writer_xml.h>

+ Collaboration diagram for XmlWriter:

Public Member Functions

 XmlWriter (const char *filename)
 
 XmlWriter (const std::string &filename)
 
 ~XmlWriter ()
 
void Open ()
 
void Close ()
 
void WriteInt (int val)
 
template<class T >
void Write (const T &val)
 
template<class T >
void WriteNode (const std::string &name, const T &val)
 
void BeginElement (const std::string &name)
 
void BeginElement (const std::string &name, int ID)
 
void EndElement (const std::string &name)
 
void NewLine ()
 
bool IsOk () const
 
template<>
void Write (const bool &val)
 
template<>
void Write (const int &val)
 
template<>
void Write (const uint8_t &val)
 
template<>
void Write (const int16_t &val)
 
template<>
void Write (const uint32_t &val)
 
template<>
void Write (const double &val)
 

Protected Member Functions

void Indent ()
 
template<class T >
void WriteVector (const std::vector< T > &val)
 

Protected Attributes

std::string filename
 
FILE * stream
 
int indent
 
bool at_bol
 

Detailed Description

XmlWriter class.

Definition at line 18 of file writer_xml.h.

Constructor & Destructor Documentation

XmlWriter::XmlWriter ( const char *  filename)

Constructs a new XML File Writer.

Parameters
filenamefile to open.

Definition at line 10 of file writer_xml.cpp.

References Open().

+ Here is the call graph for this function:

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

Constructs a new XML File Writer.

Parameters
filenamefile to open.

Definition at line 18 of file writer_xml.cpp.

References Open().

+ Here is the call graph for this function:

XmlWriter::~XmlWriter ( )

Destructor. Closes the opened file.

Definition at line 26 of file writer_xml.cpp.

References Close().

+ Here is the call graph for this function:

Member Function Documentation

void XmlWriter::BeginElement ( const std::string &  name,
int  ID 
)

Writes element starting tag and attribute id to the stream.

Parameters
namethe element name string.
IDthe attribute ID integer.

Definition at line 170 of file writer_xml.cpp.

References indent, Indent(), NewLine(), and stream.

+ Here is the call graph for this function:

void XmlWriter::Close ( )

Closes the opened file.

Definition at line 35 of file writer_xml.cpp.

References stream.

Referenced by ~XmlWriter().

+ Here is the caller graph for this function:

void XmlWriter::EndElement ( const std::string &  name)
void XmlWriter::Indent ( )
protected

Writes an indentation to the stream.

Definition at line 191 of file writer_xml.cpp.

References at_bol, indent, and stream.

Referenced by BeginElement(), EndElement(), and WriteVector().

+ Here is the caller graph for this function:

bool XmlWriter::IsOk ( ) const

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

Returns
true if the stream is okay.

Definition at line 199 of file writer_xml.cpp.

References stream.

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

+ Here is the caller graph for this function:

void XmlWriter::NewLine ( )

Writes a line break to the stream.

Definition at line 184 of file writer_xml.cpp.

References at_bol, and stream.

Referenced by BeginElement(), and EndElement().

+ Here is the caller graph for this function:

void XmlWriter::Open ( )

Opens the file.

Definition at line 30 of file writer_xml.cpp.

References filename, and stream.

Referenced by XmlWriter().

+ Here is the caller graph for this function:

template<>
void XmlWriter::Write ( const bool &  val)

Definition at line 42 of file writer_xml.cpp.

template<>
void XmlWriter::Write ( const int &  val)

Definition at line 48 of file writer_xml.cpp.

template<>
void XmlWriter::Write ( const uint8_t &  val)

Definition at line 54 of file writer_xml.cpp.

template<>
void XmlWriter::Write ( const int16_t &  val)

Definition at line 59 of file writer_xml.cpp.

template<class T >
void XmlWriter::Write ( const T &  val)

Writes a primitive value to the stream.

Parameters
valthe value.

Referenced by RawStruct< RPG::TreeMap >::WriteXml(), Primitive< T >::WriteXml(), Primitive< std::vector< T > >::WriteXml(), and Primitive< std::string >::WriteXml().

+ Here is the caller graph for this function:

template<>
void XmlWriter::Write ( const uint32_t &  val)

Definition at line 64 of file writer_xml.cpp.

template<>
void XmlWriter::Write ( const double &  val)

Definition at line 70 of file writer_xml.cpp.

void XmlWriter::WriteInt ( int  val)

Writes an integer to the stream.

Parameters
valthe integer.

Definition at line 139 of file writer_xml.cpp.

Referenced by Primitive< int >::WriteXml().

+ Here is the caller graph for this function:

template<class T >
template void XmlWriter::WriteNode< double > ( const std::string &  name,
const T &  val 
)

Writes a primitive value in a node to the stream. Calls BeginElement, Write and EndElement.

Parameters
namethe node name string.
valthe value.

Definition at line 157 of file writer_xml.cpp.

References BeginElement(), and EndElement().

Referenced by RawStruct< RPG::MoveCommand >::WriteXml(), RawStruct< RPG::Rect >::WriteXml(), RawStruct< RPG::Parameters >::WriteXml(), RawStruct< RPG::TreeMap >::WriteXml(), RawStruct< RPG::Equipment >::WriteXml(), RawStruct< RPG::EventCommand >::WriteXml(), and Flags< S >::WriteXml().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
void XmlWriter::WriteVector ( const std::vector< T > &  val)
protected

Writes a vector of primitive values to the stream.

Parameters
valvector to write.

Definition at line 144 of file writer_xml.cpp.

References Indent(), and stream.

+ Here is the call graph for this function:

Member Data Documentation

bool XmlWriter::at_bol
protected

Indicates if writer cursor is at the beginning of the line.

Definition at line 118 of file writer_xml.h.

Referenced by Indent(), and NewLine().

std::string XmlWriter::filename
protected

Name of the file that is associated with the stream.

Definition at line 112 of file writer_xml.h.

Referenced by Open().

int XmlWriter::indent
protected

Stores indentation level.

Definition at line 116 of file writer_xml.h.

Referenced by BeginElement(), EndElement(), and Indent().

FILE* XmlWriter::stream
protected

File-stream managed by this Writer.

Definition at line 114 of file writer_xml.h.

Referenced by BeginElement(), Close(), EndElement(), Indent(), IsOk(), NewLine(), Open(), and WriteVector().


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