TGUI  0.9.3

Wrapper class to store strings. More...

#include <TGUI/String.hpp>

Public Types

using iterator = std::u32string::iterator
 
using const_iterator = std::u32string::const_iterator
 
using reverse_iterator = std::u32string::reverse_iterator
 
using const_reverse_iterator = std::u32string::const_reverse_iterator
 
using value_type = char32_t
 
using reference = char32_t &
 
using const_reference = const char32_t &
 

Public Member Functions

bool attemptToInt (int &result) const
 Converts the string to an integer. More...
 
bool attemptToUInt (unsigned int &result) const
 Converts the string to an unsigned int. More...
 
bool attemptToFloat (float &result) const
 Converts the string to a float. More...
 
int toInt (int defaultValue=0) const
 Converts the string to an integer. More...
 
unsigned int toUInt (unsigned int defaultValue=0) const
 Converts the string to an unsigned int. More...
 
float toFloat (float defaultValue=0) const
 Converts the string to a float. More...
 
String trim () const
 Returns a string with the whitespace at the start and end of this string removed. More...
 
String toLower () const
 Converts the ASCII characters in the string to lowercase. More...
 
String toUpper () const
 Converts the ASCII characters in the string to uppercase. More...
 
bool equalIgnoreCase (const String &other) const
 Compares this string to another and checks if they are equal if ASCII letters would have been lowercase. More...
 
bool startsWith (const String &substring) const
 Checks whether the first part of the string matches the given substring. More...
 
bool endsWith (const String &substring) const
 Checks whether the last part of the string matches the given substring. More...
 
Stringreplace (const String &searchFor, const String &replaceWith)
 Replaces all occurrences of a substring with a replacement string. More...
 
std::vector< Stringsplit (char32_t delimiter, bool trim=false) const
 Splits the string into multiple substrings given the delimiter that separates them. More...
 
 String (const std::string &str)
 
 String (const std::wstring &str)
 
 String (const std::u16string &str)
 
 String (const std::u32string &str)
 
 String (std::u32string &&str)
 
 String (char ansiChar)
 
 String (wchar_t wideChar)
 
 String (char16_t utfChar)
 
 String (char32_t utfChar)
 
 String (const char *str)
 
 String (const wchar_t *str)
 
 String (const char16_t *str)
 
 String (const char32_t *str)
 
template<typename T , typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
 String (T number)
 
 String (std::size_t count, char ch)
 
 String (std::size_t count, wchar_t ch)
 
 String (std::size_t count, char16_t ch)
 
 String (std::size_t count, char32_t ch)
 
 String (const std::string &str, std::size_t pos)
 
 String (const std::wstring &str, std::size_t pos)
 
 String (const std::u16string &str, std::size_t pos)
 
 String (const std::u32string &str, std::size_t pos)
 
 String (const std::string &str, std::size_t pos, std::size_t count)
 
 String (const std::wstring &str, std::size_t pos, std::size_t count)
 
 String (const std::u16string &str, std::size_t pos, std::size_t count)
 
 String (const std::u32string &str, std::size_t pos, std::size_t count)
 
 String (const char *str, std::size_t count)
 
 String (const wchar_t *str, std::size_t count)
 
 String (const char16_t *str, std::size_t count)
 
 String (const char32_t *str, std::size_t count)
 
 String (std::initializer_list< char > chars)
 
 String (std::initializer_list< wchar_t > chars)
 
 String (std::initializer_list< char16_t > chars)
 
 String (std::initializer_list< char32_t > chars)
 
 String (std::string::const_iterator first, std::string::const_iterator last)
 
 String (std::wstring::const_iterator first, std::wstring::const_iterator last)
 
 String (std::u16string::const_iterator first, std::u16string::const_iterator last)
 
 String (std::u32string::const_iterator first, std::u32string::const_iterator last)
 
template<typename StringViewType , typename = IsStringViewType<StringViewType>>
 String (const StringViewType &stringView)
 
template<typename StringViewType , typename = IsStringViewType<StringViewType>>
 String (const StringViewType &stringView, std::size_t pos, std::size_t count)
 
 String (const sf::String &str)
 
 operator sf::String () const
 
 operator std::string () const
 
 operator std::wstring () const
 
 operator std::u16string () const
 
 operator const std::u32string & () const
 
 operator std::u32string_view () const noexcept
 
std::string toAnsiString () const
 
std::string toStdString () const
 
std::wstring toWideString () const
 
std::u16string toUtf16 () const
 
const std::u32string & toUtf32 () const
 
std::string toUtf8 () const
 
Stringassign (std::size_t count, char ch)
 
Stringassign (std::size_t count, wchar_t ch)
 
Stringassign (std::size_t count, char16_t ch)
 
Stringassign (std::size_t count, char32_t ch)
 
Stringassign (const std::string &str)
 
Stringassign (const std::wstring &str)
 
Stringassign (const std::u16string &str)
 
Stringassign (const std::u32string &str)
 
Stringassign (const String &str)
 
Stringassign (const std::string &str, std::size_t pos, std::size_t count=npos)
 
Stringassign (const std::wstring &str, std::size_t pos, std::size_t count=npos)
 
Stringassign (const std::u16string &str, std::size_t pos, std::size_t count=npos)
 
Stringassign (const std::u32string &str, std::size_t pos, std::size_t count=npos)
 
Stringassign (const String &str, std::size_t pos, std::size_t count=npos)
 
Stringassign (std::string &&str)
 
Stringassign (std::wstring &&str)
 
Stringassign (std::u16string &&str)
 
Stringassign (std::u32string &&str)
 
Stringassign (String &&str)
 
Stringassign (const char *str, std::size_t count)
 
Stringassign (const wchar_t *str, std::size_t count)
 
Stringassign (const char16_t *str, std::size_t count)
 
Stringassign (const char32_t *str, std::size_t count)
 
Stringassign (const char *str)
 
Stringassign (const wchar_t *str)
 
Stringassign (const char16_t *str)
 
Stringassign (const char32_t *str)
 
Stringassign (std::initializer_list< char > chars)
 
Stringassign (std::initializer_list< wchar_t > chars)
 
Stringassign (std::initializer_list< char16_t > chars)
 
Stringassign (std::initializer_list< char32_t > chars)
 
Stringassign (std::string::const_iterator first, std::string::const_iterator last)
 
Stringassign (std::wstring::const_iterator first, std::wstring::const_iterator last)
 
Stringassign (std::u16string::const_iterator first, std::u16string::const_iterator last)
 
Stringassign (std::u32string::const_iterator first, std::u32string::const_iterator last)
 
reference at (std::size_t pos)
 
const_reference at (std::size_t pos) const
 
const_reference operator[] (std::size_t index) const
 
reference operator[] (std::size_t index)
 
reference front ()
 
const_reference front () const
 
reference back ()
 
const_reference back () const
 
const char32_t * data () const noexcept
 
const char32_t * c_str () const noexcept
 
iterator begin () noexcept
 
const_iterator begin () const noexcept
 
const_iterator cbegin () const noexcept
 
iterator end () noexcept
 
const_iterator end () const noexcept
 
const_iterator cend () const noexcept
 
reverse_iterator rbegin () noexcept
 
const_reverse_iterator rbegin () const noexcept
 
const_reverse_iterator crbegin () const noexcept
 
reverse_iterator rend () noexcept
 
const_reverse_iterator rend () const noexcept
 
const_reverse_iterator crend () const noexcept
 
bool empty () const noexcept
 
std::size_t size () const noexcept
 
std::size_t length () const noexcept
 
std::size_t max_size () const noexcept
 
void reserve (std::size_t newCap)
 
std::size_t capacity () const noexcept
 
void shrink_to_fit ()
 
void clear () noexcept
 
Stringinsert (std::size_t index, std::size_t count, char ch)
 
Stringinsert (std::size_t index, std::size_t count, wchar_t ch)
 
Stringinsert (std::size_t index, std::size_t count, char16_t ch)
 
Stringinsert (std::size_t index, std::size_t count, char32_t ch)
 
Stringinsert (std::size_t index, const std::string &str)
 
Stringinsert (std::size_t index, const std::wstring &str)
 
Stringinsert (std::size_t index, const std::u16string &str)
 
Stringinsert (std::size_t index, const std::u32string &str)
 
Stringinsert (std::size_t index, const String &str)
 
Stringinsert (std::size_t index, const std::string &str, std::size_t pos, std::size_t count=npos)
 
Stringinsert (std::size_t index, const std::wstring &str, std::size_t pos, std::size_t count=npos)
 
Stringinsert (std::size_t index, const std::u16string &str, std::size_t pos, std::size_t count=npos)
 
Stringinsert (std::size_t index, const std::u32string &str, std::size_t pos, std::size_t count=npos)
 
Stringinsert (std::size_t index, const String &str, std::size_t pos, std::size_t count=npos)
 
Stringinsert (std::size_t index, const char *str, std::size_t count)
 
Stringinsert (std::size_t index, const wchar_t *str, std::size_t count)
 
Stringinsert (std::size_t index, const char16_t *str, std::size_t count)
 
Stringinsert (std::size_t index, const char32_t *str, std::size_t count)
 
Stringinsert (std::size_t index, const char *str)
 
Stringinsert (std::size_t index, const wchar_t *str)
 
Stringinsert (std::size_t index, const char16_t *str)
 
Stringinsert (std::size_t index, const char32_t *str)
 
iterator insert (const_iterator pos, char ch)
 
iterator insert (const_iterator pos, wchar_t ch)
 
iterator insert (const_iterator pos, char16_t ch)
 
iterator insert (const_iterator pos, char32_t ch)
 
iterator insert (const_iterator pos, std::size_t count, char ch)
 
iterator insert (const_iterator pos, std::size_t count, wchar_t ch)
 
iterator insert (const_iterator pos, std::size_t count, char16_t ch)
 
iterator insert (const_iterator pos, std::size_t count, char32_t ch)
 
iterator insert (const_iterator pos, std::initializer_list< char > chars)
 
iterator insert (const_iterator pos, std::initializer_list< wchar_t > chars)
 
iterator insert (const_iterator pos, std::initializer_list< char16_t > chars)
 
iterator insert (const_iterator pos, std::initializer_list< char32_t > chars)
 
iterator insert (const_iterator pos, std::string::const_iterator first, std::string::const_iterator last)
 
iterator insert (const_iterator pos, std::wstring::const_iterator first, std::wstring::const_iterator last)
 
iterator insert (const_iterator pos, std::u16string::const_iterator first, std::u16string::const_iterator last)
 
iterator insert (const_iterator pos, std::u32string::const_iterator first, std::u32string::const_iterator last)
 
Stringerase (std::size_t index=0, std::size_t count=npos)
 
iterator erase (const_iterator position)
 
iterator erase (const_iterator first, const_iterator last)
 
void push_back (char ch)
 
void push_back (wchar_t ch)
 
void push_back (char16_t ch)
 
void push_back (char32_t ch)
 
void pop_back ()
 
Stringappend (std::size_t count, char ch)
 
Stringappend (std::size_t count, wchar_t ch)
 
Stringappend (std::size_t count, char16_t ch)
 
Stringappend (std::size_t count, char32_t ch)
 
Stringappend (const std::string &str)
 
Stringappend (const std::wstring &str)
 
Stringappend (const std::u16string &str)
 
Stringappend (const std::u32string &str)
 
Stringappend (const String &str)
 
Stringappend (const std::string &str, std::size_t pos, std::size_t count=npos)
 
Stringappend (const std::wstring &str, std::size_t pos, std::size_t count=npos)
 
Stringappend (const std::u16string &str, std::size_t pos, std::size_t count=npos)
 
Stringappend (const std::u32string &str, std::size_t pos, std::size_t count=npos)
 
Stringappend (const String &str, std::size_t pos, std::size_t count=npos)
 
Stringappend (const char *str, std::size_t count)
 
Stringappend (const wchar_t *str, std::size_t count)
 
Stringappend (const char16_t *str, std::size_t count)
 
Stringappend (const char32_t *str, std::size_t count)
 
Stringappend (const char *str)
 
Stringappend (const wchar_t *str)
 
Stringappend (const char16_t *str)
 
Stringappend (const char32_t *str)
 
Stringappend (std::string::const_iterator first, std::string::const_iterator last)
 
Stringappend (std::wstring::const_iterator first, std::wstring::const_iterator last)
 
Stringappend (std::u16string::const_iterator first, std::u16string::const_iterator last)
 
Stringappend (std::u32string::const_iterator first, std::u32string::const_iterator last)
 
Stringappend (std::initializer_list< char > chars)
 
Stringappend (std::initializer_list< wchar_t > chars)
 
Stringappend (std::initializer_list< char16_t > chars)
 
Stringappend (std::initializer_list< char32_t > chars)
 
Stringoperator+= (const String &str)
 
int compare (const std::string &str) const noexcept
 
int compare (const std::wstring &str) const noexcept
 
int compare (const std::u16string &str) const noexcept
 
int compare (const std::u32string &str) const noexcept
 
int compare (const String &str) const noexcept
 
int compare (std::size_t pos1, std::size_t count1, const std::string &str) const
 
int compare (std::size_t pos1, std::size_t count1, const std::wstring &str) const
 
int compare (std::size_t pos1, std::size_t count1, const std::u16string &str) const
 
int compare (std::size_t pos1, std::size_t count1, const std::u32string &str) const
 
int compare (std::size_t pos1, std::size_t count1, const String &str) const
 
int compare (std::size_t pos1, std::size_t count1, const std::string &str, std::size_t pos2, std::size_t count2=npos) const
 
int compare (std::size_t pos1, std::size_t count1, const std::wstring &str, std::size_t pos2, std::size_t count2=npos) const
 
int compare (std::size_t pos1, std::size_t count1, const std::u16string &str, std::size_t pos2, std::size_t count2=npos) const
 
int compare (std::size_t pos1, std::size_t count1, const std::u32string &str, std::size_t pos2, std::size_t count2=npos) const
 
int compare (std::size_t pos1, std::size_t count1, const String &str, std::size_t pos2, std::size_t count2=npos) const
 
int compare (const char *s) const
 
int compare (const wchar_t *s) const
 
int compare (const char16_t *s) const
 
int compare (const char32_t *s) const
 
int compare (std::size_t pos1, std::size_t count1, const char *s) const
 
int compare (std::size_t pos1, std::size_t count1, const wchar_t *s) const
 
int compare (std::size_t pos1, std::size_t count1, const char16_t *s) const
 
int compare (std::size_t pos1, std::size_t count1, const char32_t *s) const
 
int compare (std::size_t pos1, std::size_t count1, const char *s, std::size_t count2) const
 
int compare (std::size_t pos1, std::size_t count1, const wchar_t *s, std::size_t count2) const
 
int compare (std::size_t pos1, std::size_t count1, const char16_t *s, std::size_t count2) const
 
int compare (std::size_t pos1, std::size_t count1, const char32_t *s, std::size_t count2) const
 
Stringreplace (std::size_t pos, std::size_t count, const std::string &str)
 
Stringreplace (std::size_t pos, std::size_t count, const std::wstring &str)
 
Stringreplace (std::size_t pos, std::size_t count, const std::u16string &str)
 
Stringreplace (std::size_t pos, std::size_t count, const std::u32string &str)
 
Stringreplace (std::size_t pos, std::size_t count, const String &str)
 
Stringreplace (const_iterator first, const_iterator last, const std::string &str)
 
Stringreplace (const_iterator first, const_iterator last, const std::wstring &str)
 
Stringreplace (const_iterator first, const_iterator last, const std::u16string &str)
 
Stringreplace (const_iterator first, const_iterator last, const std::u32string &str)
 
Stringreplace (const_iterator first, const_iterator last, const String &str)
 
Stringreplace (std::size_t pos, std::size_t count, const std::string &str, std::size_t pos2, std::size_t count2=npos)
 
Stringreplace (std::size_t pos, std::size_t count, const std::wstring &str, std::size_t pos2, std::size_t count2=npos)
 
Stringreplace (std::size_t pos, std::size_t count, const std::u16string &str, std::size_t pos2, std::size_t count2=npos)
 
Stringreplace (std::size_t pos, std::size_t count, const std::u32string &str, std::size_t pos2, std::size_t count2=npos)
 
Stringreplace (std::size_t pos, std::size_t count, const String &str, std::size_t pos2, std::size_t count2=npos)
 
Stringreplace (const_iterator first, const_iterator last, std::string::const_iterator first2, std::string::const_iterator last2)
 
Stringreplace (const_iterator first, const_iterator last, std::wstring::const_iterator first2, std::wstring::const_iterator last2)
 
Stringreplace (const_iterator first, const_iterator last, std::u16string::const_iterator first2, std::u16string::const_iterator last2)
 
Stringreplace (const_iterator first, const_iterator last, std::u32string::const_iterator first2, std::u32string::const_iterator last2)
 
Stringreplace (std::size_t pos, std::size_t count, const char *cstr, std::size_t count2)
 
Stringreplace (std::size_t pos, std::size_t count, const wchar_t *cstr, std::size_t count2)
 
Stringreplace (std::size_t pos, std::size_t count, const char16_t *cstr, std::size_t count2)
 
Stringreplace (std::size_t pos, std::size_t count, const char32_t *cstr, std::size_t count2)
 
Stringreplace (const_iterator first, const_iterator last, const char *cstr, std::size_t count2)
 
Stringreplace (const_iterator first, const_iterator last, const wchar_t *cstr, std::size_t count2)
 
Stringreplace (const_iterator first, const_iterator last, const char16_t *cstr, std::size_t count2)
 
Stringreplace (const_iterator first, const_iterator last, const char32_t *cstr, std::size_t count2)
 
Stringreplace (std::size_t pos, std::size_t count, const char *cstr)
 
Stringreplace (std::size_t pos, std::size_t count, const wchar_t *cstr)
 
Stringreplace (std::size_t pos, std::size_t count, const char16_t *cstr)
 
Stringreplace (std::size_t pos, std::size_t count, const char32_t *cstr)
 
Stringreplace (const_iterator first, const_iterator last, const char *cstr)
 
Stringreplace (const_iterator first, const_iterator last, const wchar_t *cstr)
 
Stringreplace (const_iterator first, const_iterator last, const char16_t *cstr)
 
Stringreplace (const_iterator first, const_iterator last, const char32_t *cstr)
 
Stringreplace (std::size_t pos, std::size_t count, std::size_t count2, char ch)
 
Stringreplace (std::size_t pos, std::size_t count, std::size_t count2, wchar_t ch)
 
Stringreplace (std::size_t pos, std::size_t count, std::size_t count2, char16_t ch)
 
Stringreplace (std::size_t pos, std::size_t count, std::size_t count2, char32_t ch)
 
Stringreplace (const_iterator first, const_iterator last, std::size_t count2, char ch)
 
Stringreplace (const_iterator first, const_iterator last, std::size_t count2, wchar_t ch)
 
Stringreplace (const_iterator first, const_iterator last, std::size_t count2, char16_t ch)
 
Stringreplace (const_iterator first, const_iterator last, std::size_t count2, char32_t ch)
 
Stringreplace (const_iterator first, const_iterator last, std::initializer_list< char > chars)
 
Stringreplace (const_iterator first, const_iterator last, std::initializer_list< wchar_t > chars)
 
Stringreplace (const_iterator first, const_iterator last, std::initializer_list< char16_t > chars)
 
Stringreplace (const_iterator first, const_iterator last, std::initializer_list< char32_t > chars)
 
String substr (std::size_t pos=0, std::size_t count=npos) const
 
std::size_t copy (char32_t *dest, std::size_t count, std::size_t pos=0) const
 
void resize (std::size_t count)
 
void resize (std::size_t count, char ch)
 
void resize (std::size_t count, wchar_t ch)
 
void resize (std::size_t count, char16_t ch)
 
void resize (std::size_t count, char32_t ch)
 
void swap (String &other)
 
bool contains (std::u32string_view sv) const noexcept
 
bool contains (char c) const noexcept
 
bool contains (wchar_t c) const noexcept
 
bool contains (char16_t c) const noexcept
 
bool contains (char32_t c) const noexcept
 
bool contains (const char *s) const
 
bool contains (const wchar_t *s) const
 
bool contains (const char16_t *s) const
 
bool contains (const char32_t *s) const
 
std::size_t find (const std::string &str, std::size_t pos=0) const noexcept
 
std::size_t find (const std::wstring &str, std::size_t pos=0) const noexcept
 
std::size_t find (const std::u16string &str, std::size_t pos=0) const noexcept
 
std::size_t find (const std::u32string &str, std::size_t pos=0) const noexcept
 
std::size_t find (const String &str, std::size_t pos=0) const noexcept
 
std::size_t find (const char *s, std::size_t pos, std::size_t count) const
 
std::size_t find (const wchar_t *s, std::size_t pos, std::size_t count) const
 
std::size_t find (const char16_t *s, std::size_t pos, std::size_t count) const
 
std::size_t find (const char32_t *s, std::size_t pos, std::size_t count) const
 
std::size_t find (const char *s, std::size_t pos=0) const
 
std::size_t find (const wchar_t *s, std::size_t pos=0) const
 
std::size_t find (const char16_t *s, std::size_t pos=0) const
 
std::size_t find (const char32_t *s, std::size_t pos=0) const
 
std::size_t find (char ch, std::size_t pos=0) const noexcept
 
std::size_t find (wchar_t ch, std::size_t pos=0) const noexcept
 
std::size_t find (char16_t ch, std::size_t pos=0) const noexcept
 
std::size_t find (char32_t ch, std::size_t pos=0) const noexcept
 
std::size_t find (std::u32string_view sv, std::size_t pos=0) const noexcept
 
std::size_t find_first_of (const std::string &str, std::size_t pos=0) const noexcept
 
std::size_t find_first_of (const std::wstring &str, std::size_t pos=0) const noexcept
 
std::size_t find_first_of (const std::u16string &str, std::size_t pos=0) const noexcept
 
std::size_t find_first_of (const std::u32string &str, std::size_t pos=0) const noexcept
 
std::size_t find_first_of (const String &str, std::size_t pos=0) const noexcept
 
std::size_t find_first_of (const char *s, std::size_t pos, std::size_t count) const
 
std::size_t find_first_of (const wchar_t *s, std::size_t pos, std::size_t count) const
 
std::size_t find_first_of (const char16_t *s, std::size_t pos, std::size_t count) const
 
std::size_t find_first_of (const char32_t *s, std::size_t pos, std::size_t count) const
 
std::size_t find_first_of (const char *s, std::size_t pos=0) const
 
std::size_t find_first_of (const wchar_t *s, std::size_t pos=0) const
 
std::size_t find_first_of (const char16_t *s, std::size_t pos=0) const
 
std::size_t find_first_of (const char32_t *s, std::size_t pos=0) const
 
std::size_t find_first_of (char ch, std::size_t pos=0) const noexcept
 
std::size_t find_first_of (wchar_t ch, std::size_t pos=0) const noexcept
 
std::size_t find_first_of (char16_t ch, std::size_t pos=0) const noexcept
 
std::size_t find_first_of (char32_t ch, std::size_t pos=0) const noexcept
 
std::size_t find_first_not_of (const std::string &str, std::size_t pos=0) const noexcept
 
std::size_t find_first_not_of (const std::wstring &str, std::size_t pos=0) const noexcept
 
std::size_t find_first_not_of (const std::u16string &str, std::size_t pos=0) const noexcept
 
std::size_t find_first_not_of (const std::u32string &str, std::size_t pos=0) const noexcept
 
std::size_t find_first_not_of (const String &str, std::size_t pos=0) const noexcept
 
std::size_t find_first_not_of (const char *s, std::size_t pos, std::size_t count) const
 
std::size_t find_first_not_of (const wchar_t *s, std::size_t pos, std::size_t count) const
 
std::size_t find_first_not_of (const char16_t *s, std::size_t pos, std::size_t count) const
 
std::size_t find_first_not_of (const char32_t *s, std::size_t pos, std::size_t count) const
 
std::size_t find_first_not_of (const char *s, std::size_t pos=0) const
 
std::size_t find_first_not_of (const wchar_t *s, std::size_t pos=0) const
 
std::size_t find_first_not_of (const char16_t *s, std::size_t pos=0) const
 
std::size_t find_first_not_of (const char32_t *s, std::size_t pos=0) const
 
std::size_t find_first_not_of (char ch, std::size_t pos=0) const noexcept
 
std::size_t find_first_not_of (wchar_t ch, std::size_t pos=0) const noexcept
 
std::size_t find_first_not_of (char16_t ch, std::size_t pos=0) const noexcept
 
std::size_t find_first_not_of (char32_t ch, std::size_t pos=0) const noexcept
 
std::size_t rfind (const std::string &str, std::size_t pos=npos) const noexcept
 
std::size_t rfind (const std::wstring &str, std::size_t pos=npos) const noexcept
 
std::size_t rfind (const std::u16string &str, std::size_t pos=npos) const noexcept
 
std::size_t rfind (const std::u32string &str, std::size_t pos=npos) const noexcept
 
std::size_t rfind (const String &str, std::size_t pos=npos) const noexcept
 
std::size_t rfind (const char *s, std::size_t pos, std::size_t count) const
 
std::size_t rfind (const wchar_t *s, std::size_t pos, std::size_t count) const
 
std::size_t rfind (const char16_t *s, std::size_t pos, std::size_t count) const
 
std::size_t rfind (const char32_t *s, std::size_t pos, std::size_t count) const
 
std::size_t rfind (const char *s, std::size_t pos=npos) const
 
std::size_t rfind (const wchar_t *s, std::size_t pos=npos) const
 
std::size_t rfind (const char16_t *s, std::size_t pos=npos) const
 
std::size_t rfind (const char32_t *s, std::size_t pos=npos) const
 
std::size_t rfind (char ch, std::size_t pos=npos) const noexcept
 
std::size_t rfind (wchar_t ch, std::size_t pos=npos) const noexcept
 
std::size_t rfind (char16_t ch, std::size_t pos=npos) const noexcept
 
std::size_t rfind (char32_t ch, std::size_t pos=npos) const noexcept
 
std::size_t find_last_of (const std::string &str, std::size_t pos=npos) const noexcept
 
std::size_t find_last_of (const std::wstring &str, std::size_t pos=npos) const noexcept
 
std::size_t find_last_of (const std::u16string &str, std::size_t pos=npos) const noexcept
 
std::size_t find_last_of (const std::u32string &str, std::size_t pos=npos) const noexcept
 
std::size_t find_last_of (const String &str, std::size_t pos=npos) const noexcept
 
std::size_t find_last_of (const char *s, std::size_t pos, std::size_t count) const
 
std::size_t find_last_of (const wchar_t *s, std::size_t pos, std::size_t count) const
 
std::size_t find_last_of (const char16_t *s, std::size_t pos, std::size_t count) const
 
std::size_t find_last_of (const char32_t *s, std::size_t pos, std::size_t count) const
 
std::size_t find_last_of (const char *s, std::size_t pos=npos) const
 
std::size_t find_last_of (const wchar_t *s, std::size_t pos=npos) const
 
std::size_t find_last_of (const char16_t *s, std::size_t pos=npos) const
 
std::size_t find_last_of (const char32_t *s, std::size_t pos=npos) const
 
std::size_t find_last_of (char ch, std::size_t pos=npos) const noexcept
 
std::size_t find_last_of (wchar_t ch, std::size_t pos=npos) const noexcept
 
std::size_t find_last_of (char16_t ch, std::size_t pos=npos) const noexcept
 
std::size_t find_last_of (char32_t ch, std::size_t pos=npos) const noexcept
 
std::size_t find_last_not_of (const std::string &str, std::size_t pos=npos) const noexcept
 
std::size_t find_last_not_of (const std::wstring &str, std::size_t pos=npos) const noexcept
 
std::size_t find_last_not_of (const std::u16string &str, std::size_t pos=npos) const noexcept
 
std::size_t find_last_not_of (const std::u32string &str, std::size_t pos=npos) const noexcept
 
std::size_t find_last_not_of (const String &str, std::size_t pos=npos) const noexcept
 
std::size_t find_last_not_of (const char *s, std::size_t pos, std::size_t count) const
 
std::size_t find_last_not_of (const wchar_t *s, std::size_t pos, std::size_t count) const
 
std::size_t find_last_not_of (const char16_t *s, std::size_t pos, std::size_t count) const
 
std::size_t find_last_not_of (const char32_t *s, std::size_t pos, std::size_t count) const
 
std::size_t find_last_not_of (const char *s, std::size_t pos=npos) const
 
std::size_t find_last_not_of (const wchar_t *s, std::size_t pos=npos) const
 
std::size_t find_last_not_of (const char16_t *s, std::size_t pos=npos) const
 
std::size_t find_last_not_of (const char32_t *s, std::size_t pos=npos) const
 
std::size_t find_last_not_of (char ch, std::size_t pos=npos) const noexcept
 
std::size_t find_last_not_of (wchar_t ch, std::size_t pos=npos) const noexcept
 
std::size_t find_last_not_of (char16_t ch, std::size_t pos=npos) const noexcept
 
std::size_t find_last_not_of (char32_t ch, std::size_t pos=npos) const noexcept
 

Static Public Member Functions

static String join (const std::vector< String > &segments, const String &separator)
 Joins multiple string segments into a single string. More...
 
template<typename T >
static String fromNumber (T value)
 Construct the string from a number. More...
 
template<typename T >
static String fromNumberRounded (T value, int decimals)
 Construct the string from a floating point number, keeping only a certain amount of decimals behind the comma. More...
 

Static Public Attributes

static const decltype(std::u32string::npos) npos
 

Friends

bool operator== (const String &left, const String &right)
 
bool operator!= (const String &left, const String &right)
 
bool operator< (const String &left, const String &right)
 
bool operator<= (const String &left, const String &right)
 
bool operator> (const String &left, const String &right)
 
bool operator>= (const String &left, const String &right)
 
String operator+ (const String &left, const String &right)
 
String operator+ (const String &left, String &&right)
 
String operator+ (String &&left, const String &right)
 
String operator+ (String &&left, String &&right)
 

Detailed Description

Wrapper class to store strings.

A constructor and conversion operator are provided for sf::String to easily convert between sf::String and tgui::String.

The interface is similar to std::basic_string, but functions accept char, wchar_t, char8_t, char16_t and char32_t. Some extra helper functions are also provided to e.g. convert the string to an integer or float or to lowercase.

Note that when converting to std::string, an UTF-8 encoded string will be returned. Similarly, when passing an std::string or const char* to this class, the encoding is assumed to be UTF-8.

Data is stored in UTF-32, so any parameter or operator using a different encoding will have to convert the string internally and may be slightly slower than the variants that use UTF-32.

Member Function Documentation

◆ attemptToFloat()

bool tgui::String::attemptToFloat ( float &  result) const

Converts the string to a float.

Parameters
resultFloat value if the string contains a float. Unmodified if string is invalid.
Returns
Returns whether the string was valid and a value has been placed into the reference parameter.

◆ attemptToInt()

bool tgui::String::attemptToInt ( int &  result) const

Converts the string to an integer.

Parameters
resultInteger value if the string contains a base 10 integer. Unmodified if string is invalid.
Returns
Returns whether the string was valid and a value has been placed into the reference parameter.

◆ attemptToUInt()

bool tgui::String::attemptToUInt ( unsigned int &  result) const

Converts the string to an unsigned int.

Parameters
resultUnsigned integer value if the string contains a base 10 unsigned int. Unmodified if string is invalid.
Returns
Returns whether the string was valid and a value has been placed into the reference parameter.

◆ endsWith()

bool tgui::String::endsWith ( const String substring) const

Checks whether the last part of the string matches the given substring.

Parameters
substringCharacters to compare against the final part of the string
Returns
Does the back of the string match the given substring?

◆ equalIgnoreCase()

bool tgui::String::equalIgnoreCase ( const String other) const

Compares this string to another and checks if they are equal if ASCII letters would have been lowercase.

Parameters
otherThe other string to compare this one with
Returns
Are the strings equal except for the case of ASCII letters?

◆ fromNumber()

template<typename T >
static String tgui::String::fromNumber ( value)
inlinestatic

Construct the string from a number.

Parameters
valueNumber to convert to string
Returns
String representing given number

◆ fromNumberRounded()

template<typename T >
static String tgui::String::fromNumberRounded ( value,
int  decimals 
)
inlinestatic

Construct the string from a floating point number, keeping only a certain amount of decimals behind the comma.

Parameters
valueNumber to convert to string
decimalsDigits to keep behind the comma
Returns
String representing given number, rounded to the given decimals

◆ join()

static String tgui::String::join ( const std::vector< String > &  segments,
const String separator 
)
static

Joins multiple string segments into a single string.

Parameters
segmentsSubstrings that need to concatenated behind each other (with optional separators inbetween)
separatorCharacter that separates the substrings

◆ replace()

String & tgui::String::replace ( const String searchFor,
const String replaceWith 
)

Replaces all occurrences of a substring with a replacement string.

Parameters
searchForThe value being searched for
replaceWithThe value that replaces found searchFor values
Returns
Reference to this object.

◆ split()

std::vector< String > tgui::String::split ( char32_t  delimiter,
bool  trim = false 
) const

Splits the string into multiple substrings given the delimiter that separates them.

Parameters
delimiterCharacter that separates the substrings
trimShould whitespace be removed at the start and end of each part?

◆ startsWith()

bool tgui::String::startsWith ( const String substring) const

Checks whether the first part of the string matches the given substring.

Parameters
substringCharacters to compare against the first part of the string
Returns
Does the first part of the string match the given substring?

◆ toFloat()

float tgui::String::toFloat ( float  defaultValue = 0) const

Converts the string to a float.

Parameters
defaultValueValue to return if conversion fails
Returns
Returns the float value or defaultValue if the string didn't contain an float

◆ toInt()

int tgui::String::toInt ( int  defaultValue = 0) const

Converts the string to an integer.

Parameters
defaultValueValue to return if conversion fails
Returns
Returns the integer value or defaultValue if the string didn't contain a base 10 integer

◆ toLower()

String tgui::String::toLower ( ) const

Converts the ASCII characters in the string to lowercase.

Returns
Lowercase string

◆ toUInt()

unsigned int tgui::String::toUInt ( unsigned int  defaultValue = 0) const

Converts the string to an unsigned int.

Parameters
defaultValueValue to return if conversion fails
Returns
Returns the unsigned integer value or defaultValue if the string didn't contain a base 10 unsigned integer

◆ toUpper()

String tgui::String::toUpper ( ) const

Converts the ASCII characters in the string to uppercase.

Returns
Uppercase string

◆ trim()

String tgui::String::trim ( ) const

Returns a string with the whitespace at the start and end of this string removed.

Returns
Trimmed string

The documentation for this class was generated from the following file: