V-Gears 0
Free Final Fantasy VII engine.
Utilites.h File Reference
#include <OgreColourValue.h>
#include <OgreMatrix4.h>
#include <OgreString.h>
#include <OgreStringVector.h>
#include <Ogre.h>
#include <Overlay/OgreUTFString.h>
#include <OIS/OIS.h>
#include <tinyxml.h>
Include dependency graph for Utilites.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool GetBool (TiXmlNode *node, const Ogre::String &tag, bool def=false)
 Retrieves a boolean from an XMl tag. More...
 
int GetInt (TiXmlNode *node, const Ogre::String &tag, int def=0)
 Retrieves an integer from an XMl tag. More...
 
float GetFloat (TiXmlNode *node, const Ogre::String &tag, float def=0.0f)
 Retrieves a decimal from an XMl tag. More...
 
const Ogre::String GetString (TiXmlNode *node, const Ogre::String &tag, const Ogre::String &def="")
 Retrieves a string from an XMl tag. More...
 
const Ogre::UTFString GetUTFString (TiXmlNode *node, const Ogre::String &tag, const Ogre::UTFString &def="")
 Retrieves a string from an XMl tag. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
const Ogre::Quaternion GetQuaternion (TiXmlNode *node, const Ogre::String &tag, const Ogre::Quaternion &def=Ogre::Quaternion::IDENTITY)
 Retrieves a quaternion from an XMl tag. More...
 
const Ogre::ColourValue GetColourValue (TiXmlNode *node, const Ogre::String &tag, const Ogre::ColourValue &def=Ogre::ColourValue::ZERO)
 Retrieves a colour from an XMl tag. More...
 
void ParsePercent (float &value_percent, float &value, const Ogre::String &string)
 Parses percentage strings. More...
 
float ParseKeyFrameTime (const float length, const Ogre::String &string)
 Parses a keyframe time string. More...
 
const Ogre::String CreateAutoName (const Ogre::String prefix)
 Creates a name. More...
 
Ogre::String KeyToString (OIS::KeyCode key)
 Obtains a name from a key code. More...
 
OIS::KeyCode StringToKey (const Ogre::String &str)
 Obtains a key code from a name. More...
 
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. More...
 

Function Documentation

◆ CreateAutoName()

const Ogre::String CreateAutoName ( const Ogre::String  prefix)

Creates a name.

Parameters
[in]prefixName prefix.
Returns
PREFIX + "0".
Todo:
This seems so simple, am I missing something?

◆ GetBool()

bool GetBool ( TiXmlNode *  node,
const Ogre::String &  tag,
bool  def = false 
)

Retrieves a boolean from an XMl tag.

Parameters
[in]nodeThe XML node.
[in]tagThe name of the tag.
[in]defDefault value, in case the tag is not found or it's not a boolean value.
Returns
Boolean value of the tag. If it's not found or it's not a boolean, def is returned.

◆ GetColourValue()

const Ogre::ColourValue GetColourValue ( TiXmlNode *  node,
const Ogre::String &  tag,
const Ogre::ColourValue &  def = Ogre::ColourValue::ZERO 
)

Retrieves a colour from an XMl tag.

Parameters
[in]nodeThe XML node.
[in]tagThe name of the tag.
[in]defDefault value, in case the tag is not found.
Returns
Colour in the tag. If it's not found, def is returned.

◆ GetFloat()

float GetFloat ( TiXmlNode *  node,
const Ogre::String &  tag,
float  def = 0.0f 
)

Retrieves a decimal from an XMl tag.

Parameters
[in]nodeThe XML node.
[in]tagThe name of the tag.
[in]defDefault value, in case the tag is not found or it's not a numeric value.
Returns
Floating value of the tag. If it's not found or it's not a number, def is returned.

◆ GetInt()

int GetInt ( TiXmlNode *  node,
const Ogre::String &  tag,
int  def = 0 
)

Retrieves an integer from an XMl tag.

Parameters
[in]nodeThe XML node.
[in]tagThe name of the tag.
[in]defDefault value, in case the tag is not found or it's not a numeric value.
Returns
Integer value of the tag. If it's not found or it's not a number, def is returned.

◆ GetMatrix4()

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.

Parameters
[in]nodeThe XML node.
[in]tagThe name of the tag.
[in]defDefault value, in case the tag is not found.
Returns
Martix in the tag. If it's not found, def is returned.

◆ GetQuaternion()

const Ogre::Quaternion GetQuaternion ( TiXmlNode *  node,
const Ogre::String &  tag,
const Ogre::Quaternion &  def = Ogre::Quaternion::IDENTITY 
)

Retrieves a quaternion from an XMl tag.

Parameters
[in]nodeThe XML node.
[in]tagThe name of the tag.
[in]defDefault value, in case the tag is not found.
Returns
quaternion in the tag. If it's not found, def is returned.

◆ GetString()

const Ogre::String GetString ( TiXmlNode *  node,
const Ogre::String &  tag,
const Ogre::String &  def = "" 
)

Retrieves a string from an XMl tag.

Parameters
[in]nodeThe XML node.
[in]tagThe name of the tag.
[in]defDefault value, in case the tag is not found.
Returns
String value of the tag. If it's not found, def is returned.

◆ GetUTFString()

const Ogre::UTFString GetUTFString ( TiXmlNode *  node,
const Ogre::String &  tag,
const Ogre::UTFString &  def = "" 
)

Retrieves a string from an XMl tag.

Parameters
[in]nodeThe XML node.
[in]tagThe name of the tag.
[in]defDefault value, in case the tag is not found.
Returns
String value of the tag, in UFT8. If not found, def is returned.

◆ GetVector2()

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.

Parameters
[in]nodeThe XML node.
[in]tagThe name of the tag.
[in]defDefault value, in case the tag is not found.
Returns
Vector in the tag. If it's not found, def is returned.

◆ GetVector3()

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.

Parameters
[in]nodeThe XML node.
[in]tagThe name of the tag.
[in]defDefault value, in case the tag is not found.
Returns
Vector in the tag. If it's not found, def is returned.

◆ GetVector4()

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.

Parameters
[in]nodeThe XML node.
[in]tagThe name of the tag.
[in]defDefault value, in case the tag is not found.
Returns
Vector in the tag. If it's not found, def is returned.

◆ KeyToString()

Ogre::String KeyToString ( OIS::KeyCode  key)

Obtains a name from a key code.

Parameters
[in]keyKey code.
Returns
Human readable name assigned to the key code. "UNASSIGNED" if there is no name for the key code.

◆ ParseKeyFrameTime()

float ParseKeyFrameTime ( const float  length,
const Ogre::String &  string 
)

Parses a keyframe time string.

It accepts input string of numeric values and numeric values followed by a percentage sign.

Examples: "7.2" -> 7.2 "7.2%" -> length * 7.2

Parameters
[in]lengthKeyframe duration, used only for percentages.
[in]stringInput string
Returns
Keyframe time.

◆ ParsePercent()

void ParsePercent ( float &  value_percent,
float &  value,
const Ogre::String &  string 
)

Parses percentage strings.

Accepts strings in the formats "A" "A%" "A%B", where A and B are real values.

Examples: "80.4%" -> value = 0, percent_value = 80.4 "80.4%20.6" -> value = 20.6, percent_value = 80.4 "80.4" -> value = 80.4, percent_value = 0

Parameters
[out]value_percentPercent value
[out]valueString numeric value.
[in]stringInput string.

◆ StringTokenise()

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.

Parameters
[in]strInput string.
[in]delimitersToken delimiters. They will be stripped from the string.
[in]delimiters_preserveMore token delimiters. They will be returned as individual tokens.
[in]quote
Todo:
Understand and document.
Parameters
[in]escAccepted escape characters. Escaped characters won't be considered delimiters of any kind.
Returns
Tokens of the original string.

◆ StringToKey()

OIS::KeyCode StringToKey ( const Ogre::String &  str)

Obtains a key code from a name.

Parameters
[in]strKey name.
Returns
Key code assigned to the name. OIS::KC_UNASSIGNED if there is no keycode with the specified name.