OGRE  1.8
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-2013 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) );
77  static String toString(Radian val, unsigned short precision = 6,
78  unsigned short width = 0, char fill = ' ',
79  std::ios::fmtflags flags = std::ios::fmtflags(0) )
80  {
81  return toString(val.valueAngleUnits(), precision, width, fill, flags);
82  }
84  static String toString(Degree val, unsigned short precision = 6,
85  unsigned short width = 0, char fill = ' ',
86  std::ios::fmtflags flags = std::ios::fmtflags(0) )
87  {
88  return toString(val.valueAngleUnits(), precision, width, fill, flags);
89  }
91  static String toString(int val, unsigned short width = 0,
92  char fill = ' ',
93  std::ios::fmtflags flags = std::ios::fmtflags(0) );
94 #if OGRE_PLATFORM != OGRE_PLATFORM_NACL && ( OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_64 || OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS )
95 
96  static String toString(unsigned int val,
97  unsigned short width = 0, char fill = ' ',
98  std::ios::fmtflags flags = std::ios::fmtflags(0) );
100  static String toString(size_t val,
101  unsigned short width = 0, char fill = ' ',
102  std::ios::fmtflags flags = std::ios::fmtflags(0) );
103  #if OGRE_COMPILER == OGRE_COMPILER_MSVC
104 
105  static String toString(unsigned long val,
106  unsigned short width = 0, char fill = ' ',
107  std::ios::fmtflags flags = std::ios::fmtflags(0) );
108 
109  #endif
110 #else
111 
112  static String toString(size_t val,
113  unsigned short width = 0, char fill = ' ',
114  std::ios::fmtflags flags = std::ios::fmtflags(0) );
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 
121  static String toString(long val,
122  unsigned short width = 0, char fill = ' ',
123  std::ios::fmtflags flags = std::ios::fmtflags(0) );
127  static String toString(bool val, bool yesNo = false);
132  static String toString(const Vector2& val);
137  static String toString(const Vector3& val);
142  static String toString(const Vector4& val);
147  static String toString(const Matrix3& val);
153  static String toString(const Matrix4& val);
158  static String toString(const Quaternion& val);
163  static String toString(const ColourValue& val);
169  static String toString(const StringVector& val);
170 
175  static Real parseReal(const String& val, Real defaultValue = 0);
180  static inline Radian parseAngle(const String& val, Radian defaultValue = Radian(0)) {
181  return Angle(parseReal(val, defaultValue.valueRadians()));
182  }
187  static int parseInt(const String& val, int defaultValue = 0);
192  static unsigned int parseUnsignedInt(const String& val, unsigned int defaultValue = 0);
197  static long parseLong(const String& val, long defaultValue = 0);
202  static unsigned long parseUnsignedLong(const String& val, unsigned long defaultValue = 0);
207  static size_t parseSizeT(const String& val, size_t defaultValue = 0);
213  static bool parseBool(const String& val, bool defaultValue = 0);
219  static Vector2 parseVector2(const String& val, const Vector2& defaultValue = Vector2::ZERO);
225  static Vector3 parseVector3(const String& val, const Vector3& defaultValue = Vector3::ZERO);
231  static Vector4 parseVector4(const String& val, const Vector4& defaultValue = Vector4::ZERO);
237  static Matrix3 parseMatrix3(const String& val, const Matrix3& defaultValue = Matrix3::IDENTITY);
243  static Matrix4 parseMatrix4(const String& val, const Matrix4& defaultValue = Matrix4::IDENTITY);
249  static Quaternion parseQuaternion(const String& val, const Quaternion& defaultValue = Quaternion::IDENTITY);
255  static ColourValue parseColourValue(const String& val, const ColourValue& defaultValue = ColourValue::Black);
256 
262  static StringVector parseStringVector(const String& val);
264  static bool isNumber(const String& val);
265  };
266 
270 }
271 
272 
273 
274 #endif
275 
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:233
Class for converting the core Ogre data types to/from Strings.
Class representing colour.
static const Vector3 ZERO
Definition: OgreVector3.h:796
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:149
static const Matrix3 IDENTITY
Definition: OgreMatrix3.h:260
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:705
static const Quaternion IDENTITY
static const Vector2 ZERO
Definition: OgreVector2.h:589
Standard 2-dimensional vector.
Definition: OgreVector2.h:51
Wrapper class which indicates a given angle value is in Degrees.
Definition: OgreMath.h:97
vector< String >::type StringVector
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
Wrapper class which indicates a given angle value is in Radians.
Definition: OgreMath.h:46
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
_StringBase String
static const Vector4 ZERO
Definition: OgreVector4.h:407
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
Real valueAngleUnits() const
Definition: OgreMath.h:695