liblcf
XmlWriter Class Reference

#include <writer_xml.h>

+ Collaboration diagram for XmlWriter:

Public Member Functions

 XmlWriter (std::ostream &filestream)
 
 ~XmlWriter ()
 
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 int32_t &val)
 
template<>
void Write (const int8_t &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::ostream & stream
 
int indent
 
bool at_bol
 

Detailed Description

XmlWriter class.

Definition at line 22 of file writer_xml.h.

Constructor & Destructor Documentation

◆ XmlWriter()

XmlWriter::XmlWriter ( std::ostream &  filestream)

Constructs a new XML File Writer.

Parameters
filestreamalready opened filestream.

Definition at line 18 of file writer_xml.cpp.

References stream.

◆ ~XmlWriter()

XmlWriter::~XmlWriter ( )

Destructor. Closes the opened file.

Definition at line 27 of file writer_xml.cpp.

Member Function Documentation

◆ BeginElement() [1/2]

void XmlWriter::BeginElement ( const std::string &  name)

Writes element starting tag to the stream.

Parameters
namethe element name string.

Definition at line 161 of file writer_xml.cpp.

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

Referenced by LMT_Reader::SaveXml(), LMU_Reader::SaveXml(), LDB_Reader::SaveXml(), LSD_Reader::SaveXml(), WriteNode(), RawStruct< RPG::TreeMap >::WriteXml(), RawStruct< RPG::MoveCommand >::WriteXml(), RawStruct< RPG::Equipment >::WriteXml(), RawStruct< RPG::Rect >::WriteXml(), RawStruct< RPG::Parameters >::WriteXml(), RawStruct< RPG::EventCommand >::WriteXml(), TypedField< S, T >::WriteXml(), Flags< S >::WriteXml(), IDReaderT< S, true >::WriteXmlTag(), and IDReaderT< S, false >::WriteXmlTag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BeginElement() [2/2]

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 168 of file writer_xml.cpp.

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

+ Here is the call graph for this function:

◆ Close()

void XmlWriter::Close ( )

Closes the opened file.

◆ EndElement()

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

Writes element ending tag to the stream.

Parameters
namethe element name string.

Definition at line 177 of file writer_xml.cpp.

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

Referenced by LMT_Reader::SaveXml(), LMU_Reader::SaveXml(), LDB_Reader::SaveXml(), LSD_Reader::SaveXml(), WriteNode(), RawStruct< RPG::TreeMap >::WriteXml(), RawStruct< RPG::MoveCommand >::WriteXml(), RawStruct< RPG::Equipment >::WriteXml(), RawStruct< RPG::Parameters >::WriteXml(), RawStruct< RPG::Rect >::WriteXml(), RawStruct< RPG::EventCommand >::WriteXml(), TypedField< S, T >::WriteXml(), Struct< S >::WriteXml(), and Flags< S >::WriteXml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Indent()

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(), Write(), and WriteVector().

+ Here is the caller graph for this function:

◆ IsOk()

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 LMT_Reader::SaveXml(), LMU_Reader::SaveXml(), LSD_Reader::SaveXml(), and LDB_Reader::SaveXml().

+ Here is the caller graph for this function:

◆ NewLine()

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:

◆ Write() [1/8]

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

Definition at line 31 of file writer_xml.cpp.

References Indent(), and stream.

+ Here is the call graph for this function:

◆ Write() [2/8]

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

Definition at line 37 of file writer_xml.cpp.

References Indent(), and stream.

+ Here is the call graph for this function:

◆ Write() [3/8]

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

Definition at line 43 of file writer_xml.cpp.

References WriteInt().

+ Here is the call graph for this function:

◆ Write() [4/8]

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

Definition at line 48 of file writer_xml.cpp.

References WriteInt().

+ Here is the call graph for this function:

◆ Write() [5/8]

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

Definition at line 53 of file writer_xml.cpp.

References WriteInt().

+ Here is the call graph for this function:

◆ Write() [6/8]

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:

◆ Write() [7/8]

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

Definition at line 58 of file writer_xml.cpp.

References Indent(), and stream.

+ Here is the call graph for this function:

◆ Write() [8/8]

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

Definition at line 64 of file writer_xml.cpp.

References Indent(), and stream.

+ Here is the call graph for this function:

◆ WriteInt()

void XmlWriter::WriteInt ( int  val)

Writes an integer to the stream.

Parameters
valthe integer.

Definition at line 137 of file writer_xml.cpp.

Referenced by Write(), and Primitive< int32_t >::WriteXml().

+ Here is the caller graph for this function:

◆ WriteNode()

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 155 of file writer_xml.cpp.

References BeginElement(), and EndElement().

Referenced by RawStruct< RPG::Equipment >::WriteXml(), RawStruct< RPG::Rect >::WriteXml(), RawStruct< RPG::MoveCommand >::WriteXml(), RawStruct< RPG::TreeMap >::WriteXml(), RawStruct< RPG::Parameters >::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:

◆ WriteVector()

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 142 of file writer_xml.cpp.

References Indent(), and stream.

+ Here is the call graph for this function:

Member Data Documentation

◆ at_bol

bool XmlWriter::at_bol
protected

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

Definition at line 108 of file writer_xml.h.

Referenced by Indent(), and NewLine().

◆ indent

int XmlWriter::indent
protected

Stores indentation level.

Definition at line 106 of file writer_xml.h.

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

◆ stream

std::ostream& XmlWriter::stream
protected

File-stream managed by this Writer.

Definition at line 104 of file writer_xml.h.

Referenced by BeginElement(), EndElement(), Indent(), IsOk(), NewLine(), Write(), WriteVector(), and XmlWriter().


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