OGRE  1.9
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 "OgreMath.h"
36 #include "OgreMatrix3.h"
37 #include "OgreMatrix4.h"
38 #include "OgreQuaternion.h"
39 #include "OgreVector2.h"
40 #include "OgreVector3.h"
41 #include "OgreVector4.h"
42 
43 namespace Ogre {
44 
69  {
70  public:
71 
73  static String toString(Real val, unsigned short precision = 6,
74  unsigned short width = 0, char fill = ' ',
75  std::ios::fmtflags flags = std::ios::fmtflags(0));
76 #if OGRE_DOUBLE_PRECISION == 1
77 
78  static String toString(float val, unsigned short precision = 6,
79  unsigned short width = 0, char fill = ' ',
80  std::ios::fmtflags flags = std::ios::fmtflags(0));
81 #else
82 
83  static String toString(double val, unsigned short precision = 6,
84  unsigned short width = 0, char fill = ' ',
85  std::ios::fmtflags flags = std::ios::fmtflags(0));
86 #endif
87 
88  static String toString(Radian val, unsigned short precision = 6,
89  unsigned short width = 0, char fill = ' ',
90  std::ios::fmtflags flags = std::ios::fmtflags(0))
91  {
92  return toString(val.valueAngleUnits(), precision, width, fill, flags);
93  }
95  static String toString(Degree val, unsigned short precision = 6,
96  unsigned short width = 0, char fill = ' ',
97  std::ios::fmtflags flags = std::ios::fmtflags(0))
98  {
99  return toString(val.valueAngleUnits(), precision, width, fill, flags);
100  }
102  static String toString(int val, unsigned short width = 0,
103  char fill = ' ',
104  std::ios::fmtflags flags = std::ios::fmtflags(0));
105 #if OGRE_PLATFORM != OGRE_PLATFORM_NACL && ( OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_64 || OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS )
106 
107  static String toString(unsigned int val,
108  unsigned short width = 0, char fill = ' ',
109  std::ios::fmtflags flags = std::ios::fmtflags(0));
111  static String toString(size_t val,
112  unsigned short width = 0, char fill = ' ',
113  std::ios::fmtflags flags = std::ios::fmtflags(0));
114  #if OGRE_COMPILER == OGRE_COMPILER_MSVC
115 
116  static String toString(unsigned long val,
117  unsigned short width = 0, char fill = ' ',
118  std::ios::fmtflags flags = std::ios::fmtflags(0));
119  #endif
120 #else
121 
122  static String toString(size_t val,
123  unsigned short width = 0, char fill = ' ',
124  std::ios::fmtflags flags = std::ios::fmtflags(0));
126  static String toString(unsigned long val,
127  unsigned short width = 0, char fill = ' ',
128  std::ios::fmtflags flags = std::ios::fmtflags(0));
129 #endif
130 
131  static String toString(long val,
132  unsigned short width = 0, char fill = ' ',
133  std::ios::fmtflags flags = std::ios::fmtflags(0));
137  static String toString(bool val, bool yesNo = false);
142  static String toString(const Vector2& val);
147  static String toString(const Vector3& val);
152  static String toString(const Vector4& val);
157  static String toString(const Matrix3& val);
163  static String toString(const Matrix4& val);
168  static String toString(const Quaternion& val);
173  static String toString(const ColourValue& val);
179  static String toString(const StringVector& val);
180 
185  static Real parseReal(const String& val, Real defaultValue = 0);
190  static inline Radian parseAngle(const String& val, Radian defaultValue = Radian(0)) {
191  return Angle(parseReal(val, defaultValue.valueRadians()));
192  }
197  static int parseInt(const String& val, int defaultValue = 0);
202  static unsigned int parseUnsignedInt(const String& val, unsigned int defaultValue = 0);
207  static long parseLong(const String& val, long defaultValue = 0);
212  static unsigned long parseUnsignedLong(const String& val, unsigned long defaultValue = 0);
217  static size_t parseSizeT(const String& val, size_t defaultValue = 0);
223  static bool parseBool(const String& val, bool defaultValue = 0);
229  static Vector2 parseVector2(const String& val, const Vector2& defaultValue = Vector2::ZERO);
235  static Vector3 parseVector3(const String& val, const Vector3& defaultValue = Vector3::ZERO);
241  static Vector4 parseVector4(const String& val, const Vector4& defaultValue = Vector4::ZERO);
247  static Matrix3 parseMatrix3(const String& val, const Matrix3& defaultValue = Matrix3::IDENTITY);
253  static Matrix4 parseMatrix4(const String& val, const Matrix4& defaultValue = Matrix4::IDENTITY);
259  static Quaternion parseQuaternion(const String& val, const Quaternion& defaultValue = Quaternion::IDENTITY);
265  static ColourValue parseColourValue(const String& val, const ColourValue& defaultValue = ColourValue::Black);
266 
272  static StringVector parseStringVector(const String& val);
274  static bool isNumber(const String& val);
275 
276  //-----------------------------------------------------------------------
278  {
279  msDefaultStringLocale = loc;
280  msLocale = std::locale(msDefaultStringLocale.c_str());
281  }
282  //-----------------------------------------------------------------------
283  static String getDefaultStringLocale(void) { return msDefaultStringLocale; }
284  //-----------------------------------------------------------------------
285  static void setUseLocale(bool useLocale) { msUseLocale = useLocale; }
286  //-----------------------------------------------------------------------
287  static bool isUseLocale() { return msUseLocale; }
288  //-----------------------------------------------------------------------
289 
290  protected:
292  static std::locale msLocale;
293  static bool msUseLocale;
294  };
295 
299 }
300 
301 
302 
303 #endif
304 
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:260
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:800
static const Matrix4 IDENTITY
Definition: OgreMatrix4.h:511
Wrapper class which identifies a value as the currently default angle type, as defined by Math::setAn...
Definition: OgreMath.h:150
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:732
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:98
vector< String >::type StringVector
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
static void setDefaultStringLocale(String loc)
Wrapper class which indicates a given angle value is in Radians.
Definition: OgreMath.h:47
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
static const Vector4 ZERO
Definition: OgreVector4.h:411
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
Real valueAngleUnits() const
Definition: OgreMath.h:722