OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreStringConverter.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 
29 #ifndef __StringConverter_H__
30 #define __StringConverter_H__
31 
32 #include "OgrePrerequisites.h"
33 #include "OgreStringVector.h"
34 #include "OgreColourValue.h"
35 #include "OgreMatrix4.h"
36 #include "OgreVector2.h"
37 
38 namespace Ogre {
39 
64  {
65  public:
66 
68  static String toString(Real val, unsigned short precision = 6,
69  unsigned short width = 0, char fill = ' ',
70  std::ios::fmtflags flags = std::ios::fmtflags(0));
71 #if OGRE_DOUBLE_PRECISION == 1
72 
73  static String toString(float val, unsigned short precision = 6,
74  unsigned short width = 0, char fill = ' ',
75  std::ios::fmtflags flags = std::ios::fmtflags(0));
76 #else
77 
78  static String toString(double val, unsigned short precision = 6,
79  unsigned short width = 0, char fill = ' ',
80  std::ios::fmtflags flags = std::ios::fmtflags(0));
81 #endif
82 
83  static String toString(Radian val, unsigned short precision = 6,
84  unsigned short width = 0, char fill = ' ',
85  std::ios::fmtflags flags = std::ios::fmtflags(0))
86  {
87  return toString(val.valueAngleUnits(), precision, width, fill, flags);
88  }
90  static String toString(Degree val, unsigned short precision = 6,
91  unsigned short width = 0, char fill = ' ',
92  std::ios::fmtflags flags = std::ios::fmtflags(0))
93  {
94  return toString(val.valueAngleUnits(), precision, width, fill, flags);
95  }
97  static String toString(int val, unsigned short width = 0,
98  char fill = ' ',
99  std::ios::fmtflags flags = std::ios::fmtflags(0));
100 #if OGRE_PLATFORM != OGRE_PLATFORM_NACL && ( OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_64 || OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS )
101 
102  static String toString(unsigned int val,
103  unsigned short width = 0, char fill = ' ',
104  std::ios::fmtflags flags = std::ios::fmtflags(0));
106  static String toString(size_t val,
107  unsigned short width = 0, char fill = ' ',
108  std::ios::fmtflags flags = std::ios::fmtflags(0));
109  #if OGRE_COMPILER == OGRE_COMPILER_MSVC
110 
111  static String toString(unsigned long val,
112  unsigned short width = 0, char fill = ' ',
113  std::ios::fmtflags flags = std::ios::fmtflags(0));
114  #endif
115 #else
116 
117  static String toString(size_t val,
118  unsigned short width = 0, char fill = ' ',
119  std::ios::fmtflags flags = std::ios::fmtflags(0));
121  static String toString(unsigned long val,
122  unsigned short width = 0, char fill = ' ',
123  std::ios::fmtflags flags = std::ios::fmtflags(0));
124 #endif
125 
126  static String toString(long val,
127  unsigned short width = 0, char fill = ' ',
128  std::ios::fmtflags flags = std::ios::fmtflags(0));
132  static String toString(bool val, bool yesNo = false);
137  static String toString(const Vector2& val);
142  static String toString(const Vector3& val);
147  static String toString(const Vector4& val);
152  static String toString(const Matrix3& val);
158  static String toString(const Matrix4& val);
163  static String toString(const Quaternion& val);
168  static String toString(const ColourValue& val);
174  static String toString(const StringVector& val);
175 
180  static Real parseReal(const String& val, Real defaultValue = 0);
185  static inline Radian parseAngle(const String& val, Radian defaultValue = Radian(0)) {
186  return Angle(parseReal(val, defaultValue.valueRadians()));
187  }
192  static int parseInt(const String& val, int defaultValue = 0);
197  static unsigned int parseUnsignedInt(const String& val, unsigned int defaultValue = 0);
202  static long parseLong(const String& val, long defaultValue = 0);
207  static unsigned long parseUnsignedLong(const String& val, unsigned long defaultValue = 0);
212  static size_t parseSizeT(const String& val, size_t defaultValue = 0);
219  static bool parseBool(const String& val, bool defaultValue = 0);
225  static Vector2 parseVector2(const String& val, const Vector2& defaultValue = Vector2::ZERO);
231  static Vector3 parseVector3(const String& val, const Vector3& defaultValue = Vector3::ZERO);
237  static Vector4 parseVector4(const String& val, const Vector4& defaultValue = Vector4::ZERO);
243  static Matrix3 parseMatrix3(const String& val, const Matrix3& defaultValue = Matrix3::IDENTITY);
249  static Matrix4 parseMatrix4(const String& val, const Matrix4& defaultValue = Matrix4::IDENTITY);
255  static Quaternion parseQuaternion(const String& val, const Quaternion& defaultValue = Quaternion::IDENTITY);
261  static ColourValue parseColourValue(const String& val, const ColourValue& defaultValue = ColourValue::Black);
262 
268  static StringVector parseStringVector(const String& val);
270  static bool isNumber(const String& val);
271 
272  //-----------------------------------------------------------------------
273  static void setDefaultStringLocale(const String &loc)
274  {
275  msDefaultStringLocale = loc;
276  msLocale = std::locale(msDefaultStringLocale.c_str());
277  }
278  //-----------------------------------------------------------------------
279  static String getDefaultStringLocale(void) { return msDefaultStringLocale; }
280  //-----------------------------------------------------------------------
281  static void setUseLocale(bool useLocale) { msUseLocale = useLocale; }
282  //-----------------------------------------------------------------------
283  static bool isUseLocale() { return msUseLocale; }
284  //-----------------------------------------------------------------------
285 
286  protected:
288  static std::locale msLocale;
289  static bool msUseLocale;
290  };
291 
295 }
296 
297 
298 
299 #endif
300 
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:255
Class for converting the core Ogre data types to/from Strings.
static String msDefaultStringLocale
static String getDefaultStringLocale(void)
Class representing colour.
static const Vector3 ZERO
Definition: OgreVector3.h:807
static const Matrix4 IDENTITY
Definition: OgreMatrix4.h:556
Wrapper class which identifies a value as the currently default angle type, as defined by Math::setAn...
Definition: OgreMath.h:152
static const Matrix3 IDENTITY
Definition: OgreMatrix3.h:268
A 3x3 matrix which can represent rotations around axes.
Definition: OgreMatrix3.h:68
static Radian parseAngle(const String &val, Radian defaultValue=Radian(0))
Converts a String to a Angle.
Implementation of a Quaternion, i.e.
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.
Real valueAngleUnits() const
Definition: OgreMath.h:767
static const Quaternion IDENTITY
static const Vector2 ZERO
Definition: OgreVector2.h:585
static void setUseLocale(bool useLocale)
Standard 2-dimensional vector.
Definition: OgreVector2.h:51
Wrapper class which indicates a given angle value is in Degrees.
Definition: OgreMath.h:100
vector< String >::type StringVector
Standard 3-dimensional vector.
Definition: OgreVector3.h:50
Wrapper class which indicates a given angle value is in Radians.
Definition: OgreMath.h:49
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 const ColourValue Black
static std::locale msLocale
_StringBase String
Definition: OgreCommon.h:53
static const Vector4 ZERO
Definition: OgreVector4.h:411
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
static void setDefaultStringLocale(const String &loc)
Real valueAngleUnits() const
Definition: OgreMath.h:757