25 #ifndef CPP3DS_STRING_HPP
26 #define CPP3DS_STRING_HPP
31 #include <cpp3ds/System/Utf.hpp>
49 typedef std::basic_string<Uint32>::iterator
Iterator;
75 String(
char ansiChar,
const std::locale& locale = std::locale());
103 String(
const char* ansiString,
const std::locale& locale = std::locale());
115 String(
const std::string& ansiString,
const std::locale& locale = std::locale());
123 String(
const wchar_t* wideString);
131 String(
const std::wstring& wideString);
139 String(
const Uint32* utf32String);
147 String(
const std::basic_string<Uint32>& utf32String);
168 template <
typename T>
182 template <
typename T>
200 template <
typename T>
218 operator std::string()
const;
233 operator std::wstring()
const;
250 std::string
toAnsiString(
const std::locale& locale = std::locale())
const;
273 std::basic_string<Uint8>
toUtf8()
const;
283 std::basic_string<Uint16>
toUtf16()
const;
296 std::basic_string<Uint32>
toUtf32()
const;
384 void erase(std::size_t position, std::size_t count = 1);
410 std::size_t
find(
const String& str, std::size_t start = 0)
const;
424 void replace(std::size_t position, std::size_t length,
const String& replaceWith);
453 String substring(std::size_t position, std::size_t length = InvalidPos)
const;
486 ConstIterator
begin()
const;
514 ConstIterator
end()
const;
518 friend bool operator ==(
const String& left,
const String& right);
519 friend bool operator <(
const String& left,
const String& right);
524 std::basic_string<Uint32> m_string;
537 bool operator ==(
const String& left,
const String& right);
549 bool operator !=(
const String& left,
const String& right);
561 bool operator <(
const String& left,
const String& right);
573 bool operator >(
const String& left,
const String& right);
585 bool operator <=(
const String& left,
const String& right);
597 bool operator >=(
const String& left,
const String& right);
611 #include <cpp3ds/System/String.inl>
Uint32 operator[](std::size_t index) const
Overload of [] operator to access a character by its position.
Iterator end()
Return an iterator to the beginning of the string.
String()
Default constructor.
std::basic_string< Uint32 >::iterator Iterator
Iterator type.
bool isEmpty() const
Check whether the string is empty or not.
static String fromUtf8(T begin, T end)
Create a new cpp3ds::String from a UTF-8 encoded string.
void clear()
Clear the string.
Utility string class that automatically handles conversions between types and encodings.
const Uint32 * getData() const
Get a pointer to the C-style array of characters.
Iterator begin()
Return an iterator to the beginning of the string.
void replace(std::size_t position, std::size_t length, const String &replaceWith)
Replace a substring with another string.
String & operator+=(const String &right)
Overload of += operator to append an UTF-32 string.
std::size_t getSize() const
Get the size of the string.
static String fromUtf16(T begin, T end)
Create a new cpp3ds::String from a UTF-16 encoded string.
std::string toAnsiString(const std::locale &locale=std::locale()) const
Convert the unicode string to an ANSI string.
void insert(std::size_t position, const String &str)
Insert one or more characters into the string.
static const std::size_t InvalidPos
Represents an invalid position in the 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 fromUtf32(T begin, T end)
Create a new cpp3ds::String from a UTF-32 encoded string.
String substring(std::size_t position, std::size_t length=InvalidPos) const
Return a part of the string.
std::basic_string< Uint32 > toUtf32() const
Convert the unicode string to a UTF-32 string.
std::basic_string< Uint32 >::const_iterator ConstIterator
Constant iterator type.
void erase(std::size_t position, std::size_t count=1)
Erase one or more characters from the string.
std::wstring toWideString() const
Convert the unicode string to a wide string.
std::basic_string< Uint16 > toUtf16() const
Convert the unicode string to a UTF-16 string.
std::basic_string< Uint8 > toUtf8() const
Convert the unicode string to a UTF-8 string.
String & operator=(const String &right)
Overload of assignment operator.