Loading...
Searching...
No Matches
Ogre::StringConverter Class Reference
Core » General

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

`#include <OgreStringConverter.h>`

## Static Public Member Functions

static bool | isNumber (const String &val)
static bool | parse (const String &str, bool &v)
static bool | parse (const String &str, ColourValue &v)
| Converts a String to a basic value type.
static bool | parse (const String &str, double &v)
static bool | parse (const String &str, float &v)
static bool | parse (const String &str, int32 &v)
static bool | parse (const String &str, int64 &v)
static bool | parse (const String &str, Matrix3 &v)
static bool | parse (const String &str, Matrix4 &v)
static bool | parse (const String &str, Quaternion &v)
static bool | parse (const String &str, uint32 &v)
static bool | parse (const String &str, unsigned long &v)
static bool | parse (const String &str, unsigned long long &v)
static bool | parse (const String &str, Vector2 &v)
static bool | parse (const String &str, Vector3 &v)
static bool | parse (const String &str, Vector4 &v)
static Radian | parseAngle (const String &val, Radian defaultValue=Radian(0))
| Converts a String to a Angle.
static bool | parseBool (const String &val, bool defaultValue=0)
| Converts a String to a boolean.
static ColourValue | parseColourValue (const String &val, const ColourValue &defaultValue=ColourValue::Black)
| Parses a ColourValue out of a String.
static int32 | parseInt (const String &val, int32 defaultValue=0)
| Converts a String to a whole number.
static int64 | parseLong (const String &val, int64 defaultValue=0)
static Matrix3 | parseMatrix3 (const String &val, const Matrix3 &defaultValue=Matrix3::IDENTITY)
| Parses a Matrix3 out of a String.
static Matrix4 | parseMatrix4 (const String &val, const Matrix4 &defaultValue=Matrix4::IDENTITY)
| Parses a Matrix4 out of a String.
static Quaternion | parseQuaternion (const String &val, const Quaternion &defaultValue=Quaternion::IDENTITY)
| Parses a Quaternion out of a String.
static Real | parseReal (const String &val, Real defaultValue=0)
| Converts a String to a Real.
static size_t | parseSizeT (const String &val, size_t defaultValue=0)
| Converts a String to size_t.
static StringVector | parseStringVector (const String &val)
static uint32 | parseUnsignedInt (const String &val, uint32 defaultValue=0)
| Converts a String to a whole number.
static uint64 | parseUnsignedLong (const String &val, uint64 defaultValue=0)
static Vector2 | parseVector2 (const String &val, const Vector2 &defaultValue=Vector2::ZERO)
| Parses a Vector2 out of a String.
static Vector3 | parseVector3 (const String &val, const Vector3 &defaultValue=Vector3::ZERO)
| Parses a Vector3 out of a String.
static Vector4 | parseVector4 (const String &val, const Vector4 &defaultValue=Vector4::ZERO)
| Parses a Vector4 out of a String.
static String | toString (bool val, bool yesNo=false)
| Converts a boolean to a String.
static String | toString (const ColourValue &val)
| Converts a ColourValue to a String.
static String | toString (const Matrix3 &val)
| Converts a Matrix3 to a String.
static String | toString (const Matrix4 &val)
| Converts a Matrix4 to a String.
static String | toString (const Quaternion &val)
| Converts a Quaternion to a String.
static String | toString (const StringVector &val)
| Converts a StringVector to a string.
static String | toString (const Vector2 &val)
| Converts a Vector2 to a String.
static String | toString (const Vector3 &val)
| Converts a Vector3 to a String.
static String | toString (const Vector4 &val)
| Converts a Vector4 to a String.
static String | toString (Degree val, unsigned short precision=6, unsigned short width=0, char fill=' ', std::ios::fmtflags flags=std::ios::fmtflags(0))
| Converts a Degree to a String.
static String | toString (double val, unsigned short precision=6, unsigned short width=0, char fill=' ', std::ios::fmtflags flags=std::ios::fmtflags(0))
| Converts a double to a String.
static String | toString (float val, unsigned short precision=6, unsigned short width=0, char fill=' ', std::ios::fmtflags flags=std::ios::fmtflags(0))
| Converts a float to a String.
static String | toString (int32 val)
static String | toString (int32 val, unsigned short width, char fill=' ', std::ios::fmtflags flags=std::ios::fmtflags(0))
static String | toString (long val)
static String | toString (long val, unsigned short width, char fill=' ', std::ios::fmtflags flags=std::ios::fmtflags(0))
static String | toString (Radian val, unsigned short precision=6, unsigned short width=0, char fill=' ', std::ios::fmtflags flags=std::ios::fmtflags(0))
| Converts a Radian to a String.
static String | toString (uint32 val)
static String | toString (uint32 val, unsigned short width, char fill=' ', std::ios::fmtflags flags=std::ios::fmtflags(0))
static String | toString (unsigned long long val)
static String | toString (unsigned long long val, unsigned short width, char fill=' ', std::ios::fmtflags flags=std::ios::fmtflags(0))
static String | toString (unsigned long val)
static String | toString (unsigned long val, unsigned short width, char fill=' ', std::ios::fmtflags flags=std::ios::fmtflags(0))

## Static Public Attributes

static locale_t | _numLocale

## Detailed Description

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

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.

## Member Function Documentation

## toString() [1/23]

String Ogre::StringConverter::toString | ( | int32 | val | ) |

inline static

Referenced by Ogre::SimpleParamCommand< _Class, Param, getter, setter >::doGet(), Ogre::to_string(), Ogre::to_string(), Ogre::to_string(), Ogre::to_string(), Ogre::to_string(), Ogre::to_string(), Ogre::to_string(), toString(), and toString().

## toString() [2/23]

String Ogre::StringConverter::toString | ( | uint32 | val | ) |

inline static

## toString() [3/23]

String Ogre::StringConverter::toString | ( | unsigned long | val | ) |

inline static

## toString() [4/23]

String Ogre::StringConverter::toString | ( | unsigned long long | val | ) |

inline static

## toString() [5/23]

String Ogre::StringConverter::toString | ( | long | val | ) |

inline static

## toString() [6/23]

String Ogre::StringConverter::toString | ( | float | val,
|  | unsigned short | precision = 6,
|  | unsigned short | width = 0,
|  | char | fill = ' ',
|  | std::ios::fmtflags | flags = std::ios::fmtflags(0) )

static

Converts a float to a String.

## toString() [7/23]

String Ogre::StringConverter::toString | ( | double | val,
|  | unsigned short | precision = 6,
|  | unsigned short | width = 0,
|  | char | fill = ' ',
|  | std::ios::fmtflags | flags = std::ios::fmtflags(0) )

static

Converts a double to a String.

## toString() [8/23]

String Ogre::StringConverter::toString | ( | Radian | val,
|  | unsigned short | precision = 6,
|  | unsigned short | width = 0,
|  | char | fill = ' ',
|  | std::ios::fmtflags | flags = std::ios::fmtflags(0) )

inline static

Converts a Radian to a String.

References toString(), and Ogre::Radian::valueAngleUnits().

## toString() [9/23]

String Ogre::StringConverter::toString | ( | Degree | val,
|  | unsigned short | precision = 6,
|  | unsigned short | width = 0,
|  | char | fill = ' ',
|  | std::ios::fmtflags | flags = std::ios::fmtflags(0) )

inline static

Converts a Degree to a String.

References toString(), and Ogre::Degree::valueAngleUnits().

## toString() [10/23]

String Ogre::StringConverter::toString | ( | int32 | val,
|  | unsigned short | width,
|  | char | fill = ' ',
|  | std::ios::fmtflags | flags = std::ios::fmtflags(0) )

static

Deprecated
  use StringUtil::format

## toString() [11/23]

String Ogre::StringConverter::toString | ( | uint32 | val,
|  | unsigned short | width,
|  | char | fill = ' ',
|  | std::ios::fmtflags | flags = std::ios::fmtflags(0) )

static

Deprecated
  use StringUtil::format

## toString() [12/23]

String Ogre::StringConverter::toString | ( | unsigned long | val,
|  | unsigned short | width,
|  | char | fill = ' ',
|  | std::ios::fmtflags | flags = std::ios::fmtflags(0) )

static

Deprecated
  use StringUtil::format

## toString() [13/23]

String Ogre::StringConverter::toString | ( | unsigned long long | val,
|  | unsigned short | width,
|  | char | fill = ' ',
|  | std::ios::fmtflags | flags = std::ios::fmtflags(0) )

static

Deprecated
  use StringUtil::format

## toString() [14/23]

String Ogre::StringConverter::toString | ( | long | val,
|  | unsigned short | width,
|  | char | fill = ' ',
|  | std::ios::fmtflags | flags = std::ios::fmtflags(0) )

static

Deprecated
  use StringUtil::format

## toString() [15/23]

String Ogre::StringConverter::toString | ( | bool | val,
|  | bool | yesNo = false )

static

Converts a boolean to a String.

Parameters

  val |
  yesNo | If set to true, result is 'yes' or 'no' instead of 'true' or 'false'

## toString() [16/23]

String Ogre::StringConverter::toString | ( | const Vector2 & | val | ) |

static

Converts a Vector2 to a String.

Format is "x y" (i.e. 2x Real values, space delimited)

## toString() [17/23]

String Ogre::StringConverter::toString | ( | const Vector3 & | val | ) |

static

Converts a Vector3 to a String.

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

## toString() [18/23]

String Ogre::StringConverter::toString | ( | const Vector4 & | val | ) |

static

Converts a Vector4 to a String.

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

## toString() [19/23]

String Ogre::StringConverter::toString | ( | const Matrix3 & | val | ) |

static

Converts a Matrix3 to a String.

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

## toString() [20/23]

String Ogre::StringConverter::toString | ( | const Matrix4 & | val | ) |

static

Converts a Matrix4 to a String.

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.

## toString() [21/23]

String Ogre::StringConverter::toString | ( | const Quaternion & | val | ) |

static

Converts a Quaternion to a String.

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

## toString() [22/23]

String Ogre::StringConverter::toString | ( | const ColourValue & | val | ) |

static

Converts a ColourValue to a String.

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

## toString() [23/23]

String Ogre::StringConverter::toString | ( | const StringVector & | val | ) |

static

Converts a StringVector to a string.

Strings must not contain spaces since space is used as a delimiter in the output.

## parse() [1/15]

bool Ogre::StringConverter::parse | ( | const String & | str,
|  | ColourValue & | v )

static

Converts a String to a basic value type.

Returns
  whether the conversion was successful

Referenced by Ogre::SimpleParamCommand< _Class, Param, getter, setter >::doSet(), parseBool(), parseColourValue(), parseInt(), parseLong(), parseMatrix3(), parseMatrix4(), parseQuaternion(), parseReal(), parseSizeT(), parseUnsignedInt(), parseUnsignedLong(), parseVector2(), parseVector3(), and parseVector4().

## parse() [2/15]

bool Ogre::StringConverter::parse | ( | const String & | str,
|  | Quaternion & | v )

static

## parse() [3/15]

bool Ogre::StringConverter::parse | ( | const String & | str,
|  | Matrix4 & | v )

static

## parse() [4/15]

bool Ogre::StringConverter::parse | ( | const String & | str,
|  | Matrix3 & | v )

static

## parse() [5/15]

bool Ogre::StringConverter::parse | ( | const String & | str,
|  | Vector4 & | v )

static

## parse() [6/15]

bool Ogre::StringConverter::parse | ( | const String & | str,
|  | Vector3 & | v )

static

## parse() [7/15]

bool Ogre::StringConverter::parse | ( | const String & | str,
|  | Vector2 & | v )

static

## parse() [8/15]

bool Ogre::StringConverter::parse | ( | const String & | str,
|  | int32 & | v )

static

## parse() [9/15]

bool Ogre::StringConverter::parse | ( | const String & | str,
|  | uint32 & | v )

static

## parse() [10/15]

bool Ogre::StringConverter::parse | ( | const String & | str,
|  | int64 & | v )

static

## parse() [11/15]

bool Ogre::StringConverter::parse | ( | const String & | str,
|  | unsigned long & | v )

static

## parse() [12/15]

bool Ogre::StringConverter::parse | ( | const String & | str,
|  | unsigned long long & | v )

static

## parse() [13/15]

bool Ogre::StringConverter::parse | ( | const String & | str,
|  | bool & | v )

static

## parse() [14/15]

bool Ogre::StringConverter::parse | ( | const String & | str,
|  | double & | v )

static

## parse() [15/15]

bool Ogre::StringConverter::parse | ( | const String & | str,
|  | float & | v )

static

## parseReal()

Real Ogre::StringConverter::parseReal | ( | const String & | val,
|  | Real | defaultValue = 0 )

inline static

Converts a String to a Real.

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

References parse().

Referenced by parseAngle().

## parseAngle()

Radian Ogre::StringConverter::parseAngle | ( | const String & | val,
|  | Radian | defaultValue = Radian(0) )

inline static

Converts a String to a Angle.

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

References parseReal().

## parseInt()

int32 Ogre::StringConverter::parseInt | ( | const String & | val,
|  | int32 | defaultValue = 0 )

inline 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.

References parse().

## parseUnsignedInt()

uint32 Ogre::StringConverter::parseUnsignedInt | ( | const String & | val,
|  | uint32 | defaultValue = 0 )

inline 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.

References parse().

## parseLong()

int64 Ogre::StringConverter::parseLong | ( | const String & | val,
|  | int64 | defaultValue = 0 )

inline static

Deprecated

References parse().

## parseUnsignedLong()

uint64 Ogre::StringConverter::parseUnsignedLong | ( | const String & | val,
|  | uint64 | defaultValue = 0 )

inline static

Deprecated

References parse().

## parseSizeT()

size_t Ogre::StringConverter::parseSizeT | ( | const String & | val,
|  | size_t | defaultValue = 0 )

inline static

Converts a String to size_t.

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

References parse().

## parseBool()

bool Ogre::StringConverter::parseBool | ( | const String & | val,
|  | bool | defaultValue = 0 )

inline static

Converts a String to a boolean.

Returns true if case-insensitive match of the start of the string matches "true", "yes", "1", or "on", false if "false", "no", "0" or "off".

References parse().

## parseVector2()

Vector2 Ogre::StringConverter::parseVector2 | ( | const String & | val,
|  | const Vector2 & | defaultValue = Vector2::ZERO )

inline static

Parses a Vector2 out of a String.

Format is "x y" ie. 2 Real components, space delimited. Failure to parse returns Vector2::ZERO.

References parse().

## parseVector3()

Vector3 Ogre::StringConverter::parseVector3 | ( | const String & | val,
|  | const Vector3 & | defaultValue = Vector3::ZERO )

inline static

Parses a Vector3 out of a String.

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

References parse().

## parseVector4()

Vector4 Ogre::StringConverter::parseVector4 | ( | const String & | val,
|  | const Vector4 & | defaultValue = Vector4::ZERO )

inline static

Parses a Vector4 out of a String.

Format is "x y z w" ie. 4 Real components, space delimited. Failure to parse returns Vector4::ZERO.

References parse().

## parseMatrix3()

Matrix3 Ogre::StringConverter::parseMatrix3 | ( | const String & | val,
|  | const Matrix3 & | defaultValue = Matrix3::IDENTITY )

inline static

Parses a Matrix3 out of a String.

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.

References Ogre::Matrix3::IDENTITY, and parse().

## parseMatrix4()

Matrix4 Ogre::StringConverter::parseMatrix4 | ( | const String & | val,
|  | const Matrix4 & | defaultValue = Matrix4::IDENTITY )

inline static

Parses a Matrix4 out of a String.

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.

References Ogre::Matrix4::IDENTITY, and parse().

## parseQuaternion()

Quaternion Ogre::StringConverter::parseQuaternion | ( | const String & | val,
|  | const Quaternion & | defaultValue = Quaternion::IDENTITY )

inline static

Parses a Quaternion out of a String.

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

References Ogre::Quaternion::IDENTITY, and parse().

## parseColourValue()

ColourValue Ogre::StringConverter::parseColourValue | ( | const String & | val,
|  | const ColourValue & | defaultValue = ColourValue::Black )

inline static

Parses a ColourValue out of a String.

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.

References Ogre::ColourValue::Black, and parse().

## parseStringVector()

StringVector Ogre::StringConverter::parseStringVector | ( | const String & | val | ) |

inline static

Deprecated
  use StringUtil::split

References Ogre::StringUtil::split().

## isNumber()

bool Ogre::StringConverter::isNumber | ( | const String & | val | ) |

static

Deprecated
  use parse()

## Member Data Documentation

## _numLocale

locale_t Ogre::StringConverter::_numLocale

static

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

- OgreStringConverter.h