Loading...
Searching...
No Matches
String.hpp
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#ifndef SFML_STRING_HPP
26#define SFML_STRING_HPP
27
29// Headers
32#include <locale>
33#include <string>
34
35
36namespace sf
37{
44{
45public :
46
48 // Types
50 typedef std::basic_string<Uint32>::iterator Iterator;
51 typedef std::basic_string<Uint32>::const_iterator ConstIterator;
52
54 // Static member data
56 static const std::size_t InvalidPos;
57
65
76 String(char ansiChar, const std::locale& locale = std::locale());
77
84 String(wchar_t wideChar);
85
92 String(Uint32 utf32Char);
93
104 String(const char* ansiString, const std::locale& locale = std::locale());
105
116 String(const std::string& ansiString, const std::locale& locale = std::locale());
117
124 String(const wchar_t* wideString);
125
132 String(const std::wstring& wideString);
133
140 String(const Uint32* utf32String);
141
148 String(const std::basic_string<Uint32>& utf32String);
149
156 String(const String& copy);
157
173 operator std::string() const;
174
188 operator std::wstring() const;
189
205 std::string toAnsiString(const std::locale& locale = std::locale()) const;
206
218 std::wstring toWideString() const;
219
228 String& operator =(const String& right);
229
238 String& operator +=(const String& right);
239
251 Uint32 operator [](std::size_t index) const;
252
264 Uint32& operator [](std::size_t index);
265
274 void clear();
275
284 std::size_t getSize() const;
285
294 bool isEmpty() const;
295
306 void erase(std::size_t position, std::size_t count = 1);
307
318 void insert(std::size_t position, const String& str);
319
332 std::size_t find(const String& str, std::size_t start = 0) const;
333
345 const Uint32* getData() const;
346
356
366
380
394
395private :
396
397 friend SFML_SYSTEM_API bool operator ==(const String& left, const String& right);
398 friend SFML_SYSTEM_API bool operator <(const String& left, const String& right);
399
401 // Member data
403 std::basic_string<Uint32> m_string;
404};
405
416SFML_SYSTEM_API bool operator ==(const String& left, const String& right);
417
428SFML_SYSTEM_API bool operator !=(const String& left, const String& right);
429
440SFML_SYSTEM_API bool operator <(const String& left, const String& right);
441
452SFML_SYSTEM_API bool operator >(const String& left, const String& right);
453
464SFML_SYSTEM_API bool operator <=(const String& left, const String& right);
465
476SFML_SYSTEM_API bool operator >=(const String& left, const String& right);
477
488SFML_SYSTEM_API String operator +(const String& left, const String& right);
489
490} // namespace sf
491
492
493#endif // SFML_STRING_HPP
494
495
#define SFML_SYSTEM_API
Color operator+(const Color &left, const Color &right)
Overload of the binary + operator.
String(const std::string &ansiString, const std::locale &locale=std::locale())
Construct from an ANSI string and a locale.
ConstIterator begin() const
Return an iterator to the beginning of the string.
bool isEmpty() const
Check whether the string is empty or not.
void clear()
Clear the string.
const Uint32 * getData() const
Get a pointer to the C-style array of characters.
String(const wchar_t *wideString)
Construct from null-terminated C-style wide string.
String(const char *ansiString, const std::locale &locale=std::locale())
Construct from a null-terminated C-style ANSI string and a locale.
String(const std::wstring &wideString)
Construct from a wide string.
String(const std::basic_string< Uint32 > &utf32String)
Construct from an UTF-32 string.
std::basic_string< Uint32 >::const_iterator ConstIterator
Constant iterator type.
Definition String.hpp:51
String(Uint32 utf32Char)
Construct from single UTF-32 character.
Iterator begin()
Return an iterator to the beginning of the string.
String()
Default constructor.
std::wstring toWideString() const
Convert the unicode string to a wide string.
std::size_t find(const String &str, std::size_t start=0) const
Find a sequence of one or more characters in the string.
void erase(std::size_t position, std::size_t count=1)
Erase one or more characters from the string.
static const std::size_t InvalidPos
Represents an invalid position in the string.
Definition String.hpp:56
Iterator end()
Return an iterator to the beginning of the string.
std::basic_string< Uint32 >::iterator Iterator
Iterator type.
Definition String.hpp:50
String(char ansiChar, const std::locale &locale=std::locale())
Construct from a single ANSI character and a locale.
void insert(std::size_t position, const String &str)
Insert one or more characters into the string.
std::string toAnsiString(const std::locale &locale=std::locale()) const
Convert the unicode string to an ANSI string.
std::size_t getSize() const
Get the size of the string.
String(const Uint32 *utf32String)
Construct from a null-terminated C-style UTF-32 string.
String(wchar_t wideChar)
Construct from single wide character.
ConstIterator end() const
Return an iterator to the beginning of the string.
String(const String &copy)
Copy constructor.
bool operator==(const IpAddress &left, const IpAddress &right)
Overload of == operator to compare two IP addresses.
bool operator>=(const IpAddress &left, const IpAddress &right)
Overload of >= operator to compare two IP addresses.
bool operator!=(const IpAddress &left, const IpAddress &right)
Overload of != operator to compare two IP addresses.
bool operator<=(const IpAddress &left, const IpAddress &right)
Overload of <= operator to compare two IP addresses.
unsigned int Uint32
Definition Config.hpp:145
bool operator<(const IpAddress &left, const IpAddress &right)
Overload of < operator to compare two IP addresses.
bool operator>(const IpAddress &left, const IpAddress &right)
Overload of > operator to compare two IP addresses.