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-2005 The OGRE Team
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 */
00025 #ifndef _String_H__
00026 #define _String_H__
00027 
00028 #include "OgrePrerequisites.h"
00029 
00030 // If we're using the GCC 3.1 C++ Std lib
00031 #if OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 310 && !defined(STLPORT)
00032 
00033 #include <ext/hash_map>
00034 namespace __gnu_cxx
00035 {
00036     template <> struct hash< Ogre::_StringBase >
00037     {
00038         size_t operator()( const Ogre::_StringBase _stringBase ) const
00039         {
00040             /* This is the PRO-STL way, but it seems to cause problems with VC7.1
00041                and in some other cases (although I can't recreate it)
00042             hash<const char*> H;
00043             return H(_stringBase.c_str());
00044             */
00046             register size_t ret = 0;
00047             for( Ogre::_StringBase::const_iterator it = _stringBase.begin(); it != _stringBase.end(); ++it )
00048                 ret = 5 * ret + *it;
00049 
00050             return ret;
00051         }
00052     };
00053 }
00054 
00055 #endif
00056 
00057 namespace Ogre {
00058 
00060     class _OgreExport StringUtil
00061     {
00062     public:
00063         typedef std::ostringstream StrStreamType;
00064 
00072         static void trim( String& str, bool left = true, bool right = true );
00073 
00082         static std::vector< String > split( const String& str, const String& delims = "\t\n ", unsigned int maxSplits = 0);
00083 
00086         static void toLowerCase( String& str );
00087 
00090         static void toUpperCase( String& str );
00091 
00092 
00098         static bool startsWith(const String& str, const String& pattern, bool lowerCase = true);
00099 
00105         static bool endsWith(const String& str, const String& pattern, bool lowerCase = true);
00106 
00109         static String standardisePath( const String &init);
00110 
00116         static void splitFilename(const String& qualifiedName,
00117             String& outBasename, String& outPath);
00118 
00124         static bool match(const String& str, const String& pattern, bool caseSensitive = true);
00125 
00126 
00127 
00128 
00129 
00131         static const String BLANK;
00132     };
00133 
00134 
00135 #if OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 310 && !defined(STLPORT)
00136     typedef ::__gnu_cxx::hash< _StringBase > _StringHash;
00137 #elif !defined( _STLP_HASH_FUN_H )
00138     typedef stdext::hash_compare< _StringBase, std::less< _StringBase > > _StringHash;
00139 #else
00140     typedef std::hash< _StringBase > _StringHash;
00141 #endif
00142 
00143 } // namespace Ogre
00144 
00145 #endif // _String_H__

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Jun 11 10:46:41 2006