Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Ogre::StringConverter Class Reference

Class for converting the core Ogre data types to/from Strings. More...

#include <OgreStringConverter.h>

List of all members.

Static Public Methods

String toString (Real val)
 Converts a Real to a String.

String toString (int val)
 Converts an int to a String.

String toString (unsigned int val)
 Converts an int to a String.

String toString (long val)
 Converts a long to a String.

String toString (unsigned long val)
 Converts a long to a String.

String toString (bool val, bool yesNo=false)
 Converts a boolean to a String.

String toString (const Vector3 &val)
 Converts a Vector3 to a String.

String toString (const Matrix3 &val)
 Converts a Matrix3 to a String.

String toString (const Matrix4 &val)
 Converts a Matrix4 to a String.

String toString (const Quaternion &val)
 Converts a Quaternion to a String.

String toString (const ColourValue &val)
 Converts a ColourValue to a String.

String toString (const StringVector &val)
 Converts a StringVector to a string.

Real parseReal (const String &val)
 Converts a String to a Real.

int parseInt (const String &val)
 Converts a String to a whole number.

unsigned int parseUnsignedInt (const String &val)
 Converts a String to a whole number.

long parseLong (const String &val)
 Converts a String to a whole number.

unsigned long parseUnsignedLong (const String &val)
 Converts a String to a whole number.

bool parseBool (const String &val)
 Converts a String to a boolean.

Vector3 parseVector3 (const String &val)
 Parses a Vector3 out of a String.

Matrix3 parseMatrix3 (const String &val)
 Parses a Matrix3 out of a String.

Matrix4 parseMatrix4 (const String &val)
 Parses a Matrix4 out of a String.

Quaternion parseQuaternion (const String &val)
 Parses a Quaternion out of a String.

ColourValue parseColourValue (const String &val)
 Parses a ColourValue out of a String.

StringVector parseStringVector (const String &val)
 Pareses a StringVector from a string.


Detailed Description

Class for converting the core Ogre data types to/from Strings.

Remarks:
The code for converting values to and from strings is here as a separate class to avoid coupling String to other datatypes (and vice-versa) which reduces compilation dependency: important given how often the core types are used.

This class is mainly used for parsing settings in text files. External applications can also use it to interface with classes which use the StringInterface template class.

The String formats of each of the major types is listed with the methods. The basic types like int and Real just use the underlying C runtime library atof and atoi family methods, however custom types like Vector3, ColourValue and Matrix4 are also supported by this class using custom formats.

Author:
Steve Streeting

Definition at line 52 of file OgreStringConverter.h.


Member Function Documentation

bool Ogre::StringConverter::parseBool const String   val [static]
 

Converts a String to a boolean.

Remarks:
Accepts 'true' or 'false' as input.

Definition at line 194 of file OgreStringConverter.cpp.

ColourValue Ogre::StringConverter::parseColourValue const String   val [static]
 

Parses a ColourValue out of a String.

Remarks:
Format is "r g b a" (i.e. 4x Real values, space delimited), or "r g b" which implies an alpha value of 1.0 (opaque). Failure to parse returns ColourValue::Black.

Definition at line 268 of file OgreStringConverter.cpp.

References parseReal(), and Ogre::String::split().

int Ogre::StringConverter::parseInt const String   val [static]
 

Converts a String to a whole number.

Returns:
0.0 if the value could not be parsed, otherwise the numeric version of the String.

Definition at line 174 of file OgreStringConverter.cpp.

long Ogre::StringConverter::parseLong const String   val [static]
 

Converts a String to a whole number.

Returns:
0.0 if the value could not be parsed, otherwise the numeric version of the String.

Definition at line 184 of file OgreStringConverter.cpp.

Matrix3 Ogre::StringConverter::parseMatrix3 const String   val [static]
 

Parses a Matrix3 out of a String.

Remarks:
Format is "00 01 02 10 11 12 20 21 22" where '01' means row 0 column 1 etc. Failure to parse returns Matrix3::IDENTITY.

Definition at line 218 of file OgreStringConverter.cpp.

References parseReal(), and Ogre::String::split().

Matrix4 Ogre::StringConverter::parseMatrix4 const String   val [static]
 

Parses a Matrix4 out of a String.

Remarks:
Format is "00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33" where '01' means row 0 column 1 etc. Failure to parse returns Matrix4::IDENTITY.

Definition at line 235 of file OgreStringConverter.cpp.

References parseReal(), and Ogre::String::split().

Quaternion Ogre::StringConverter::parseQuaternion const String   val [static]
 

Parses a Quaternion out of a String.

Remarks:
Format is "x y z w" (i.e. 4x Real values, space delimited). Failure to parse returns Quaternion::IDENTITY.

Definition at line 253 of file OgreStringConverter.cpp.

References parseReal(), and Ogre::String::split().

Real Ogre::StringConverter::parseReal const String   val [static]
 

Converts a String to a Real.

Returns:
0.0 if the value could not be parsed, otherwise the Real version of the String.

Definition at line 169 of file OgreStringConverter.cpp.

References Ogre::Real.

Referenced by parseColourValue(), parseMatrix3(), parseMatrix4(), parseQuaternion(), and parseVector3().

StringVector Ogre::StringConverter::parseStringVector const String   val [static]
 

Pareses a StringVector from a string.

Remarks:
Strings must not contain spaces since space is used as a delimeter in the output.

Definition at line 287 of file OgreStringConverter.cpp.

References Ogre::String::split(), and Ogre::StringVector.

unsigned int Ogre::StringConverter::parseUnsignedInt const String   val [static]
 

Converts a String to a whole number.

Returns:
0.0 if the value could not be parsed, otherwise the numeric version of the String.

Definition at line 179 of file OgreStringConverter.cpp.

unsigned long Ogre::StringConverter::parseUnsignedLong const String   val [static]
 

Converts a String to a whole number.

Returns:
0.0 if the value could not be parsed, otherwise the numeric version of the String.

Definition at line 189 of file OgreStringConverter.cpp.

Vector3 Ogre::StringConverter::parseVector3 const String   val [static]
 

Parses a Vector3 out of a String.

Remarks:
Format is "x y z" ie. 3 Real components, space delimited. Failure to parse returns Vector3::ZERO.

Definition at line 202 of file OgreStringConverter.cpp.

References parseReal(), and Ogre::String::split().

String Ogre::StringConverter::toString const StringVector   val [static]
 

Converts a StringVector to a string.

Remarks:
Strings must not contain spaces since space is used as a delimeter in the output.

Definition at line 153 of file OgreStringConverter.cpp.

References Ogre::StringVector.

String Ogre::StringConverter::toString const ColourValue   val [static]
 

Converts a ColourValue to a String.

Remarks:
Format is "r g b a" (i.e. 4x Real values, space delimited).

Definition at line 146 of file OgreStringConverter.cpp.

References Ogre::ColourValue::a, Ogre::ColourValue::b, Ogre::ColourValue::g, and Ogre::ColourValue::r.

String Ogre::StringConverter::toString const Quaternion   val [static]
 

Converts a Quaternion to a String.

Remarks:
Format is "x y z w" (i.e. 4x Real values, space delimited)

Definition at line 139 of file OgreStringConverter.cpp.

References Ogre::Quaternion::w, Ogre::Quaternion::x, Ogre::Quaternion::y, and Ogre::Quaternion::z.

String Ogre::StringConverter::toString const Matrix4   val [static]
 

Converts a Matrix4 to a String.

Remarks:
Format is "00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33" where '01' means row 0 column 1 etc.

Definition at line 117 of file OgreStringConverter.cpp.

String Ogre::StringConverter::toString const Matrix3   val [static]
 

Converts a Matrix3 to a String.

Remarks:
Format is "00 01 02 10 11 12 20 21 22" where '01' means row 0 column 1 etc.

Definition at line 78 of file OgreStringConverter.cpp.

String Ogre::StringConverter::toString const Vector3   val [static]
 

Converts a Vector3 to a String.

Remarks:
Format is "x y z" (i.e. 3x Real values, space delimited)

Definition at line 71 of file OgreStringConverter.cpp.

References Ogre::Vector3::x, Ogre::Vector3::y, and Ogre::Vector3::z.

String Ogre::StringConverter::toString bool    val,
bool    yesNo = false
[static]
 

Converts a boolean to a String.

Parameters:
yesNo  If set to true, result is 'yes' or 'no' instead of 'true' or 'false'

Definition at line 93 of file OgreStringConverter.cpp.

String Ogre::StringConverter::toString unsigned long    val [static]
 

Converts a long to a String.

Definition at line 64 of file OgreStringConverter.cpp.

String Ogre::StringConverter::toString long    val [static]
 

Converts a long to a String.

Definition at line 57 of file OgreStringConverter.cpp.

String Ogre::StringConverter::toString unsigned int    val [static]
 

Converts an int to a String.

Definition at line 50 of file OgreStringConverter.cpp.

String Ogre::StringConverter::toString int    val [static]
 

Converts an int to a String.

Definition at line 43 of file OgreStringConverter.cpp.

String Ogre::StringConverter::toString Real    val [static]
 

Converts a Real to a String.

Trivial format, full precision.

Definition at line 36 of file OgreStringConverter.cpp.

References Ogre::Real.


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

Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:27:19 2004