NGL
6.5
The NCCA Graphics Library
|
#include <XMLSerializer.h>
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_node * | getCurrentNode () const |
Private Member Functions | |
XMLSerializer (const AbstractSerializer &) | |
make sure we can't copy this class; More... | |
XMLSerializer & | operator= (const XMLSerializer &) |
make sure we can't copy this class; More... | |
Private Attributes | |
rapidxml::xml_document | m_doc |
rapidxml::xml_node * | m_currentNode |
rapidxml::xml_node * | m_parent |
std::string | m_fname |
ACCESSMODE | m_mode |
Definition at line 34 of file XMLSerializer.h.
Enumerator | |
---|---|
READ | |
WRITE |
Definition at line 38 of file XMLSerializer.h.
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
[in] | &_fname | the 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.
|
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.
|
inlineprivate |
make sure we can't copy this class;
Definition at line 235 of file XMLSerializer.h.
void ngl::XMLSerializer::addNode | ( | const std::string & | _tag | ) |
Definition at line 33 of file XMLSerializer.cpp.
References rapidxml::memory_pool< Ch >::allocate_node(), rapidxml::memory_pool< Ch >::allocate_string(), rapidxml::xml_node< Ch >::append_node(), m_currentNode, m_doc, and rapidxml::node_element.
void ngl::XMLSerializer::addNode | ( | const std::string & | _tag, |
rapidxml::xml_node<> * | _parent | ||
) |
Definition at line 41 of file XMLSerializer.cpp.
References rapidxml::memory_pool< Ch >::allocate_node(), rapidxml::memory_pool< Ch >::allocate_string(), rapidxml::xml_node< Ch >::append_node(), m_currentNode, m_doc, and rapidxml::node_element.
|
inline |
Definition at line 232 of file XMLSerializer.h.
|
private |
make sure we can't copy this class;
read from an AABB must be overriden in child
[in,out] | _s | the element to read |
Definition at line 73 of file XMLSerializer.cpp.
read from an BBox must be overriden in child
[in,out] | _s | the element to read |
Definition at line 83 of file XMLSerializer.cpp.
|
virtual |
read from an BezierCurve must be overriden in child
[in,out] | _s | the element to read |
Definition at line 93 of file XMLSerializer.cpp.
read from an Camera must be overriden in child
[in,out] | _s | the element to read |
Definition at line 103 of file XMLSerializer.cpp.
read from an Colour must be overriden in child
[in,out] | _s | the element to read |
Definition at line 126 of file XMLSerializer.cpp.
read from an Light must be overriden in child
[in,out] | _s | the element to read |
Definition at line 142 of file XMLSerializer.cpp.
read from an Mat3 must be overriden in child
[in,out] | _s | the element to read |
Definition at line 173 of file XMLSerializer.cpp.
read from an Mat4 must be overriden in child
[in,out] | _s | the element to read |
Definition at line 187 of file XMLSerializer.cpp.
|
virtual |
read from an Material must be overriden in child
[in,out] | _s | the element to read |
Definition at line 204 of file XMLSerializer.cpp.
|
virtual |
read from an PathCamera must be overriden in child
[in,out] | _s | the element to read |
Definition at line 223 of file XMLSerializer.cpp.
read from an Plane must be overriden in child
[in,out] | _s | the element to read |
Definition at line 233 of file XMLSerializer.cpp.
|
virtual |
read from an Quaternion must be overriden in child
[in,out] | _s | the element to read |
Definition at line 243 of file XMLSerializer.cpp.
read from an SpotLight must be overriden in child
[in,out] | _s | the element to read |
Definition at line 255 of file XMLSerializer.cpp.
|
virtual |
read from an Transformation must be overriden in child
[in,out] | _s | the element to read |
Definition at line 266 of file XMLSerializer.cpp.
read from an Vec2 must be overriden in child
[in,out] | _s | the element to read |
Definition at line 287 of file XMLSerializer.cpp.
read from an Vec3 must be overriden in child
[in,out] | _s | the element to read |
Definition at line 306 of file XMLSerializer.cpp.
read from an Vec4 must be overriden in child
[in,out] | _s | the element to read |
Definition at line 321 of file XMLSerializer.cpp.
write from an AABB must be overriden in child
[in] | _s | the element to write |
Definition at line 78 of file XMLSerializer.cpp.
write from an BBox must be overriden in child
[in] | _s | the element to write |
Definition at line 88 of file XMLSerializer.cpp.
|
virtual |
write from an BezierCurve must be overriden in child
[in] | _s | the element to write |
Definition at line 98 of file XMLSerializer.cpp.
|
virtual |
write from an Camera must be overriden in child
[in] | _s | the element to write |
Definition at line 110 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(), ngl::Camera::getAspect(), ngl::Camera::getEye(), ngl::Camera::getFar(), ngl::Camera::getFOV(), ngl::Camera::getLook(), ngl::Camera::getNear(), ngl::Camera::getUp(), m_doc, rapidxml::node_element, write(), and writeToXML().
|
virtual |
write from an Colour must be overriden in child
[in] | _s | the 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().
|
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().
|
virtual |
write from an Light must be overriden in child
[in] | _s | the 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().
|
virtual |
write from an Mat3 must be overriden in child
[in] | _s | the element to write |
Definition at line 178 of file XMLSerializer.cpp.
References fmt::format(), ngl::Mat3::m_openGL, and writeToXML().
|
virtual |
write from an Mat4 must be overriden in child
[in] | _s | the element to write |
Definition at line 192 of file XMLSerializer.cpp.
References fmt::format(), ngl::Mat4::openGL(), and writeToXML().
|
virtual |
write from an Material must be overriden in child
[in] | _s | the 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().
|
virtual |
write from an PathCamera must be overriden in child
[in] | _s | the element to write |
Definition at line 228 of file XMLSerializer.cpp.
|
virtual |
write from an Plane must be overriden in child
[in] | _s | the element to write |
Definition at line 238 of file XMLSerializer.cpp.
|
virtual |
write from an Quaternion must be overriden in child
[in] | _s | the 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().
|
virtual |
write from an SpotLight must be overriden in child
[in] | _s | the element to write |
Definition at line 260 of file XMLSerializer.cpp.
|
virtual |
write from an Transformation must be overriden in child
[in] | _s | the element to write |
Definition at line 271 of file XMLSerializer.cpp.
References rapidxml::memory_pool< Ch >::allocate_node(), rapidxml::memory_pool< Ch >::allocate_string(), rapidxml::xml_node< Ch >::append_node(), ngl::Transformation::getPosition(), ngl::Transformation::getRotation(), ngl::Transformation::getScale(), m_doc, rapidxml::node_element, and write().
|
virtual |
write from an Vec2 must be overriden in child
[in] | _s | the element to write |
Definition at line 292 of file XMLSerializer.cpp.
References fmt::format(), ngl::Vec2::m_x, ngl::Vec2::m_y, and writeToXML().
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().
|
virtual |
write from an Vec3 must be overriden in child
[in] | _s | the 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().
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().
|
virtual |
write from an Vec4 must be overriden in child
[in] | _s | the 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().
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().
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.
void ngl::XMLSerializer::writeToXML | ( | const std::string & | _s, |
rapidxml::xml_node<> * | _parent, | ||
const std::string & | _tag | ||
) |
Definition at line 25 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.
|
private |
Definition at line 242 of file XMLSerializer.h.
|
private |
Definition at line 240 of file XMLSerializer.h.
|
private |
Definition at line 245 of file XMLSerializer.h.
|
private |
Definition at line 246 of file XMLSerializer.h.
|
private |
Definition at line 243 of file XMLSerializer.h.