NGL  6.5
The NCCA Graphics Library
ngl::XMLSerializer Class Reference

#include <XMLSerializer.h>

+ Collaboration diagram for ngl::XMLSerializer:

Public Types

enum  ACCESSMODE { READ, WRITE }
 

Public Member Functions

 XMLSerializer (const std::string &_fname, ACCESSMODE _mode)
 ctor, uses RAII to open the file, flag indicates if we have read or write mode More...
 
virtual ~XMLSerializer ()
 dtor will close the file More...
 
virtual void read (AABB &_s)
 read from an AABB must be overriden in child More...
 
virtual void write (const AABB &_s)
 write from an AABB must be overriden in child More...
 
virtual void read (BBox &_s)
 read from an BBox must be overriden in child More...
 
virtual void write (const BBox &_s)
 write from an BBox must be overriden in child More...
 
virtual void read (BezierCurve &_s)
 read from an BezierCurve must be overriden in child More...
 
virtual void write (const BezierCurve &_s)
 write from an BezierCurve must be overriden in child More...
 
virtual void read (Camera &_s)
 read from an Camera must be overriden in child More...
 
virtual void write (const Camera &_s, const std::string &_tag)
 write from an Camera must be overriden in child More...
 
virtual void read (Colour &_s)
 read from an Colour must be overriden in child More...
 
virtual void write (const Colour &_s, std::string _tag="Colour")
 write from an Colour must be overriden in child More...
 
virtual void write (const Colour &_s, rapidxml::xml_node<> *_parent, std::string _tag="Colour")
 
virtual void read (Light &_s)
 read from an Light must be overriden in child More...
 
virtual void write (const Light &_s, const std::string &_tag)
 write from an Light must be overriden in child More...
 
virtual void read (Mat3 &_s)
 read from an Mat3 must be overriden in child More...
 
virtual void write (Mat3 &_s, std::string _tag="Mat3")
 write from an Mat3 must be overriden in child More...
 
virtual void read (Mat4 &_s)
 read from an Mat4 must be overriden in child More...
 
virtual void write (Mat4 &_s, std::string _tag="Mat4")
 write from an Mat4 must be overriden in child More...
 
virtual void read (Material &_s)
 read from an Material must be overriden in child More...
 
virtual void write (const Material &_s, const std::string &_tag)
 write from an Material must be overriden in child More...
 
virtual void read (PathCamera &_s)
 read from an PathCamera must be overriden in child More...
 
virtual void write (const PathCamera &_s, const std::string &_tag)
 write from an PathCamera must be overriden in child More...
 
virtual void read (Plane &_s)
 read from an Plane must be overriden in child More...
 
virtual void write (const Plane &_s, const std::string &_tag)
 write from an Plane must be overriden in child More...
 
virtual void read (Quaternion &_s)
 read from an Quaternion must be overriden in child More...
 
virtual void write (const Quaternion &_s, const std::string &_tag="Quat")
 write from an Quaternion must be overriden in child More...
 
virtual void read (SpotLight &_s)
 read from an SpotLight must be overriden in child More...
 
virtual void write (const SpotLight &_s, const std::string &_tag)
 write from an SpotLight must be overriden in child More...
 
virtual void read (Transformation &_s)
 read from an Transformation must be overriden in child More...
 
virtual void write (const Transformation &_s, const std::string &_tag)
 write from an Transformation must be overriden in child More...
 
virtual void read (Vec2 &_s)
 read from an Vec2 must be overriden in child More...
 
virtual void write (const Vec2 &_s, std::string _tag="Vec2")
 write from an Vec2 must be overriden in child More...
 
void write (const Vec2 &_s, rapidxml::xml_node<> *_parent, std::string _tag)
 
virtual void read (Vec3 &_s)
 read from an Vec3 must be overriden in child More...
 
virtual void write (const Vec3 &_s, std::string _tag="Vec3")
 write from an Vec3 must be overriden in child More...
 
void write (const Vec3 &_s, rapidxml::xml_node<> *_parent, std::string _tag)
 
virtual void read (Vec4 &_s)
 read from an Vec4 must be overriden in child More...
 
virtual void write (const Vec4 &_s, std::string _tag="Vec4")
 write from an Vec4 must be overriden in child More...
 
void write (const Vec4 &_s, rapidxml::xml_node<> *_parent, std::string _tag)
 
void writeToXML (const std::string &_s, const std::string &_tag)
 
void writeToXML (const std::string &_s, rapidxml::xml_node<> *_parent, const std::string &_tag)
 
void addNode (const std::string &_tag)
 
void addNode (const std::string &_tag, rapidxml::xml_node<> *_parent)
 
rapidxml::xml_nodegetCurrentNode () const
 

Private Member Functions

 XMLSerializer (const AbstractSerializer &)
 make sure we can't copy this class; More...
 
XMLSerializeroperator= (const XMLSerializer &)
 make sure we can't copy this class; More...
 

Private Attributes

rapidxml::xml_document m_doc
 
rapidxml::xml_nodem_currentNode
 
rapidxml::xml_nodem_parent
 
std::string m_fname
 
ACCESSMODE m_mode
 

Detailed Description

Definition at line 34 of file XMLSerializer.h.

Member Enumeration Documentation

Enumerator
READ 
WRITE 

Definition at line 38 of file XMLSerializer.h.

Constructor & Destructor Documentation

ngl::XMLSerializer::XMLSerializer ( const std::string _fname,
ACCESSMODE  _mode 
)

ctor, uses RAII to open the file, flag indicates if we have read or write mode

Parameters
[in]&_fnamethe name of file to serialize

Definition at line 49 of file XMLSerializer.cpp.

References rapidxml::memory_pool< Ch >::allocate_attribute(), rapidxml::memory_pool< Ch >::allocate_node(), rapidxml::xml_node< Ch >::append_attribute(), rapidxml::xml_node< Ch >::append_node(), m_currentNode, m_doc, m_fname, m_mode, and rapidxml::node_declaration.

+ Here is the call graph for this function:

ngl::XMLSerializer::~XMLSerializer ( )
virtual

dtor will close the file

Definition at line 62 of file XMLSerializer.cpp.

References rapidxml::xml_document< Ch >::clear(), m_doc, m_fname, m_mode, and WRITE.

+ Here is the call graph for this function:

ngl::XMLSerializer::XMLSerializer ( const AbstractSerializer )
inlineprivate

make sure we can't copy this class;

Definition at line 235 of file XMLSerializer.h.

Member Function Documentation

void ngl::XMLSerializer::addNode ( const std::string _tag)
void ngl::XMLSerializer::addNode ( const std::string _tag,
rapidxml::xml_node<> *  _parent 
)
rapidxml::xml_node* ngl::XMLSerializer::getCurrentNode ( ) const
inline

Definition at line 232 of file XMLSerializer.h.

XMLSerializer& ngl::XMLSerializer::operator= ( const XMLSerializer )
private

make sure we can't copy this class;

void ngl::XMLSerializer::read ( AABB _s)
virtual

read from an AABB must be overriden in child

Parameters
[in,out]_sthe element to read

Definition at line 73 of file XMLSerializer.cpp.

void ngl::XMLSerializer::read ( BBox _s)
virtual

read from an BBox must be overriden in child

Parameters
[in,out]_sthe element to read

Definition at line 83 of file XMLSerializer.cpp.

void ngl::XMLSerializer::read ( BezierCurve _s)
virtual

read from an BezierCurve must be overriden in child

Parameters
[in,out]_sthe element to read

Definition at line 93 of file XMLSerializer.cpp.

void ngl::XMLSerializer::read ( Camera _s)
virtual

read from an Camera must be overriden in child

Parameters
[in,out]_sthe element to read

Definition at line 103 of file XMLSerializer.cpp.

void ngl::XMLSerializer::read ( Colour _s)
virtual

read from an Colour must be overriden in child

Parameters
[in,out]_sthe element to read

Definition at line 126 of file XMLSerializer.cpp.

void ngl::XMLSerializer::read ( Light _s)
virtual

read from an Light must be overriden in child

Parameters
[in,out]_sthe element to read

Definition at line 142 of file XMLSerializer.cpp.

void ngl::XMLSerializer::read ( Mat3 _s)
virtual

read from an Mat3 must be overriden in child

Parameters
[in,out]_sthe element to read

Definition at line 173 of file XMLSerializer.cpp.

void ngl::XMLSerializer::read ( Mat4 _s)
virtual

read from an Mat4 must be overriden in child

Parameters
[in,out]_sthe element to read

Definition at line 187 of file XMLSerializer.cpp.

void ngl::XMLSerializer::read ( Material &  _s)
virtual

read from an Material must be overriden in child

Parameters
[in,out]_sthe element to read

Definition at line 204 of file XMLSerializer.cpp.

void ngl::XMLSerializer::read ( PathCamera _s)
virtual

read from an PathCamera must be overriden in child

Parameters
[in,out]_sthe element to read

Definition at line 223 of file XMLSerializer.cpp.

void ngl::XMLSerializer::read ( Plane _s)
virtual

read from an Plane must be overriden in child

Parameters
[in,out]_sthe element to read

Definition at line 233 of file XMLSerializer.cpp.

void ngl::XMLSerializer::read ( Quaternion _s)
virtual

read from an Quaternion must be overriden in child

Parameters
[in,out]_sthe element to read

Definition at line 243 of file XMLSerializer.cpp.

void ngl::XMLSerializer::read ( SpotLight _s)
virtual

read from an SpotLight must be overriden in child

Parameters
[in,out]_sthe element to read

Definition at line 255 of file XMLSerializer.cpp.

void ngl::XMLSerializer::read ( Transformation _s)
virtual

read from an Transformation must be overriden in child

Parameters
[in,out]_sthe element to read

Definition at line 266 of file XMLSerializer.cpp.

void ngl::XMLSerializer::read ( Vec2 _s)
virtual

read from an Vec2 must be overriden in child

Parameters
[in,out]_sthe element to read

Definition at line 287 of file XMLSerializer.cpp.

void ngl::XMLSerializer::read ( Vec3 _s)
virtual

read from an Vec3 must be overriden in child

Parameters
[in,out]_sthe element to read

Definition at line 306 of file XMLSerializer.cpp.

void ngl::XMLSerializer::read ( Vec4 _s)
virtual

read from an Vec4 must be overriden in child

Parameters
[in,out]_sthe element to read

Definition at line 321 of file XMLSerializer.cpp.

void ngl::XMLSerializer::write ( const AABB _s)
virtual

write from an AABB must be overriden in child

Parameters
[in]_sthe element to write

Definition at line 78 of file XMLSerializer.cpp.

+ Here is the caller graph for this function:

void ngl::XMLSerializer::write ( const BBox _s)
virtual

write from an BBox must be overriden in child

Parameters
[in]_sthe element to write

Definition at line 88 of file XMLSerializer.cpp.

void ngl::XMLSerializer::write ( const BezierCurve _s)
virtual

write from an BezierCurve must be overriden in child

Parameters
[in]_sthe element to write

Definition at line 98 of file XMLSerializer.cpp.

void ngl::XMLSerializer::write ( const Camera _s,
const std::string _tag 
)
virtual
void ngl::XMLSerializer::write ( const Colour _s,
std::string  _tag = "Colour" 
)
virtual

write from an Colour must be overriden in child

Parameters
[in]_sthe element to write

Definition at line 131 of file XMLSerializer.cpp.

References fmt::format(), ngl::Colour::m_a, ngl::Colour::m_b, ngl::Colour::m_g, ngl::Colour::m_r, and writeToXML().

+ Here is the call graph for this function:

void ngl::XMLSerializer::write ( const Colour _s,
rapidxml::xml_node<> *  _parent,
std::string  _tag = "Colour" 
)
virtual

Definition at line 137 of file XMLSerializer.cpp.

References fmt::format(), ngl::Colour::m_a, ngl::Colour::m_b, ngl::Colour::m_g, ngl::Colour::m_r, and writeToXML().

+ Here is the call graph for this function:

void ngl::XMLSerializer::write ( const Light _s,
const std::string _tag 
)
virtual

write from an Light must be overriden in child

Parameters
[in]_sthe element to write

Definition at line 147 of file XMLSerializer.cpp.

References rapidxml::memory_pool< Ch >::allocate_node(), rapidxml::memory_pool< Ch >::allocate_string(), rapidxml::xml_node< Ch >::append_node(), ngl::Light::getColour(), ngl::Light::getPos(), ngl::Light::getSpecColour(), m_doc, rapidxml::node_element, and write().

+ Here is the call graph for this function:

void ngl::XMLSerializer::write ( Mat3 _s,
std::string  _tag = "Mat3" 
)
virtual

write from an Mat3 must be overriden in child

Parameters
[in]_sthe element to write

Definition at line 178 of file XMLSerializer.cpp.

References fmt::format(), ngl::Mat3::m_openGL, and writeToXML().

+ Here is the call graph for this function:

void ngl::XMLSerializer::write ( Mat4 _s,
std::string  _tag = "Mat4" 
)
virtual

write from an Mat4 must be overriden in child

Parameters
[in]_sthe element to write

Definition at line 192 of file XMLSerializer.cpp.

References fmt::format(), ngl::Mat4::openGL(), and writeToXML().

+ Here is the call graph for this function:

void ngl::XMLSerializer::write ( const Material &  _s,
const std::string _tag 
)
virtual

write from an Material must be overriden in child

Parameters
[in]_sthe element to write

Definition at line 209 of file XMLSerializer.cpp.

References rapidxml::memory_pool< Ch >::allocate_node(), rapidxml::memory_pool< Ch >::allocate_string(), rapidxml::xml_node< Ch >::append_node(), fmt::format(), m_doc, rapidxml::node_element, write(), and writeToXML().

+ Here is the call graph for this function:

void ngl::XMLSerializer::write ( const PathCamera _s,
const std::string _tag 
)
virtual

write from an PathCamera must be overriden in child

Parameters
[in]_sthe element to write

Definition at line 228 of file XMLSerializer.cpp.

void ngl::XMLSerializer::write ( const Plane _s,
const std::string _tag 
)
virtual

write from an Plane must be overriden in child

Parameters
[in]_sthe element to write

Definition at line 238 of file XMLSerializer.cpp.

void ngl::XMLSerializer::write ( const Quaternion _s,
const std::string _tag = "Quat" 
)
virtual

write from an Quaternion must be overriden in child

Parameters
[in]_sthe element to write

Definition at line 249 of file XMLSerializer.cpp.

References fmt::format(), ngl::Quaternion::getS(), ngl::Quaternion::getX(), ngl::Quaternion::getY(), ngl::Quaternion::getZ(), and writeToXML().

+ Here is the call graph for this function:

void ngl::XMLSerializer::write ( const SpotLight _s,
const std::string _tag 
)
virtual

write from an SpotLight must be overriden in child

Parameters
[in]_sthe element to write

Definition at line 260 of file XMLSerializer.cpp.

void ngl::XMLSerializer::write ( const Transformation _s,
const std::string _tag 
)
virtual
void ngl::XMLSerializer::write ( const Vec2 _s,
std::string  _tag = "Vec2" 
)
virtual

write from an Vec2 must be overriden in child

Parameters
[in]_sthe element to write

Definition at line 292 of file XMLSerializer.cpp.

References fmt::format(), ngl::Vec2::m_x, ngl::Vec2::m_y, and writeToXML().

+ Here is the call graph for this function:

void ngl::XMLSerializer::write ( const Vec2 _s,
rapidxml::xml_node<> *  _parent,
std::string  _tag 
)

Definition at line 299 of file XMLSerializer.cpp.

References fmt::format(), ngl::Vec2::m_x, ngl::Vec2::m_y, and writeToXML().

+ Here is the call graph for this function:

void ngl::XMLSerializer::write ( const Vec3 _s,
std::string  _tag = "Vec3" 
)
virtual

write from an Vec3 must be overriden in child

Parameters
[in]_sthe element to write

Definition at line 311 of file XMLSerializer.cpp.

References fmt::format(), ngl::Vec3::m_x, ngl::Vec3::m_y, ngl::Vec3::m_z, and writeToXML().

+ Here is the call graph for this function:

void ngl::XMLSerializer::write ( const Vec3 _s,
rapidxml::xml_node<> *  _parent,
std::string  _tag 
)

Definition at line 315 of file XMLSerializer.cpp.

References fmt::format(), ngl::Vec3::m_x, ngl::Vec3::m_y, ngl::Vec3::m_z, and writeToXML().

+ Here is the call graph for this function:

void ngl::XMLSerializer::write ( const Vec4 _s,
std::string  _tag = "Vec4" 
)
virtual

write from an Vec4 must be overriden in child

Parameters
[in]_sthe element to write

Definition at line 332 of file XMLSerializer.cpp.

References fmt::format(), ngl::Vec4::m_w, ngl::Vec4::m_x, ngl::Vec4::m_y, ngl::Vec4::m_z, and writeToXML().

+ Here is the call graph for this function:

void ngl::XMLSerializer::write ( const Vec4 _s,
rapidxml::xml_node<> *  _parent,
std::string  _tag 
)

Definition at line 338 of file XMLSerializer.cpp.

References fmt::format(), ngl::Vec4::m_w, ngl::Vec4::m_x, ngl::Vec4::m_y, ngl::Vec4::m_z, and writeToXML().

+ Here is the call graph for this function:

void ngl::XMLSerializer::writeToXML ( const std::string _s,
const std::string _tag 
)

Definition at line 16 of file XMLSerializer.cpp.

References rapidxml::memory_pool< Ch >::allocate_node(), rapidxml::memory_pool< Ch >::allocate_string(), rapidxml::xml_node< Ch >::append_node(), m_doc, and rapidxml::node_element.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ngl::XMLSerializer::writeToXML ( const std::string _s,
rapidxml::xml_node<> *  _parent,
const std::string _tag 
)

Member Data Documentation

rapidxml::xml_node* ngl::XMLSerializer::m_currentNode
private

Definition at line 242 of file XMLSerializer.h.

rapidxml::xml_document ngl::XMLSerializer::m_doc
private

Definition at line 240 of file XMLSerializer.h.

std::string ngl::XMLSerializer::m_fname
private

Definition at line 245 of file XMLSerializer.h.

ACCESSMODE ngl::XMLSerializer::m_mode
private

Definition at line 246 of file XMLSerializer.h.

rapidxml::xml_node* ngl::XMLSerializer::m_parent
private

Definition at line 243 of file XMLSerializer.h.


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