OgreString.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef _String_H__
#define _String_H__
#include "OgrePrerequisites.h"
#include "OgreHeaderPrefix.h"
// If we're using the GCC 3.1 C++ Std lib
#if OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 310 && !defined(STLPORT)
// For gcc 4.3 see http://gcc.gnu.org/gcc-4.3/changes.html
# if OGRE_COMP_VER >= 430
# include <tr1/unordered_map>
# else
# include <ext/hash_map>
namespace __gnu_cxx
{
template <> struct hash< Ogre::_StringBase >
{
size_t operator()( const Ogre::_StringBase _stringBase ) const
{
/* This is the PRO-STL way, but it seems to cause problems with VC7.1
and in some other cases (although I can't recreate it)
hash<const char*> H;
return H(_stringBase.c_str());
*/
register size_t ret = 0;
for( Ogre::_StringBase::const_iterator it = _stringBase.begin(); it != _stringBase.end(); ++it )
ret = 5 * ret + *it;
return ret;
}
};
}
# endif
#endif
namespace Ogre {
class _OgreExport StringUtil
{
public:
typedef StringStream StrStreamType;
static void trim( String& str, bool left = true, bool right = true );
static vector<String>::type split( const String& str, const String& delims = "\t\n ", unsigned int maxSplits = 0, bool preserveDelims = false);
static vector<String>::type tokenise( const String& str, const String& delims = "\t\n ", const String& doubleDelims = "\"", unsigned int maxSplits = 0);
static void toLowerCase( String& str );
static void toUpperCase( String& str );
static bool startsWith(const String& str, const String& pattern, bool lowerCase = true);
static bool endsWith(const String& str, const String& pattern, bool lowerCase = true);
static String standardisePath( const String &init);
static String normalizeFilePath(const String& init, bool makeLowerCase = true);
static void splitFilename(const String& qualifiedName,
String& outBasename, String& outPath);
static void splitFullFilename(const Ogre::String& qualifiedName,
Ogre::String& outBasename, Ogre::String& outExtention,
Ogre::String& outPath);
static void splitBaseFilename(const Ogre::String& fullName,
Ogre::String& outBasename, Ogre::String& outExtention);
static bool match(const String& str, const String& pattern, bool caseSensitive = true);
static const String replaceAll(const String& source, const String& replaceWhat, const String& replaceWithWhat);
static const String BLANK;
};
#if OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 310 && !defined(STLPORT)
# if OGRE_COMP_VER < 430
typedef ::__gnu_cxx::hash< _StringBase > _StringHash;
# else
typedef ::std::tr1::hash< _StringBase > _StringHash;
# endif
#elif OGRE_COMPILER == OGRE_COMPILER_CLANG
# if defined(_LIBCPP_VERSION)
typedef ::std::hash< _StringBase > _StringHash;
# else
typedef ::std::tr1::hash< _StringBase > _StringHash;
# endif
#elif OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_COMP_VER >= 1600 && !defined(STLPORT) // VC++ 10.0
typedef ::std::tr1::hash< _StringBase > _StringHash;
#elif !defined( _STLP_HASH_FUN_H )
typedef stdext::hash_compare< _StringBase, std::less< _StringBase > > _StringHash;
#else
typedef std::hash< _StringBase > _StringHash;
#endif
} // namespace Ogre
#include "OgreHeaderSuffix.h"
#if OGRE_DEBUG_MODE && (OGRE_PLATFORM == OGRE_PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WINRT)
# pragma push_macro("NOMINMAX")
# define NOMINMAX
# include <windows.h>
# pragma pop_macro("NOMINMAX")
# define Ogre_OutputCString(str) ::OutputDebugStringA(str)
# define Ogre_OutputWString(str) ::OutputDebugStringW(str)
#else
# define Ogre_OutputCString(str) std::cerr << str
# define Ogre_OutputWString(str) std::cerr << str
#endif
#endif // _String_H__
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::StringUtil::StrStreamType
StringStream StrStreamType
Definition: OgreString.h:78
Ogre::_StringHash
stdext::hash_compare< _StringBase, std::less< _StringBase > > _StringHash
Definition: OgreString.h:215
Ogre::StringUtil
Utility class for manipulating Strings.
Definition: OgreString.h:75
OgrePrerequisites.h
Ogre::_StringBase
std::string _StringBase
Definition: OgrePrerequisites.h:434
Ogre::StringStream
_StringStreamBase StringStream
Definition: OgrePrerequisites.h:440
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
OgreHeaderSuffix.h
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::vector
Definition: OgrePrerequisites.h:491
OgreHeaderPrefix.h
Ogre::StringUtil::BLANK
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.