V-Gears 0
Free Final Fantasy VII engine.
Utilites.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 <OgreColourValue.h>
19#include <OgreMatrix4.h>
20#include <OgreString.h>
21#include <OgreStringVector.h>
22#include <Ogre.h>
23#include <Overlay/OgreUTFString.h>
24#include <OIS/OIS.h>
25#include <tinyxml.h>
26
27// TODO: All the methods defined here that refer to XML files are implemented
28// as methods of XmlFile. Can they be deleted from here?
29// TODO: Also, a lot of functions are never actually called.
30
39bool GetBool(TiXmlNode* node, const Ogre::String& tag, bool def = false);
40
49int GetInt(TiXmlNode* node, const Ogre::String& tag, int def = 0);
50
59float GetFloat(TiXmlNode* node, const Ogre::String& tag, float def = 0.0f);
60
70 TiXmlNode* node, const Ogre::String& tag, const Ogre::String& def = ""
71);
72
81const Ogre::UTFString GetUTFString(
82 TiXmlNode* node, const Ogre::String& tag, const Ogre::UTFString& def = ""
83);
84
93const Ogre::Vector2 GetVector2(
94 TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector2& def = Ogre::Vector2::ZERO
95);
96
105const Ogre::Vector3 GetVector3(
106 TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector3& def = Ogre::Vector3::ZERO
107);
108
117const Ogre::Vector4 GetVector4(
118 TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector4& def = Ogre::Vector4::ZERO
119);
120
129const Ogre::Matrix4 GetMatrix4(
130 TiXmlNode* node, const Ogre::String& tag, const Ogre::Matrix4& def = Ogre::Matrix4::IDENTITY
131);
132
141const Ogre::Quaternion GetQuaternion(
142 TiXmlNode* node, const Ogre::String& tag, const Ogre::Quaternion& def = Ogre::Quaternion::IDENTITY
143);
144
153const Ogre::ColourValue GetColourValue(
154 TiXmlNode* node, const Ogre::String& tag, const Ogre::ColourValue& def = Ogre::ColourValue::ZERO
155);
156
171void ParsePercent(float& value_percent, float& value, const Ogre::String& string);
172
186float ParseKeyFrameTime(const float length, const Ogre::String& string);
187
195const Ogre::String CreateAutoName(const Ogre::String prefix);
196
204Ogre::String KeyToString(OIS::KeyCode key);
205
213OIS::KeyCode StringToKey(const Ogre::String& str);
214
226Ogre::StringVector StringTokenise(
227 const Ogre::String& str, const Ogre::String& delimiters = "\t\n ",
228 const Ogre::String& delimiters_preserve = "",
229 const Ogre::String& quote = "\"", const Ogre::String& esc = "\\"
230);
231
const Ogre::UTFString GetUTFString(TiXmlNode *node, const Ogre::String &tag, const Ogre::UTFString &def="")
Retrieves a string from an XMl tag.
Definition: Utilites.cpp:58
const Ogre::String GetString(TiXmlNode *node, const Ogre::String &tag, const Ogre::String &def="")
Retrieves a string from an XMl tag.
Definition: Utilites.cpp:47
int GetInt(TiXmlNode *node, const Ogre::String &tag, int def=0)
Retrieves an integer from an XMl tag.
Definition: Utilites.cpp:28
const Ogre::Vector4 GetVector4(TiXmlNode *node, const Ogre::String &tag, const Ogre::Vector4 &def=Ogre::Vector4::ZERO)
Retrieves a 4-dimensional vector from an XMl tag.
Definition: Utilites.cpp:87
const Ogre::Vector3 GetVector3(TiXmlNode *node, const Ogre::String &tag, const Ogre::Vector3 &def=Ogre::Vector3::ZERO)
Retrieves a 3-dimensional vector from an XMl tag.
Definition: Utilites.cpp:78
float GetFloat(TiXmlNode *node, const Ogre::String &tag, float def=0.0f)
Retrieves a decimal from an XMl tag.
Definition: Utilites.cpp:38
const Ogre::Quaternion GetQuaternion(TiXmlNode *node, const Ogre::String &tag, const Ogre::Quaternion &def=Ogre::Quaternion::IDENTITY)
Retrieves a quaternion from an XMl tag.
Definition: Utilites.cpp:105
const Ogre::ColourValue GetColourValue(TiXmlNode *node, const Ogre::String &tag, const Ogre::ColourValue &def=Ogre::ColourValue::ZERO)
Retrieves a colour from an XMl tag.
Definition: Utilites.cpp:116
const Ogre::Matrix4 GetMatrix4(TiXmlNode *node, const Ogre::String &tag, const Ogre::Matrix4 &def=Ogre::Matrix4::IDENTITY)
Retrieves a 4-dimensional matrix from an XMl tag.
Definition: Utilites.cpp:96
float ParseKeyFrameTime(const float length, const Ogre::String &string)
Parses a keyframe time string.
Definition: Utilites.cpp:145
void ParsePercent(float &value_percent, float &value, const Ogre::String &string)
Parses percentage strings.
Definition: Utilites.cpp:127
Ogre::StringVector StringTokenise(const Ogre::String &str, const Ogre::String &delimiters="\t\n ", const Ogre::String &delimiters_preserve="", const Ogre::String &quote="\"", const Ogre::String &esc="\\")
Tokenizes a string.
Definition: Utilites.cpp:277
const Ogre::Vector2 GetVector2(TiXmlNode *node, const Ogre::String &tag, const Ogre::Vector2 &def=Ogre::Vector2::ZERO)
Retrieves a 2-dimensional vector from an XMl tag.
Definition: Utilites.cpp:69
OIS::KeyCode StringToKey(const Ogre::String &str)
Obtains a key code from a name.
Definition: Utilites.cpp:269
const Ogre::String CreateAutoName(const Ogre::String prefix)
Creates a name.
Definition: Utilites.cpp:153
Ogre::String KeyToString(OIS::KeyCode key)
Obtains a name from a key code.
Definition: Utilites.cpp:262
bool GetBool(TiXmlNode *node, const Ogre::String &tag, bool def=false)
Retrieves a boolean from an XMl tag.
Definition: Utilites.cpp:19
Ogre::String String
Definition: TypeDefine.h:37