25#ifndef SFML_STRING_HPP
26#define SFML_STRING_HPP
31#include <SFML/System/Export.hpp>
32#include <SFML/System/Utf.hpp>
52 typedef std::basic_string<Uint32>::iterator
Iterator;
78 String(
char ansiChar,
const std::locale& locale = std::locale());
106 String(
const char* ansiString,
const std::locale& locale = std::locale());
118 String(
const std::string& ansiString,
const std::locale& locale = std::locale());
150 String(
const std::basic_string<Uint32>& utf32String);
171 template <
typename T>
185 template <
typename T>
203 template <
typename T>
221 operator std::string()
const;
236 operator std::wstring()
const;
253 std::string
toAnsiString(
const std::locale& locale = std::locale())
const;
332 Uint32 operator [](std::size_t index)
const;
345 Uint32& operator [](std::size_t index);
387 void erase(std::size_t position, std::size_t count = 1);
413 std::size_t
find(
const String& str, std::size_t start = 0)
const;
427 void replace(std::size_t position, std::size_t length,
const String& replaceWith);
521 friend SFML_SYSTEM_API
bool operator ==(
const String& left,
const String& right);
522 friend SFML_SYSTEM_API
bool operator <(
const String& left,
const String& right);
527 std::basic_string<Uint32> m_string;
540SFML_SYSTEM_API
bool operator ==(
const String& left,
const String& right);
552SFML_SYSTEM_API
bool operator !=(
const String& left,
const String& right);
564SFML_SYSTEM_API
bool operator <(
const String& left,
const String& right);
576SFML_SYSTEM_API
bool operator >(
const String& left,
const String& right);
588SFML_SYSTEM_API
bool operator <=(
const String& left,
const String& right);
600SFML_SYSTEM_API
bool operator >=(
const String& left,
const String& right);
614#include <SFML/System/String.inl>
Utility string class that automatically handles conversions between types and encodings.
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.
std::basic_string< Uint8 > toUtf8() const
Convert the Unicode string to a UTF-8 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 substring(std::size_t position, std::size_t length=InvalidPos) const
Return a part of the string.
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.
static String fromUtf16(T begin, T end)
Create a new sf::String from a UTF-16 encoded string.
void replace(const String &searchFor, const String &replaceWith)
Replace all occurrences of a substring with a replacement string.
std::basic_string< Uint32 >::const_iterator ConstIterator
Read-only iterator type.
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.
static String fromUtf8(T begin, T end)
Create a new sf::String from a UTF-8 encoded string.
void erase(std::size_t position, std::size_t count=1)
Erase one or more characters from the string.
static String fromUtf32(T begin, T end)
Create a new sf::String from a UTF-32 encoded string.
std::basic_string< Uint16 > toUtf16() const
Convert the Unicode string to a UTF-16 string.
static const std::size_t InvalidPos
Represents an invalid position in the string.
Iterator end()
Return an iterator to the end of the string.
std::basic_string< Uint32 >::iterator Iterator
Iterator type.
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.
void replace(std::size_t position, std::size_t length, const String &replaceWith)
Replace a substring with another 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.
std::basic_string< Uint32 > toUtf32() const
Convert the Unicode string to a UTF-32 string.
String(wchar_t wideChar)
Construct from single wide character.
ConstIterator end() const
Return an iterator to the end of the string.
String(const String ©)
Copy constructor.