OGRE: OgreString.h Source File - OGRE Documentation

# OgreString.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-2009 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 #ifndef _String_H__
    00029 #define _String_H__
    00030
    00031 #include "OgrePrerequisites.h"
    00032
    00033 // If we're using the GCC 3.1 C++ Std lib
    00034 #if OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 310 && !defined(STLPORT)
    00035
    00036 // For gcc 4.3 see http://gcc.gnu.org/gcc-4.3/changes.html
    00037 #   if OGRE_COMP_VER >= 430
    00038 #       include <tr1/unordered_map>
    00039 #   else
    00040 #       include <ext/hash_map>
    00041 namespace __gnu_cxx
    00042 {
    00043     template <> struct hash< Ogre::_StringBase >
    00044     {
    00045         size_t operator()( const Ogre::_StringBase _stringBase ) const
    00046         {
    00047             /* This is the PRO-STL way, but it seems to cause problems with VC7.1
    00048                and in some other cases (although I can't recreate it)
    00049             hash<const char*> H;
    00050             return H(_stringBase.c_str());
    00051             */
    00053             register size_t ret = 0;
    00054             for( Ogre::_StringBase::const_iterator it = _stringBase.begin(); it != _stringBase.end(); ++it )
    00055                 ret = 5 * ret + *it;
    00056
    00057             return ret;
    00058         }
    00059     };
    00060 }
    00061 #   endif
    00062
    00063 #endif
    00064
    00065 namespace Ogre {
    00074     class _OgreExport StringUtil
    00075     {
    00076     public:
    00077         typedef StringStream StrStreamType;
    00078
    00086         static void trim( String& str, bool left = true, bool right = true );
    00087
    00096         static vector<String>::type split( const String& str, const String& delims = "\t\n ", unsigned int maxSplits = 0);
    00097
    00110         static vector<String>::type tokenise( const String& str, const String& delims = "\t\n ", const String& doubleDelims = "\"", unsigned int maxSplits = 0);
    00111
    00114         static void toLowerCase( String& str );
    00115
    00118         static void toUpperCase( String& str );
    00119
    00120
    00126         static bool startsWith(const String& str, const String& pattern, bool lowerCase = true);
    00127
    00133         static bool endsWith(const String& str, const String& pattern, bool lowerCase = true);
    00134
    00137         static String standardisePath( const String &init);
    00138
    00144         static void splitFilename(const String& qualifiedName,
    00145             String& outBasename, String& outPath);
    00146
    00152         static void splitFullFilename(const Ogre::String& qualifiedName,
    00153             Ogre::String& outBasename, Ogre::String& outExtention,
    00154             Ogre::String& outPath);
    00155
    00159         static void splitBaseFilename(const Ogre::String& fullName,
    00160             Ogre::String& outBasename, Ogre::String& outExtention);
    00161
    00162
    00168         static bool match(const String& str, const String& pattern, bool caseSensitive = true);
    00169
    00170
    00177         static const String replaceAll(const String& source, const String& replaceWhat, const String& replaceWithWhat);
    00178
    00180         static const String BLANK;
    00181     };
    00182
    00183
    00184 #if OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 310 && !defined(STLPORT)
    00185 #   if OGRE_COMP_VER < 430
    00186     typedef ::__gnu_cxx::hash< _StringBase > _StringHash;
    00187 #   else
    00188     typedef ::std::tr1::hash< _StringBase > _StringHash;
    00189 #   endif
    00190 #elif OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_COMP_VER >= 1600 && !defined(STLPORT) // VC++ 10.0
    00191     typedef ::std::tr1::hash< _StringBase > _StringHash;
    00192 #elif !defined( _STLP_HASH_FUN_H )
    00193     typedef stdext::hash_compare< _StringBase, std::less< _StringBase > > _StringHash;
    00194 #else
    00195     typedef std::hash< _StringBase > _StringHash;
    00196 #endif
    00197
    00200 } // namespace Ogre
    00201
    00202 #endif // _String_H__

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Nov 3 2010 19:24:52