OgreStringConverter.h
Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004     (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright (c) 2000-2012 Torus Knot Software Ltd
    00008
    00009 Permission is hereby granted, free of charge, to any person obtaining a copy
    00010 of this software and associated documentation files (the "Software"), to deal
    00011 in the Software without restriction, including without limitation the rights
    00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    00013 copies of the Software, and to permit persons to whom the Software is
    00014 furnished to do so, subject to the following conditions:
    00015
    00016 The above copyright notice and this permission notice shall be included in
    00017 all copies or substantial portions of the Software.
    00018
    00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    00025 THE SOFTWARE.
    00026 -----------------------------------------------------------------------------
    00027 */
    00028
    00029 #ifndef __StringConverter_H__
    00030 #define __StringConverter_H__
    00031
    00032 #include "OgrePrerequisites.h"
    00033 #include "OgreStringVector.h"
    00034 #include "OgreColourValue.h"
    00035 #include "OgreMath.h"
    00036 #include "OgreMatrix3.h"
    00037 #include "OgreMatrix4.h"
    00038 #include "OgreQuaternion.h"
    00039 #include "OgreVector2.h"
    00040 #include "OgreVector3.h"
    00041 #include "OgreVector4.h"
    00042
    00043 namespace Ogre {
    00044
    00068     class _OgreExport StringConverter
    00069     {
    00070     public:
    00071
    00073         static String toString(Real val, unsigned short precision = 6,
    00074             unsigned short width = 0, char fill = ' ',
    00075             std::ios::fmtflags flags = std::ios::fmtflags(0) );
    00077         static String toString(Radian val, unsigned short precision = 6,
    00078             unsigned short width = 0, char fill = ' ',
    00079             std::ios::fmtflags flags = std::ios::fmtflags(0) )
    00080         {
    00081             return toString(val.valueAngleUnits(), precision, width, fill, flags);
    00082         }
    00084         static String toString(Degree val, unsigned short precision = 6,
    00085             unsigned short width = 0, char fill = ' ',
    00086             std::ios::fmtflags flags = std::ios::fmtflags(0) )
    00087         {
    00088             return toString(val.valueAngleUnits(), precision, width, fill, flags);
    00089         }
    00091         static String toString(int val, unsigned short width = 0,
    00092             char fill = ' ',
    00093             std::ios::fmtflags flags = std::ios::fmtflags(0) );
    00094 #if OGRE_PLATFORM != OGRE_PLATFORM_NACL &&  ( OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_64 || OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS )
    00095
    00096         static String toString(unsigned int val,
    00097             unsigned short width = 0, char fill = ' ',
    00098             std::ios::fmtflags flags = std::ios::fmtflags(0) );
    00100         static String toString(size_t val,
    00101             unsigned short width = 0, char fill = ' ',
    00102             std::ios::fmtflags flags = std::ios::fmtflags(0) );
    00103         #if OGRE_COMPILER == OGRE_COMPILER_MSVC
    00104
    00105                 static String toString(unsigned long val,
    00106                     unsigned short width = 0, char fill = ' ',
    00107                     std::ios::fmtflags flags = std::ios::fmtflags(0) );
    00108
    00109         #endif
    00110 #else
    00111
    00112         static String toString(size_t val,
    00113             unsigned short width = 0, char fill = ' ',
    00114             std::ios::fmtflags flags = std::ios::fmtflags(0) );
    00116         static String toString(unsigned long val,
    00117             unsigned short width = 0, char fill = ' ',
    00118             std::ios::fmtflags flags = std::ios::fmtflags(0) );
    00119 #endif
    00120
    00121         static String toString(long val,
    00122             unsigned short width = 0, char fill = ' ',
    00123             std::ios::fmtflags flags = std::ios::fmtflags(0) );
    00127         static String toString(bool val, bool yesNo = false);
    00132         static String toString(const Vector2& val);
    00137         static String toString(const Vector3& val);
    00142         static String toString(const Vector4& val);
    00147         static String toString(const Matrix3& val);
    00153         static String toString(const Matrix4& val);
    00158         static String toString(const Quaternion& val);
    00163         static String toString(const ColourValue& val);
    00169         static String toString(const StringVector& val);
    00170
    00175         static Real parseReal(const String& val, Real defaultValue = 0);
    00180         static inline Radian parseAngle(const String& val, Radian defaultValue = Radian(0)) {
    00181             return Angle(parseReal(val, defaultValue.valueRadians()));
    00182         }
    00187         static int parseInt(const String& val, int defaultValue = 0);
    00192         static unsigned int parseUnsignedInt(const String& val, unsigned int defaultValue = 0);
    00197         static long parseLong(const String& val, long defaultValue = 0);
    00202         static unsigned long parseUnsignedLong(const String& val, unsigned long defaultValue = 0);
    00207         static size_t parseSizeT(const String& val, size_t defaultValue = 0);
    00213         static bool parseBool(const String& val, bool defaultValue = 0);
    00219         static Vector2 parseVector2(const String& val, const Vector2& defaultValue = Vector2::ZERO);
    00225         static Vector3 parseVector3(const String& val, const Vector3& defaultValue = Vector3::ZERO);
    00231         static Vector4 parseVector4(const String& val, const Vector4& defaultValue = Vector4::ZERO);
    00237         static Matrix3 parseMatrix3(const String& val, const Matrix3& defaultValue = Matrix3::IDENTITY);
    00243         static Matrix4 parseMatrix4(const String& val, const Matrix4& defaultValue = Matrix4::IDENTITY);
    00249         static Quaternion parseQuaternion(const String& val, const Quaternion& defaultValue = Quaternion::IDENTITY);
    00255         static ColourValue parseColourValue(const String& val, const ColourValue& defaultValue = ColourValue::Black);
    00256
    00262         static StringVector parseStringVector(const String& val);
    00264         static bool isNumber(const String& val);
    00265     };
    00266
    00270 }
    00271
    00272
    00273
    00274 #endif
    00275

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun Sep 2 2012 07:27:24