V-Gears 0
Free Final Fantasy VII engine.
VGearsXMLSerializer.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18#include <Ogre.h>
19#include <OgreAxisAlignedBox.h>
20#include <OgreColourValue.h>
21#include <OgreSerializer.h>
22#include <tinyxml.h>
23#include "common/TypeDefine.h"
24
25namespace VGears{
26
27#ifdef NDEBUG
28#define assertElement(node)((void)0)
29#else
30#define assertElement(node)\
31{\
32 if(node.Type() != TiXmlNode::TINYXML_ELEMENT)\
33 {\
34 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS\
35 ,"node has wrong type, needs to be TINYXML_ELEMENT"\
36 ,"XMLSerializer::assertElement");\
37 }\
38}
39#endif
40
45
46 public:
47
52
56 virtual ~XMLSerializer();
57
58 protected:
59
66 virtual void Parse(Ogre::DataStreamPtr &stream, TiXmlDocument &dest);
67
75 virtual const String* ReadAttribute(TiXmlNode &node, const String &attribute);
76
88 virtual bool ReadAttribute(
89 TiXmlNode &node, const String &attribute, bool &dest, const bool &def = false
90 );
91
103 virtual bool ReadAttribute(
104 TiXmlNode &node, const String &attribute, int &dest, const int &def = 0
105 );
106
118 virtual bool ReadAttribute(
119 TiXmlNode &node, const String &attribute, String &dest, const String &def = ""
120 );
121
133 virtual bool ReadAttribute(
134 TiXmlNode &node, const String &attribute, Ogre::Real &dest,
135 const Ogre::Real &def = 0
136 );
137
149 virtual bool ReadAttribute(
150 TiXmlNode &node, const String &attribute, Ogre::Vector2 &dest,
151 const Ogre::Vector2 &def = Ogre::Vector2::ZERO
152 );
153
165 virtual bool ReadAttribute(
166 TiXmlNode &node, const String &attribute, Ogre::Vector3 &dest,
167 const Ogre::Vector3 &def = Ogre::Vector3::ZERO
168 );
169
181 virtual bool ReadAttribute(
182 TiXmlNode &node, const String &attribute, Ogre::Vector4 &dest,
183 const Ogre::Vector4 &def = Ogre::Vector4::ZERO
184 );
185
197 virtual bool ReadAttribute(
198 TiXmlNode &node, const String &attribute, Ogre::Quaternion &dest,
199 const Ogre::Quaternion &def = Ogre::Quaternion::IDENTITY
200 );
201
212 virtual TiXmlNode* FindChildNode(TiXmlNode &node, const String &tag);
213 };
214}
Handles the serialization of XML files.
Definition: VGearsXMLSerializer.h:44
virtual const String * ReadAttribute(TiXmlNode &node, const String &attribute)
Reads an XMl node attribute as a string.
Definition: VGearsXMLSerializer.cpp:30
virtual TiXmlNode * FindChildNode(TiXmlNode &node, const String &tag)
Finds a child node of a XML node by name.
Definition: VGearsXMLSerializer.cpp:137
XMLSerializer()
Constructor.
Definition: VGearsXMLSerializer.cpp:22
virtual ~XMLSerializer()
Destructor.
Definition: VGearsXMLSerializer.cpp:24
virtual void Parse(Ogre::DataStreamPtr &stream, TiXmlDocument &dest)
Reads and parses the XML file.
Definition: VGearsXMLSerializer.cpp:26
Definition: FF7NameLookup.h:24
Ogre::String String
Definition: TypeDefine.h:37