OgreStringConverter.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __StringConverter_H__
#define __StringConverter_H__
#include "OgrePrerequisites.h"
#include "OgreStringVector.h"
#include "OgreColourValue.h"
#include "OgreMath.h"
#include "OgreMatrix3.h"
#include "OgreMatrix4.h"
#include "OgreQuaternion.h"
#include "OgreVector2.h"
#include "OgreVector3.h"
#include "OgreVector4.h"
namespace Ogre {
class _OgreExport StringConverter
{
public:
static String toString(Real val, unsigned short precision = 6,
unsigned short width = 0, char fill = ' ',
std::ios::fmtflags flags = std::ios::fmtflags(0));
#if OGRE_DOUBLE_PRECISION == 1
static String toString(float val, unsigned short precision = 6,
unsigned short width = 0, char fill = ' ',
std::ios::fmtflags flags = std::ios::fmtflags(0));
#else
static String toString(double val, unsigned short precision = 6,
unsigned short width = 0, char fill = ' ',
std::ios::fmtflags flags = std::ios::fmtflags(0));
#endif
static String toString(Radian val, unsigned short precision = 6,
unsigned short width = 0, char fill = ' ',
std::ios::fmtflags flags = std::ios::fmtflags(0))
{
return toString(val.valueAngleUnits(), precision, width, fill, flags);
}
static String toString(Degree val, unsigned short precision = 6,
unsigned short width = 0, char fill = ' ',
std::ios::fmtflags flags = std::ios::fmtflags(0))
{
return toString(val.valueAngleUnits(), precision, width, fill, flags);
}
static String toString(int val, unsigned short width = 0,
char fill = ' ',
std::ios::fmtflags flags = std::ios::fmtflags(0));
#if OGRE_PLATFORM != OGRE_PLATFORM_NACL && ( OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_64 || OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS )
static String toString(unsigned int val,
unsigned short width = 0, char fill = ' ',
std::ios::fmtflags flags = std::ios::fmtflags(0));
static String toString(size_t val,
unsigned short width = 0, char fill = ' ',
std::ios::fmtflags flags = std::ios::fmtflags(0));
#if OGRE_COMPILER == OGRE_COMPILER_MSVC
static String toString(unsigned long val,
unsigned short width = 0, char fill = ' ',
std::ios::fmtflags flags = std::ios::fmtflags(0));
#endif
#else
static String toString(size_t val,
unsigned short width = 0, char fill = ' ',
std::ios::fmtflags flags = std::ios::fmtflags(0));
static String toString(unsigned long val,
unsigned short width = 0, char fill = ' ',
std::ios::fmtflags flags = std::ios::fmtflags(0));
#endif
static String toString(long val,
unsigned short width = 0, char fill = ' ',
std::ios::fmtflags flags = std::ios::fmtflags(0));
static String toString(bool val, bool yesNo = false);
static String toString(const Vector2& val);
static String toString(const Vector3& val);
static String toString(const Vector4& val);
static String toString(const Matrix3& val);
static String toString(const Matrix4& val);
static String toString(const Quaternion& val);
static String toString(const ColourValue& val);
static String toString(const StringVector& val);
static Real parseReal(const String& val, Real defaultValue = 0);
static inline Radian parseAngle(const String& val, Radian defaultValue = Radian(0)) {
return Angle(parseReal(val, defaultValue.valueRadians()));
}
static int parseInt(const String& val, int defaultValue = 0);
static unsigned int parseUnsignedInt(const String& val, unsigned int defaultValue = 0);
static long parseLong(const String& val, long defaultValue = 0);
static unsigned long parseUnsignedLong(const String& val, unsigned long defaultValue = 0);
static size_t parseSizeT(const String& val, size_t defaultValue = 0);
static bool parseBool(const String& val, bool defaultValue = 0);
static Vector2 parseVector2(const String& val, const Vector2& defaultValue = Vector2::ZERO);
static Vector3 parseVector3(const String& val, const Vector3& defaultValue = Vector3::ZERO);
static Vector4 parseVector4(const String& val, const Vector4& defaultValue = Vector4::ZERO);
static Matrix3 parseMatrix3(const String& val, const Matrix3& defaultValue = Matrix3::IDENTITY);
static Matrix4 parseMatrix4(const String& val, const Matrix4& defaultValue = Matrix4::IDENTITY);
static Quaternion parseQuaternion(const String& val, const Quaternion& defaultValue = Quaternion::IDENTITY);
static ColourValue parseColourValue(const String& val, const ColourValue& defaultValue = ColourValue::Black);
static StringVector parseStringVector(const String& val);
static bool isNumber(const String& val);
//-----------------------------------------------------------------------
static void setDefaultStringLocale(String loc)
{
msDefaultStringLocale = loc;
msLocale = std::locale(msDefaultStringLocale.c_str());
}
//-----------------------------------------------------------------------
static String getDefaultStringLocale(void) { return msDefaultStringLocale; }
//-----------------------------------------------------------------------
static void setUseLocale(bool useLocale) { msUseLocale = useLocale; }
//-----------------------------------------------------------------------
static bool isUseLocale() { return msUseLocale; }
//-----------------------------------------------------------------------
protected:
static String msDefaultStringLocale;
static std::locale msLocale;
static bool msUseLocale;
};
}
#endif
Ogre::StringConverter::toString
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.
Definition: OgreStringConverter.h:95
OgreVector4.h
OgreQuaternion.h
OgreVector3.h
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::Quaternion
Implementation of a Quaternion, i.e.
Definition: OgreQuaternion.h:57
Ogre::Matrix4::IDENTITY
static const Matrix4 IDENTITY
Definition: OgreMatrix4.h:511
Ogre::Matrix3
A 3x3 matrix which can represent rotations around axes.
Definition: OgreMatrix3.h:68
Ogre::Vector4
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
Ogre::Vector2
Standard 2-dimensional vector.
Definition: OgreVector2.h:51
Ogre::ColourValue
Class representing colour.
Definition: OgreColourValue.h:57
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::ColourValue::Black
static const ColourValue Black
Definition: OgreColourValue.h:61
Ogre::StringVector
vector< String >::type StringVector
Definition: OgreStringVector.h:45
Ogre::StringConverter::getDefaultStringLocale
static String getDefaultStringLocale(void)
Definition: OgreStringConverter.h:283
Ogre::Vector2::ZERO
static const Vector2 ZERO
Definition: OgreVector2.h:585
Ogre::Matrix4
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
Ogre::StringConverter::setDefaultStringLocale
static void setDefaultStringLocale(String loc)
Definition: OgreStringConverter.h:277
Ogre::Vector4::ZERO
static const Vector4 ZERO
Definition: OgreVector4.h:411
OgrePrerequisites.h
Ogre::StringConverter::isUseLocale
static bool isUseLocale()
Definition: OgreStringConverter.h:287
Ogre::Angle
Wrapper class which identifies a value as the currently default angle type, as defined by Math::setAn...
Definition: OgreMath.h:150
OgreStringVector.h
Ogre::StringConverter::setUseLocale
static void setUseLocale(bool useLocale)
Definition: OgreStringConverter.h:285
OgreMatrix4.h
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::StringConverter
Class for converting the core Ogre data types to/from Strings.
Definition: OgreStringConverter.h:68
Ogre::Matrix3::IDENTITY
static const Matrix3 IDENTITY
Definition: OgreMatrix3.h:268
Ogre::StringConverter::msDefaultStringLocale
static String msDefaultStringLocale
Definition: OgreStringConverter.h:291
Ogre::StringConverter::msLocale
static std::locale msLocale
Definition: OgreStringConverter.h:292
OgreMatrix3.h
Ogre::Degree::valueAngleUnits
Real valueAngleUnits() const
Definition: OgreMath.h:732
Ogre
Definition: OgreAndroidLogListener.h:34
OgreMath.h
Ogre::StringConverter::toString
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.
Definition: OgreStringConverter.h:88
OgreColourValue.h
Ogre::StringConverter::msUseLocale
static bool msUseLocale
Definition: OgreStringConverter.h:293
Ogre::Radian::valueAngleUnits
Real valueAngleUnits() const
Definition: OgreMath.h:722
Ogre::StringConverter::parseAngle
static Radian parseAngle(const String &val, Radian defaultValue=Radian(0))
Converts a String to a Angle.
Definition: OgreStringConverter.h:190
Ogre::Degree
Wrapper class which indicates a given angle value is in Degrees.
Definition: OgreMath.h:98
OgreVector2.h
Ogre::Quaternion::IDENTITY
static const Quaternion IDENTITY
Definition: OgreQuaternion.h:301
Ogre::Radian
Wrapper class which indicates a given angle value is in Radians.
Definition: OgreMath.h:47
Ogre::Vector3::ZERO
static const Vector3 ZERO
Definition: OgreVector3.h:800

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.