String.hpp
00001 
00002 //
00003 // SFML - Simple and Fast Multimedia Library
00004 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
00005 //
00006 // This software is provided 'as-is', without any express or implied warranty.
00007 // In no event will the authors be held liable for any damages arising from the use of this software.
00008 //
00009 // Permission is granted to anyone to use this software for any purpose,
00010 // including commercial applications, and to alter it and redistribute it freely,
00011 // subject to the following restrictions:
00012 //
00013 // 1. The origin of this software must not be misrepresented;
00014 //    you must not claim that you wrote the original software.
00015 //    If you use this software in a product, an acknowledgment
00016 //    in the product documentation would be appreciated but is not required.
00017 //
00018 // 2. Altered source versions must be plainly marked as such,
00019 //    and must not be misrepresented as being the original software.
00020 //
00021 // 3. This notice may not be removed or altered from any source distribution.
00022 //
00024 
00025 #ifndef SFML_STRING_HPP
00026 #define SFML_STRING_HPP
00027 
00029 // Headers
00031 #include <SFML/Config.hpp>
00032 #include <locale>
00033 #include <string>
00034 
00035 
00036 namespace sf
00037 {
00043 class SFML_API String
00044 {
00045 public :
00046 
00048     // Types
00050     typedef std::basic_string<Uint32>::iterator       Iterator;      
00051     typedef std::basic_string<Uint32>::const_iterator ConstIterator; 
00052 
00054     // Static member data
00056     static const std::size_t InvalidPos; 
00057 
00064     String();
00065 
00076     String(char ansiChar, const std::locale& locale = std::locale());
00077 
00084     String(wchar_t wideChar);
00085 
00092     String(Uint32 utf32Char);
00093 
00104     String(const char* ansiString, const std::locale& locale = std::locale());
00105 
00116     String(const std::string& ansiString, const std::locale& locale = std::locale());
00117 
00124     String(const wchar_t* wideString);
00125 
00132     String(const std::wstring& wideString);
00133 
00140     String(const Uint32* utf32String);
00141 
00148     String(const std::basic_string<Uint32>& utf32String);
00149 
00156     String(const String& copy);
00157 
00173     operator std::string() const;
00174 
00188     operator std::wstring() const;
00189 
00205     std::string ToAnsiString(const std::locale& locale = std::locale()) const;
00206 
00218     std::wstring ToWideString() const;
00219 
00228     String& operator =(const String& right);
00229 
00238     String& operator +=(const String& right);
00239 
00251     Uint32 operator [](std::size_t index) const;
00252 
00264     Uint32& operator [](std::size_t index);
00265 
00274     void Clear();
00275 
00284     std::size_t GetSize() const;
00285 
00294     bool IsEmpty() const;
00295 
00306     void Erase(std::size_t position, std::size_t count = 1);
00307 
00318     void Insert(std::size_t position, const String& str);
00319 
00332     std::size_t Find(const String& str, std::size_t start = 0) const;
00333 
00345     const Uint32* GetData() const;
00346 
00355     Iterator Begin();
00356 
00365     ConstIterator Begin() const;
00366 
00379     Iterator End();
00380 
00393     ConstIterator End() const;
00394 
00395 private :
00396 
00397     friend SFML_API bool operator ==(const String& left, const String& right);
00398     friend SFML_API bool operator <(const String& left, const String& right);
00399 
00401     // Member data
00403     std::basic_string<Uint32> myString; 
00404 };
00405 
00416 SFML_API bool operator ==(const String& left, const String& right);
00417 
00428 SFML_API bool operator !=(const String& left, const String& right);
00429 
00440 SFML_API bool operator <(const String& left, const String& right);
00441 
00452 SFML_API bool operator >(const String& left, const String& right);
00453 
00464 SFML_API bool operator <=(const String& left, const String& right);
00465 
00476 SFML_API bool operator >=(const String& left, const String& right);
00477 
00488 SFML_API String operator +(const String& left, const String& right);
00489 
00490 } // namespace sf
00491 
00492 
00493 #endif // SFML_STRING_HPP
00494 
00495