OGRE: OgreString.h Source File - OGRE Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

# 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-2006 Torus Knot Software Ltd
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023
    00024 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029 #ifndef _String_H__
    00030 #define _String_H__
    00031
    00032 #include "OgrePrerequisites.h"
    00033
    00034 // If we're using the GCC 3.1 C++ Std lib
    00035 #if OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 310 && !defined(STLPORT)
    00036
    00037 #include <ext/hash_map>
    00038 namespace __gnu_cxx
    00039 {
    00040     template <> struct hash< Ogre::_StringBase >
    00041     {
    00042         size_t operator()( const Ogre::_StringBase _stringBase ) const
    00043         {
    00044             /* This is the PRO-STL way, but it seems to cause problems with VC7.1
    00045                and in some other cases (although I can't recreate it)
    00046             hash<const char*> H;
    00047             return H(_stringBase.c_str());
    00048             */
    00050             register size_t ret = 0;
    00051             for( Ogre::_StringBase::const_iterator it = _stringBase.begin(); it != _stringBase.end(); ++it )
    00052                 ret = 5 * ret + *it;
    00053
    00054             return ret;
    00055         }
    00056     };
    00057 }
    00058
    00059 #endif
    00060
    00061 namespace Ogre {
    00062
    00064     class _OgreExport StringUtil
    00065     {
    00066     public:
    00067         typedef std::ostringstream StrStreamType;
    00068
    00076         static void trim( String& str, bool left = true, bool right = true );
    00077
    00086         static std::vector< String > split( const String& str, const String& delims = "\t\n ", unsigned int maxSplits = 0);
    00087
    00090         static void toLowerCase( String& str );
    00091
    00094         static void toUpperCase( String& str );
    00095
    00096
    00102         static bool startsWith(const String& str, const String& pattern, bool lowerCase = true);
    00103
    00109         static bool endsWith(const String& str, const String& pattern, bool lowerCase = true);
    00110
    00113         static String standardisePath( const String &init);
    00114
    00120         static void splitFilename(const String& qualifiedName,
    00121             String& outBasename, String& outPath);
    00122
    00128         static void splitFullFilename(const Ogre::String& qualifiedName,
    00129             Ogre::String& outBasename, Ogre::String& outExtention,
    00130             Ogre::String& outPath);
    00131
    00135         static void splitBaseFilename(const Ogre::String& fullName,
    00136             Ogre::String& outBasename, Ogre::String& outExtention);
    00137
    00138
    00144         static bool match(const String& str, const String& pattern, bool caseSensitive = true);
    00145
    00146
    00147
    00148
    00149
    00151         static const String BLANK;
    00152     };
    00153
    00154
    00155 #if OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 310 && !defined(STLPORT)
    00156     typedef ::__gnu_cxx::hash< _StringBase > _StringHash;
    00157 #elif !defined( _STLP_HASH_FUN_H )
    00158     typedef stdext::hash_compare< _StringBase, std::less< _StringBase > > _StringHash;
    00159 #else
    00160     typedef std::hash< _StringBase > _StringHash;
    00161 #endif
    00162
    00163 } // namespace Ogre
    00164
    00165 #endif // _String_H__

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Thu Mar 6 09:46:26 2008