MyGUI 3.4.1
Data Structures | Public Types | Static Public Attributes | Related Functions
MyGUI::UString Class Reference

A UTF-16 string with implicit conversion to/from std::string and std::wstring. More...

#include <MyGUI_UString.h>

Data Structures

class  _base_iterator
 base iterator class for UString More...
 
class  _const_fwd_iterator
 const forward iterator for UString More...
 
class  _const_rev_iterator
 const reverse iterator for UString More...
 
class  _fwd_iterator
 forward iterator for UString More...
 
class  _rev_iterator
 forward iterator for UString More...
 
class  invalid_data
 This exception is used when invalid data streams are encountered. More...
 

Public Types

using size_type = size_t
 size type used to indicate string size and character positions within the string More...
 
using unicode_char = uint32
 a single 32-bit Unicode character More...
 
using code_point = uint16
 a single UTF-16 code point More...
 
using value_type = code_point
 value type typedef for use in iterators More...
 
using dstring = std::basic_string< code_point >
 
using utf32string = std::basic_string< unicode_char >
 string type used for returning UTF-32 formatted data More...
 
using iterator = _fwd_iterator
 iterator More...
 
using reverse_iterator = _rev_iterator
 reverse iterator More...
 
using const_iterator = _const_fwd_iterator
 const iterator More...
 
using const_reverse_iterator = _const_rev_iterator
 const reverse iterator More...
 

Public Member Functions

Constructors/Destructor
 UString ()
 default constructor, creates an empty string More...
 
 UString (const UString &copy)
 copy constructor More...
 
 UString (size_type length, const code_point &ch)
 length copies of ch More...
 
 UString (const code_point *str)
 duplicate of nul-terminated sequence str More...
 
 UString (const code_point *str, size_type length)
 duplicate of str, length code points long More...
 
 UString (const UString &str, size_type index, size_type length)
 substring of str starting at index and length code points long More...
 
 UString (const wchar_t *w_str)
 duplicate of nul-terminated wchar_t array More...
 
 UString (const wchar_t *w_str, size_type length)
 duplicate of w_str, length characters long More...
 
 UString (const std::wstring &wstr)
 duplicate of wstr More...
 
 UString (const char *c_str)
 duplicate of nul-terminated C-string c_str (UTF-8 encoding) More...
 
 UString (const char *c_str, size_type length)
 duplicate of c_str, length characters long (UTF-8 encoding) More...
 
 UString (const std::string &str)
 duplicate of str (UTF-8 encoding) More...
 
 UString (const utf32string &str)
 
 ~UString ()
 destructor More...
 
Utility functions
size_type size () const
 Returns the number of code points in the current string. More...
 
size_type length () const
 Returns the number of code points in the current string. More...
 
size_type length_Characters () const
 Returns the number of Unicode characters in the string. More...
 
size_type max_size () const
 returns the maximum number of UTF-16 code points that the string can hold More...
 
void reserve (size_type size)
 sets the capacity of the string to at least size code points More...
 
void resize (size_type num, const code_point &val=0)
 changes the size of the string to size, filling in any new area with val More...
 
void swap (UString &from)
 exchanges the elements of the current string with those of from More...
 
bool empty () const
 returns true if the string has no elements, false otherwise More...
 
const code_pointc_str () const
 returns a pointer to the first character in the current string More...
 
const code_pointdata () const
 returns a pointer to the first character in the current string More...
 
size_type capacity () const
 returns the number of elements that the string can hold before it will need to allocate more space More...
 
void clear ()
 deletes all of the elements in the string More...
 
UString substr (size_type index, size_type num=npos) const
 returns a substring of the current string, starting at index, and num characters long. More...
 
void push_back (unicode_char val)
 appends val to the end of the string More...
 
void push_back (wchar_t val)
 appends val to the end of the string More...
 
void push_back (code_point val)
 appends val to the end of the string More...
 
void push_back (char val)
 appends val to the end of the string More...
 
bool inString (unicode_char ch) const
 returns true if the given Unicode character ch is in this string More...
 
Stream variations
const std::string & asUTF8 () const
 returns the current string in UTF-8 form within a std::string More...
 
const char * asUTF8_c_str () const
 returns the current string in UTF-8 form as a nul-terminated char array More...
 
const utf32stringasUTF32 () const
 returns the current string in UTF-32 form within a utf32string More...
 
const unicode_charasUTF32_c_str () const
 returns the current string in UTF-32 form as a nul-terminated unicode_char array More...
 
const std::wstring & asWStr () const
 returns the current string in the native form of std::wstring More...
 
const wchar_t * asWStr_c_str () const
 returns the current string in the native form of a nul-terminated wchar_t array More...
 
Single Character Access
code_pointat (size_type loc)
 returns a reference to the element in the string at index loc More...
 
const code_pointat (size_type loc) const
 returns a reference to the element in the string at index loc More...
 
unicode_char getChar (size_type loc) const
 returns the data point loc evaluated as a UTF-32 value More...
 
int setChar (size_type loc, unicode_char ch)
 sets the value of the character at loc to the Unicode value ch (UTF-32) More...
 
iterator acquisition
iterator begin ()
 returns an iterator to the first element of the string More...
 
const_iterator begin () const
 returns an iterator to the first element of the string More...
 
iterator end ()
 returns an iterator just past the end of the string More...
 
const_iterator end () const
 returns an iterator just past the end of the string More...
 
reverse_iterator rbegin ()
 returns a reverse iterator to the last element of the string More...
 
const_reverse_iterator rbegin () const
 returns a reverse iterator to the last element of the string More...
 
reverse_iterator rend ()
 returns a reverse iterator just past the beginning of the string More...
 
const_reverse_iterator rend () const
 returns a reverse iterator just past the beginning of the string More...
 
assign
UStringassign (iterator start, iterator end)
 gives the current string the values from start to end More...
 
UStringassign (const UString &str)
 assign str to the current string More...
 
UStringassign (const code_point *str)
 assign the nul-terminated str to the current string More...
 
UStringassign (const code_point *str, size_type num)
 assign the first num characters of str to the current string More...
 
UStringassign (const UString &str, size_type index, size_type len)
 assign len entries from str to the current string, starting at index More...
 
UStringassign (size_type num, const code_point &ch)
 assign num copies of ch to the current string More...
 
UStringassign (const std::wstring &wstr)
 assign wstr to the current string (wstr is treated as a UTF-16 stream) More...
 
UStringassign (const wchar_t *w_str)
 assign w_str to the current string More...
 
UStringassign (const wchar_t *w_str, size_type num)
 assign the first num characters of w_str to the current string More...
 
UStringassign (const std::string &str)
 assign str to the current string (str is treated as a UTF-8 stream) More...
 
UStringassign (const utf32string &str)
 
UStringassign (const char *c_str)
 assign c_str to the current string (c_str is treated as a UTF-8 stream) More...
 
UStringassign (const char *c_str, size_type num)
 assign the first num characters of c_str to the current string (c_str is treated as a UTF-8 stream) More...
 
append
UStringappend (const UString &str)
 appends str on to the end of the current string More...
 
UStringappend (const code_point *str)
 appends str on to the end of the current string More...
 
UStringappend (const UString &str, size_type index, size_type len)
 appends a substring of str starting at index that is len characters long on to the end of the current string More...
 
UStringappend (const code_point *str, size_type num)
 appends num characters of str on to the end of the current string More...
 
UStringappend (size_type num, code_point ch)
 appends num repetitions of ch on to the end of the current string More...
 
UStringappend (iterator start, iterator end)
 appends the sequence denoted by start and end on to the end of the current string More...
 
UStringappend (const wchar_t *w_str, size_type num)
 appends num characters of str on to the end of the current string More...
 
UStringappend (size_type num, wchar_t ch)
 appends num repetitions of ch on to the end of the current string More...
 
UStringappend (const char *c_str, size_type num)
 appends num characters of str on to the end of the current string (UTF-8 encoding) More...
 
UStringappend (size_type num, char ch)
 appends num repetitions of ch on to the end of the current string (Unicode values less than 128) More...
 
UStringappend (size_type num, unicode_char ch)
 appends num repetitions of ch on to the end of the current string (Full Unicode spectrum) More...
 
insert
iterator insert (iterator i, const code_point &ch)
 inserts ch before the code point denoted by i More...
 
UStringinsert (size_type index, const UString &str)
 inserts str into the current string, at location index More...
 
UStringinsert (size_type index, const code_point *str)
 inserts str into the current string, at location index More...
 
UStringinsert (size_type index1, const UString &str, size_type index2, size_type num)
 inserts a substring of str (starting at index2 and num code points long) into the current string, at location index1 More...
 
void insert (iterator i, iterator start, iterator end)
 inserts the code points denoted by start and end into the current string, before the code point specified by i More...
 
UStringinsert (size_type index, const code_point *str, size_type num)
 inserts num code points of str into the current string, at location index More...
 
UStringinsert (size_type index, const wchar_t *w_str, size_type num)
 inserts num code points of str into the current string, at location index More...
 
UStringinsert (size_type index, const char *c_str, size_type num)
 inserts num code points of str into the current string, at location index More...
 
UStringinsert (size_type index, size_type num, code_point ch)
 inserts num copies of ch into the current string, at location index More...
 
UStringinsert (size_type index, size_type num, wchar_t ch)
 inserts num copies of ch into the current string, at location index More...
 
UStringinsert (size_type index, size_type num, char ch)
 inserts num copies of ch into the current string, at location index More...
 
UStringinsert (size_type index, size_type num, unicode_char ch)
 inserts num copies of ch into the current string, at location index More...
 
void insert (iterator i, size_type num, const code_point &ch)
 inserts num copies of ch into the current string, before the code point denoted by i More...
 
void insert (iterator i, size_type num, const wchar_t &ch)
 inserts num copies of ch into the current string, before the code point denoted by i More...
 
void insert (iterator i, size_type num, const char &ch)
 inserts num copies of ch into the current string, before the code point denoted by i More...
 
void insert (iterator i, size_type num, const unicode_char &ch)
 inserts num copies of ch into the current string, before the code point denoted by i More...
 
erase
iterator erase (iterator loc)
 removes the code point pointed to by loc, returning an iterator to the next character More...
 
iterator erase (iterator start, iterator end)
 removes the code points between start and end (including the one at start but not the one at end), returning an iterator to the code point after the last code point removed More...
 
UStringerase (size_type index=0, size_type num=npos)
 removes num code points from the current string, starting at index More...
 
replace
UStringreplace (size_type index1, size_type num1, const UString &str)
 replaces up to num1 code points of the current string (starting at index1) with str More...
 
UStringreplace (size_type index1, size_type num1, const UString &str, size_type num2)
 replaces up to num1 code points of the current string (starting at index1) with up to num2 code points from str More...
 
UStringreplace (size_type index1, size_type num1, const UString &str, size_type index2, size_type num2)
 replaces up to num1 code points of the current string (starting at index1) with up to num2 code points from str beginning at index2 More...
 
UStringreplace (iterator start, iterator end, const UString &str, size_type num=npos)
 replaces code points in the current string from start to end with num code points from str More...
 
UStringreplace (size_type index, size_type num1, size_type num2, code_point ch)
 replaces up to num1 code points in the current string (beginning at index) with num2 copies of ch More...
 
UStringreplace (iterator start, iterator end, size_type num, code_point ch)
 replaces the code points in the current string from start to end with num copies of ch More...
 
compare
int compare (const UString &str) const
 compare str to the current string More...
 
int compare (const code_point *str) const
 compare str to the current string More...
 
int compare (size_type index, size_type length, const UString &str) const
 compare str to a substring of the current string, starting at index for length characters More...
 
int compare (size_type index, size_type length, const UString &str, size_type index2, size_type length2) const
 compare a substring of str to a substring of the current string, where index2 and length2 refer to str and index and length refer to the current string More...
 
int compare (size_type index, size_type length, const code_point *str, size_type length2) const
 compare a substring of str to a substring of the current string, where the substring of str begins at zero and is length2 characters long, and the substring of the current string begins at index and is length characters long More...
 
int compare (size_type index, size_type length, const wchar_t *w_str, size_type length2) const
 compare a substring of str to a substring of the current string, where the substring of str begins at zero and is length2 elements long, and the substring of the current string begins at index and is length characters long More...
 
int compare (size_type index, size_type length, const char *c_str, size_type length2) const
 compare a substring of str to a substring of the current string, where the substring of str begins at zero and is length2 UTF-8 code points long, and the substring of the current string begins at index and is length characters long More...
 
find & rfind
size_type find (const UString &str, size_type index=0) const
 returns the index of the first occurrence of str within the current string, starting at index; returns UString::npos if nothing is found More...
 
size_type find (const code_point *cp_str, size_type index, size_type length) const
 returns the index of the first occurrence of str within the current string and within length code points, starting at index; returns UString::npos if nothing is found More...
 
size_type find (const char *c_str, size_type index, size_type length) const
 returns the index of the first occurrence of str within the current string and within length code points, starting at index; returns UString::npos if nothing is found More...
 
size_type find (const wchar_t *w_str, size_type index, size_type length) const
 returns the index of the first occurrence of str within the current string and within length code points, starting at index; returns UString::npos if nothing is found More...
 
size_type find (char ch, size_type index=0) const
 returns the index of the first occurrence ch within the current string, starting at index; returns UString::npos if nothing is found More...
 
size_type find (code_point ch, size_type index=0) const
 returns the index of the first occurrence ch within the current string, starting at index; returns UString::npos if nothing is found More...
 
size_type find (wchar_t ch, size_type index=0) const
 returns the index of the first occurrence ch within the current string, starting at index; returns UString::npos if nothing is found More...
 
size_type find (unicode_char ch, size_type index=0) const
 returns the index of the first occurrence ch within the current string, starting at index; returns UString::npos if nothing is found More...
 
size_type rfind (const UString &str, size_type index=0) const
 returns the location of the first occurrence of str in the current string, doing a reverse search from index; returns UString::npos if nothing is found More...
 
size_type rfind (const code_point *cp_str, size_type index, size_type num) const
 returns the location of the first occurrence of str in the current string, doing a reverse search from index, searching at most num characters; returns UString::npos if nothing is found More...
 
size_type rfind (const char *c_str, size_type index, size_type num) const
 returns the location of the first occurrence of str in the current string, doing a reverse search from index, searching at most num characters; returns UString::npos if nothing is found More...
 
size_type rfind (const wchar_t *w_str, size_type index, size_type num) const
 returns the location of the first occurrence of str in the current string, doing a reverse search from index, searching at most num characters; returns UString::npos if nothing is found More...
 
size_type rfind (char ch, size_type index=0) const
 returns the location of the first occurrence of ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found More...
 
size_type rfind (code_point ch, size_type index) const
 returns the location of the first occurrence of ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found More...
 
size_type rfind (wchar_t ch, size_type index=0) const
 returns the location of the first occurrence of ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found More...
 
size_type rfind (unicode_char ch, size_type index=0) const
 returns the location of the first occurrence of ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found More...
 
find_first/last_(not)_of
size_type find_first_of (const UString &str, size_type index=0, size_type num=npos) const
 Returns the index of the first character within the current string that matches any character in str, beginning the search at index and searching at most num characters; returns UString::npos if nothing is found. More...
 
size_type find_first_of (code_point ch, size_type index=0) const
 returns the index of the first occurrence of ch in the current string, starting the search at index; returns UString::npos if nothing is found More...
 
size_type find_first_of (char ch, size_type index=0) const
 returns the index of the first occurrence of ch in the current string, starting the search at index; returns UString::npos if nothing is found More...
 
size_type find_first_of (wchar_t ch, size_type index=0) const
 returns the index of the first occurrence of ch in the current string, starting the search at index; returns UString::npos if nothing is found More...
 
size_type find_first_of (unicode_char ch, size_type index=0) const
 returns the index of the first occurrence of ch in the current string, starting the search at index; returns UString::npos if nothing is found More...
 
size_type find_first_not_of (const UString &str, size_type index=0, size_type num=npos) const
 returns the index of the first character within the current string that does not match any character in str, beginning the search at index and searching at most num characters; returns UString::npos if nothing is found More...
 
size_type find_first_not_of (code_point ch, size_type index=0) const
 returns the index of the first character within the current string that does not match ch, starting the search at index; returns UString::npos if nothing is found More...
 
size_type find_first_not_of (char ch, size_type index=0) const
 returns the index of the first character within the current string that does not match ch, starting the search at index; returns UString::npos if nothing is found More...
 
size_type find_first_not_of (wchar_t ch, size_type index=0) const
 returns the index of the first character within the current string that does not match ch, starting the search at index; returns UString::npos if nothing is found More...
 
size_type find_first_not_of (unicode_char ch, size_type index=0) const
 returns the index of the first character within the current string that does not match ch, starting the search at index; returns UString::npos if nothing is found More...
 
size_type find_last_of (const UString &str, size_type index=npos, size_type num=npos) const
 returns the index of the first character within the current string that matches any character in str, doing a reverse search from index and searching at most num characters; returns UString::npos if nothing is found More...
 
size_type find_last_of (code_point ch, size_type index=npos) const
 returns the index of the first occurrence of ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found More...
 
size_type find_last_of (char ch, size_type index=npos) const
 returns the index of the first occurrence of ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found More...
 
size_type find_last_of (wchar_t ch, size_type index=npos) const
 returns the index of the first occurrence of ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found More...
 
size_type find_last_of (unicode_char ch, size_type index=npos) const
 returns the index of the first occurrence of ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found More...
 
size_type find_last_not_of (const UString &str, size_type index=npos, size_type num=npos) const
 returns the index of the last character within the current string that does not match any character in str, doing a reverse search from index; returns UString::npos if nothing is found More...
 
size_type find_last_not_of (code_point ch, size_type index=npos) const
 returns the index of the last occurrence of a character that does not match ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found More...
 
size_type find_last_not_of (char ch, size_type index=npos) const
 returns the index of the last occurrence of a character that does not match ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found More...
 
size_type find_last_not_of (wchar_t ch, size_type index=npos) const
 returns the index of the last occurrence of a character that does not match ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found More...
 
size_type find_last_not_of (unicode_char ch, size_type index=npos) const
 returns the index of the last occurrence of a character that does not match ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found More...
 
Operators
bool operator< (const UString &right) const
 less than operator More...
 
bool operator<= (const UString &right) const
 less than or equal operator More...
 
bool operator> (const UString &right) const
 greater than operator More...
 
bool operator>= (const UString &right) const
 greater than or equal operator More...
 
bool operator== (const UString &right) const
 equality operator More...
 
bool operator!= (const UString &right) const
 inequality operator More...
 
UStringoperator= (const UString &s)
 assignment operator, implicitly casts all compatible types More...
 
UStringoperator= (code_point ch)
 assignment operator More...
 
UStringoperator= (char ch)
 assignment operator More...
 
UStringoperator= (wchar_t ch)
 assignment operator More...
 
UStringoperator= (unicode_char ch)
 assignment operator More...
 
code_pointoperator[] (size_type index)
 code point dereference operator More...
 
const code_pointoperator[] (size_type index) const
 code point dereference operator More...
 
Implicit Cast Operators
 operator std::string () const
 implicit cast to std::string More...
 
 operator std::wstring () const
 implicit cast to std::wstring More...
 

Static Public Member Functions

UTF-16 character encoding/decoding
static bool _utf16_independent_char (code_point cp)
 returns true if cp does not match the signature for the lead of follow code point of a surrogate pair in a UTF-16 sequence More...
 
static bool _utf16_surrogate_lead (code_point cp)
 returns true if cp matches the signature of a surrogate pair lead character More...
 
static bool _utf16_surrogate_follow (code_point cp)
 returns true if cp matches the signature of a surrogate pair following character More...
 
static size_t _utf16_char_length (code_point cp)
 estimates the number of UTF-16 code points in the sequence starting with cp More...
 
static size_t _utf16_char_length (unicode_char uc)
 returns the number of UTF-16 code points needed to represent the given UTF-32 character cp More...
 
static size_t _utf16_to_utf32 (const code_point in_cp[2], unicode_char &out_uc)
 converts the given UTF-16 character buffer in_cp to a single UTF-32 Unicode character out_uc, returns the number of code points used to create the output character (2 for surrogate pairs, otherwise 1) More...
 
static size_t _utf32_to_utf16 (const unicode_char &in_uc, code_point out_cp[2])
 writes the given UTF-32 uc_in to the buffer location out_cp using UTF-16 encoding, returns the number of code points used to encode the input (always 1 or 2) More...
 

Static Public Attributes

static const size_type npos = static_cast<size_type>(~0)
 the usual constant representing: not found, no limit, etc More...
 

Related Functions

(Note that these are not member functions.)

UString operator+ (const UString &s1, const UString &s2)
 string addition operator More...
 
UString operator+ (const UString &s1, UString::code_point c)
 string addition operator More...
 
UString operator+ (const UString &s1, UString::unicode_char c)
 string addition operator More...
 
UString operator+ (const UString &s1, char c)
 string addition operator More...
 
UString operator+ (const UString &s1, wchar_t c)
 string addition operator More...
 
UString operator+ (UString::code_point c, const UString &s2)
 string addition operator More...
 
UString operator+ (UString::unicode_char c, const UString &s2)
 string addition operator More...
 
UString operator+ (char c, const UString &s2)
 string addition operator More...
 
UString operator+ (wchar_t c, const UString &s2)
 string addition operator More...
 
std::ostream & operator<< (std::ostream &os, const UString &s)
 std::ostream write operator More...
 
std::wostream & operator<< (std::wostream &os, const UString &s)
 std::wostream write operator More...
 

UTF-8 character encoding/decoding

static bool _utf8_start_char (unsigned char cp)
 returns true if cp is the beginning of a UTF-8 sequence More...
 
static size_t _utf8_char_length (unsigned char cp)
 estimates the number of UTF-8 code points in the sequence starting with cp More...
 
static size_t _utf8_char_length (unicode_char uc)
 returns the number of UTF-8 code points needed to represent the given UTF-32 character cp More...
 
static size_t _utf8_to_utf32 (const unsigned char in_cp[6], unicode_char &out_uc)
 converts the given UTF-8 character buffer to a single UTF-32 Unicode character, returns the number of bytes used to create the output character (maximum of 6) More...
 
static size_t _utf32_to_utf8 (const unicode_char &in_uc, unsigned char out_cp[6])
 writes the given UTF-32 uc_in to the buffer location out_cp using UTF-8 encoding, returns the number of bytes used to encode the input More...
 
static size_type _verifyUTF8 (const unsigned char *c_str)
 verifies a UTF-8 stream, returning the total number of Unicode characters found More...
 
static size_type _verifyUTF8 (const std::string &str)
 verifies a UTF-8 stream, returning the total number of Unicode characters found More...
 

Detailed Description

A UTF-16 string with implicit conversion to/from std::string and std::wstring.

This class provides a complete 1 to 1 map of most std::string functions (at least to my knowledge). Implicit conversions allow this string class to work with all common C++ string formats, with specialty functions defined where implicit conversion would cause potential problems or is otherwise unavailable.

Some additional functionality is present to assist in working with characters using the 32-bit UTF-32 encoding. (Which is guaranteed to fit any Unicode character into a single code point.) Note: Reverse iterators do not have this functionality due to the ambiguity that surrounds working with UTF-16 in reverse. (Such as, where should an iterator point to represent the beginning of a surrogate pair?)

Supported Input Types
The supported string types for input, and their assumed encoding schemes, are:
  • std::string (UTF-8)
  • char* (UTF-8)
  • std::wstring (autodetected UTF-16 / UTF-32 based on compiler)
  • wchar_t* (autodetected UTF-16 / UTF-32 based on compiler)
See also

Definition at line 135 of file MyGUI_UString.h.

Member Typedef Documentation

◆ code_point

a single UTF-16 code point

Definition at line 160 of file MyGUI_UString.h.

◆ const_iterator

const iterator

Definition at line 407 of file MyGUI_UString.h.

◆ const_reverse_iterator

const reverse iterator

Definition at line 408 of file MyGUI_UString.h.

◆ dstring

using MyGUI::UString::dstring = std::basic_string<code_point>

Definition at line 165 of file MyGUI_UString.h.

◆ iterator

iterator

Definition at line 405 of file MyGUI_UString.h.

◆ reverse_iterator

reverse iterator

Definition at line 406 of file MyGUI_UString.h.

◆ size_type

using MyGUI::UString::size_type = size_t

size type used to indicate string size and character positions within the string

Definition at line 152 of file MyGUI_UString.h.

◆ unicode_char

a single 32-bit Unicode character

Definition at line 157 of file MyGUI_UString.h.

◆ utf32string

using MyGUI::UString::utf32string = std::basic_string<unicode_char>

string type used for returning UTF-32 formatted data

Definition at line 168 of file MyGUI_UString.h.

◆ value_type

value type typedef for use in iterators

Definition at line 163 of file MyGUI_UString.h.

Constructor & Destructor Documentation

◆ UString() [1/13]

MyGUI::UString::UString ( )

default constructor, creates an empty string

Definition at line 508 of file MyGUI_UString.cpp.

◆ UString() [2/13]

MyGUI::UString::UString ( const UString copy)

copy constructor

Definition at line 513 of file MyGUI_UString.cpp.

◆ UString() [3/13]

MyGUI::UString::UString ( size_type  length,
const code_point ch 
)

length copies of ch

Definition at line 519 of file MyGUI_UString.cpp.

◆ UString() [4/13]

MyGUI::UString::UString ( const code_point str)

duplicate of nul-terminated sequence str

Definition at line 525 of file MyGUI_UString.cpp.

◆ UString() [5/13]

MyGUI::UString::UString ( const code_point str,
size_type  length 
)

duplicate of str, length code points long

Definition at line 531 of file MyGUI_UString.cpp.

◆ UString() [6/13]

MyGUI::UString::UString ( const UString str,
size_type  index,
size_type  length 
)

substring of str starting at index and length code points long

Definition at line 537 of file MyGUI_UString.cpp.

◆ UString() [7/13]

MyGUI::UString::UString ( const wchar_t *  w_str)

duplicate of nul-terminated wchar_t array

◆ UString() [8/13]

MyGUI::UString::UString ( const wchar_t *  w_str,
size_type  length 
)

duplicate of w_str, length characters long

◆ UString() [9/13]

MyGUI::UString::UString ( const std::wstring &  wstr)

duplicate of wstr

Definition at line 557 of file MyGUI_UString.cpp.

◆ UString() [10/13]

MyGUI::UString::UString ( const char *  c_str)

duplicate of nul-terminated C-string c_str (UTF-8 encoding)

Definition at line 563 of file MyGUI_UString.cpp.

◆ UString() [11/13]

MyGUI::UString::UString ( const char *  c_str,
size_type  length 
)

duplicate of c_str, length characters long (UTF-8 encoding)

Definition at line 569 of file MyGUI_UString.cpp.

◆ UString() [12/13]

MyGUI::UString::UString ( const std::string &  str)

duplicate of str (UTF-8 encoding)

Definition at line 575 of file MyGUI_UString.cpp.

◆ UString() [13/13]

MyGUI::UString::UString ( const utf32string str)
explicit

Definition at line 581 of file MyGUI_UString.cpp.

◆ ~UString()

MyGUI::UString::~UString ( )

destructor

Definition at line 587 of file MyGUI_UString.cpp.

Member Function Documentation

◆ _utf16_char_length() [1/2]

size_t MyGUI::UString::_utf16_char_length ( code_point  cp)
static

estimates the number of UTF-16 code points in the sequence starting with cp

Definition at line 1654 of file MyGUI_UString.cpp.

◆ _utf16_char_length() [2/2]

size_t MyGUI::UString::_utf16_char_length ( unicode_char  uc)
static

returns the number of UTF-16 code points needed to represent the given UTF-32 character cp

Definition at line 1661 of file MyGUI_UString.cpp.

◆ _utf16_independent_char()

bool MyGUI::UString::_utf16_independent_char ( code_point  cp)
static

returns true if cp does not match the signature for the lead of follow code point of a surrogate pair in a UTF-16 sequence

Definition at line 1633 of file MyGUI_UString.cpp.

◆ _utf16_surrogate_follow()

bool MyGUI::UString::_utf16_surrogate_follow ( code_point  cp)
static

returns true if cp matches the signature of a surrogate pair following character

Definition at line 1647 of file MyGUI_UString.cpp.

◆ _utf16_surrogate_lead()

bool MyGUI::UString::_utf16_surrogate_lead ( code_point  cp)
static

returns true if cp matches the signature of a surrogate pair lead character

Definition at line 1640 of file MyGUI_UString.cpp.

◆ _utf16_to_utf32()

size_t MyGUI::UString::_utf16_to_utf32 ( const code_point  in_cp[2],
unicode_char out_uc 
)
static

converts the given UTF-16 character buffer in_cp to a single UTF-32 Unicode character out_uc, returns the number of code points used to create the output character (2 for surrogate pairs, otherwise 1)

This function does it's best to prevent error conditions, verifying complete surrogate pairs before applying the algorithm. In the event that half of a pair is found it will happily generate a value in the 0xD800 - 0xDFFF range, which is normally an invalid Unicode value but we preserve them for use as sentinel values.

Definition at line 1668 of file MyGUI_UString.cpp.

◆ _utf32_to_utf16()

size_t MyGUI::UString::_utf32_to_utf16 ( const unicode_char in_uc,
code_point  out_cp[2] 
)
static

writes the given UTF-32 uc_in to the buffer location out_cp using UTF-16 encoding, returns the number of code points used to encode the input (always 1 or 2)

This function, like its counterpart, will happily create invalid UTF-16 surrogate pairs. These invalid entries will be created for any value of in_uc that falls in the range U+D800 - U+DFFF. These are generally useful as sentinel values to represent various program specific conditions.

Note
This function will also pass through any single UTF-16 code point without modification, making it a safe method of ensuring a stream that is unknown UTF-32 or UTF-16 is truly UTF-16.

Definition at line 1697 of file MyGUI_UString.cpp.

◆ _utf32_to_utf8()

size_t MyGUI::UString::_utf32_to_utf8 ( const unicode_char in_uc,
unsigned char  out_cp[6] 
)
static

writes the given UTF-32 uc_in to the buffer location out_cp using UTF-8 encoding, returns the number of bytes used to encode the input

Definition at line 1804 of file MyGUI_UString.cpp.

◆ _utf8_char_length() [1/2]

size_t MyGUI::UString::_utf8_char_length ( unicode_char  uc)
static

returns the number of UTF-8 code points needed to represent the given UTF-32 character cp

Definition at line 1738 of file MyGUI_UString.cpp.

◆ _utf8_char_length() [2/2]

size_t MyGUI::UString::_utf8_char_length ( unsigned char  cp)
static

estimates the number of UTF-8 code points in the sequence starting with cp

Definition at line 1725 of file MyGUI_UString.cpp.

◆ _utf8_start_char()

bool MyGUI::UString::_utf8_start_char ( unsigned char  cp)
static

returns true if cp is the beginning of a UTF-8 sequence

Definition at line 1720 of file MyGUI_UString.cpp.

◆ _utf8_to_utf32()

size_t MyGUI::UString::_utf8_to_utf32 ( const unsigned char  in_cp[6],
unicode_char out_uc 
)
static

converts the given UTF-8 character buffer to a single UTF-32 Unicode character, returns the number of bytes used to create the output character (maximum of 6)

Definition at line 1759 of file MyGUI_UString.cpp.

◆ _verifyUTF8() [1/2]

UString::size_type MyGUI::UString::_verifyUTF8 ( const std::string &  str)
static

verifies a UTF-8 stream, returning the total number of Unicode characters found

Definition at line 1848 of file MyGUI_UString.cpp.

◆ _verifyUTF8() [2/2]

UString::size_type MyGUI::UString::_verifyUTF8 ( const unsigned char *  c_str)
static

verifies a UTF-8 stream, returning the total number of Unicode characters found

Definition at line 1842 of file MyGUI_UString.cpp.

◆ append() [1/11]

UString & MyGUI::UString::append ( const char *  c_str,
size_type  num 
)

appends num characters of str on to the end of the current string (UTF-8 encoding)

Definition at line 1037 of file MyGUI_UString.cpp.

◆ append() [2/11]

UString & MyGUI::UString::append ( const code_point str)

appends str on to the end of the current string

Definition at line 995 of file MyGUI_UString.cpp.

◆ append() [3/11]

UString & MyGUI::UString::append ( const code_point str,
size_type  num 
)

appends num characters of str on to the end of the current string

Definition at line 1007 of file MyGUI_UString.cpp.

◆ append() [4/11]

UString & MyGUI::UString::append ( const UString str)

appends str on to the end of the current string

Definition at line 989 of file MyGUI_UString.cpp.

◆ append() [5/11]

UString & MyGUI::UString::append ( const UString str,
size_type  index,
size_type  len 
)

appends a substring of str starting at index that is len characters long on to the end of the current string

Definition at line 1001 of file MyGUI_UString.cpp.

◆ append() [6/11]

UString & MyGUI::UString::append ( const wchar_t *  w_str,
size_type  num 
)

appends num characters of str on to the end of the current string

◆ append() [7/11]

UString & MyGUI::UString::append ( iterator  start,
iterator  end 
)

appends the sequence denoted by start and end on to the end of the current string

Definition at line 1019 of file MyGUI_UString.cpp.

◆ append() [8/11]

UString & MyGUI::UString::append ( size_type  num,
char  ch 
)

appends num repetitions of ch on to the end of the current string (Unicode values less than 128)

Definition at line 1044 of file MyGUI_UString.cpp.

◆ append() [9/11]

UString & MyGUI::UString::append ( size_type  num,
code_point  ch 
)

appends num repetitions of ch on to the end of the current string

Definition at line 1013 of file MyGUI_UString.cpp.

◆ append() [10/11]

UString & MyGUI::UString::append ( size_type  num,
unicode_char  ch 
)

appends num repetitions of ch on to the end of the current string (Full Unicode spectrum)

Definition at line 1050 of file MyGUI_UString.cpp.

◆ append() [11/11]

UString & MyGUI::UString::append ( size_type  num,
wchar_t  ch 
)

appends num repetitions of ch on to the end of the current string

◆ assign() [1/13]

UString & MyGUI::UString::assign ( const char *  c_str)

assign c_str to the current string (c_str is treated as a UTF-8 stream)

Definition at line 976 of file MyGUI_UString.cpp.

◆ assign() [2/13]

UString & MyGUI::UString::assign ( const char *  c_str,
size_type  num 
)

assign the first num characters of c_str to the current string (c_str is treated as a UTF-8 stream)

Definition at line 982 of file MyGUI_UString.cpp.

◆ assign() [3/13]

UString & MyGUI::UString::assign ( const code_point str)

assign the nul-terminated str to the current string

Definition at line 869 of file MyGUI_UString.cpp.

◆ assign() [4/13]

UString & MyGUI::UString::assign ( const code_point str,
size_type  num 
)

assign the first num characters of str to the current string

Definition at line 875 of file MyGUI_UString.cpp.

◆ assign() [5/13]

UString & MyGUI::UString::assign ( const std::string &  str)

assign str to the current string (str is treated as a UTF-8 stream)

Definition at line 934 of file MyGUI_UString.cpp.

◆ assign() [6/13]

UString & MyGUI::UString::assign ( const std::wstring &  wstr)

assign wstr to the current string (wstr is treated as a UTF-16 stream)

Definition at line 893 of file MyGUI_UString.cpp.

◆ assign() [7/13]

UString & MyGUI::UString::assign ( const UString str)

assign str to the current string

Definition at line 863 of file MyGUI_UString.cpp.

◆ assign() [8/13]

UString & MyGUI::UString::assign ( const UString str,
size_type  index,
size_type  len 
)

assign len entries from str to the current string, starting at index

Definition at line 881 of file MyGUI_UString.cpp.

◆ assign() [9/13]

UString & MyGUI::UString::assign ( const utf32string str)

Definition at line 967 of file MyGUI_UString.cpp.

◆ assign() [10/13]

UString & MyGUI::UString::assign ( const wchar_t *  w_str)

assign w_str to the current string

◆ assign() [11/13]

UString & MyGUI::UString::assign ( const wchar_t *  w_str,
size_type  num 
)

assign the first num characters of w_str to the current string

◆ assign() [12/13]

UString & MyGUI::UString::assign ( iterator  start,
iterator  end 
)

gives the current string the values from start to end

Definition at line 857 of file MyGUI_UString.cpp.

◆ assign() [13/13]

UString & MyGUI::UString::assign ( size_type  num,
const code_point ch 
)

assign num copies of ch to the current string

Definition at line 887 of file MyGUI_UString.cpp.

◆ asUTF32()

const UString::utf32string & MyGUI::UString::asUTF32 ( ) const

returns the current string in UTF-32 form within a utf32string

Definition at line 715 of file MyGUI_UString.cpp.

◆ asUTF32_c_str()

const UString::unicode_char * MyGUI::UString::asUTF32_c_str ( ) const

returns the current string in UTF-32 form as a nul-terminated unicode_char array

Definition at line 721 of file MyGUI_UString.cpp.

◆ asUTF8()

const std::string & MyGUI::UString::asUTF8 ( ) const

returns the current string in UTF-8 form within a std::string

Definition at line 703 of file MyGUI_UString.cpp.

◆ asUTF8_c_str()

const char * MyGUI::UString::asUTF8_c_str ( ) const

returns the current string in UTF-8 form as a nul-terminated char array

Definition at line 709 of file MyGUI_UString.cpp.

◆ asWStr()

const std::wstring & MyGUI::UString::asWStr ( ) const

returns the current string in the native form of std::wstring

Definition at line 727 of file MyGUI_UString.cpp.

◆ asWStr_c_str()

const wchar_t * MyGUI::UString::asWStr_c_str ( ) const

returns the current string in the native form of a nul-terminated wchar_t array

Definition at line 733 of file MyGUI_UString.cpp.

◆ at() [1/2]

UString::code_point & MyGUI::UString::at ( size_type  loc)

returns a reference to the element in the string at index loc

Definition at line 739 of file MyGUI_UString.cpp.

◆ at() [2/2]

const UString::code_point & MyGUI::UString::at ( size_type  loc) const

returns a reference to the element in the string at index loc

Definition at line 744 of file MyGUI_UString.cpp.

◆ begin() [1/2]

UString::iterator MyGUI::UString::begin ( )

returns an iterator to the first element of the string

Definition at line 793 of file MyGUI_UString.cpp.

◆ begin() [2/2]

UString::const_iterator MyGUI::UString::begin ( ) const

returns an iterator to the first element of the string

Definition at line 801 of file MyGUI_UString.cpp.

◆ c_str()

const UString::code_point * MyGUI::UString::c_str ( ) const

returns a pointer to the first character in the current string

Definition at line 638 of file MyGUI_UString.cpp.

◆ capacity()

UString::size_type MyGUI::UString::capacity ( ) const

returns the number of elements that the string can hold before it will need to allocate more space

Definition at line 648 of file MyGUI_UString.cpp.

◆ clear()

void MyGUI::UString::clear ( )

deletes all of the elements in the string

Definition at line 653 of file MyGUI_UString.cpp.

◆ compare() [1/7]

int MyGUI::UString::compare ( const code_point str) const

compare str to the current string

Definition at line 1251 of file MyGUI_UString.cpp.

◆ compare() [2/7]

int MyGUI::UString::compare ( const UString str) const

compare str to the current string

Definition at line 1246 of file MyGUI_UString.cpp.

◆ compare() [3/7]

int MyGUI::UString::compare ( size_type  index,
size_type  length,
const char *  c_str,
size_type  length2 
) const

compare a substring of str to a substring of the current string, where the substring of str begins at zero and is length2 UTF-8 code points long, and the substring of the current string begins at index and is length characters long

Definition at line 1279 of file MyGUI_UString.cpp.

◆ compare() [4/7]

int MyGUI::UString::compare ( size_type  index,
size_type  length,
const code_point str,
size_type  length2 
) const

compare a substring of str to a substring of the current string, where the substring of str begins at zero and is length2 characters long, and the substring of the current string begins at index and is length characters long

Definition at line 1266 of file MyGUI_UString.cpp.

◆ compare() [5/7]

int MyGUI::UString::compare ( size_type  index,
size_type  length,
const UString str 
) const

compare str to a substring of the current string, starting at index for length characters

Definition at line 1256 of file MyGUI_UString.cpp.

◆ compare() [6/7]

int MyGUI::UString::compare ( size_type  index,
size_type  length,
const UString str,
size_type  index2,
size_type  length2 
) const

compare a substring of str to a substring of the current string, where index2 and length2 refer to str and index and length refer to the current string

Definition at line 1261 of file MyGUI_UString.cpp.

◆ compare() [7/7]

int MyGUI::UString::compare ( size_type  index,
size_type  length,
const wchar_t *  w_str,
size_type  length2 
) const

compare a substring of str to a substring of the current string, where the substring of str begins at zero and is length2 elements long, and the substring of the current string begins at index and is length characters long

◆ data()

const UString::code_point * MyGUI::UString::data ( ) const

returns a pointer to the first character in the current string

Definition at line 643 of file MyGUI_UString.cpp.

◆ empty()

bool MyGUI::UString::empty ( ) const

returns true if the string has no elements, false otherwise

Definition at line 633 of file MyGUI_UString.cpp.

◆ end() [1/2]

UString::iterator MyGUI::UString::end ( )

returns an iterator just past the end of the string

Definition at line 809 of file MyGUI_UString.cpp.

◆ end() [2/2]

UString::const_iterator MyGUI::UString::end ( ) const

returns an iterator just past the end of the string

Definition at line 817 of file MyGUI_UString.cpp.

◆ erase() [1/3]

UString::iterator MyGUI::UString::erase ( iterator  loc)

removes the code point pointed to by loc, returning an iterator to the next character

Definition at line 1179 of file MyGUI_UString.cpp.

◆ erase() [2/3]

UString::iterator MyGUI::UString::erase ( iterator  start,
iterator  end 
)

removes the code points between start and end (including the one at start but not the one at end), returning an iterator to the code point after the last code point removed

Definition at line 1187 of file MyGUI_UString.cpp.

◆ erase() [3/3]

UString & MyGUI::UString::erase ( size_type  index = 0,
size_type  num = npos 
)

removes num code points from the current string, starting at index

Definition at line 1195 of file MyGUI_UString.cpp.

◆ find() [1/8]

UString::size_type MyGUI::UString::find ( char  ch,
size_type  index = 0 
) const

returns the index of the first occurrence ch within the current string, starting at index; returns UString::npos if nothing is found

ch is only capable of representing Unicode values up to U+007F (127)

Definition at line 1310 of file MyGUI_UString.cpp.

◆ find() [2/8]

UString::size_type MyGUI::UString::find ( code_point  ch,
size_type  index = 0 
) const

returns the index of the first occurrence ch within the current string, starting at index; returns UString::npos if nothing is found

ch is only capable of representing Unicode values up to U+FFFF (65535)

Definition at line 1315 of file MyGUI_UString.cpp.

◆ find() [3/8]

UString::size_type MyGUI::UString::find ( const char *  c_str,
size_type  index,
size_type  length 
) const

returns the index of the first occurrence of str within the current string and within length code points, starting at index; returns UString::npos if nothing is found

cp_str is a UTF-8 encoded string

Definition at line 1296 of file MyGUI_UString.cpp.

◆ find() [4/8]

UString::size_type MyGUI::UString::find ( const code_point cp_str,
size_type  index,
size_type  length 
) const

returns the index of the first occurrence of str within the current string and within length code points, starting at index; returns UString::npos if nothing is found

cp_str is a UTF-16 encoded string

Definition at line 1290 of file MyGUI_UString.cpp.

◆ find() [5/8]

UString::size_type MyGUI::UString::find ( const UString str,
size_type  index = 0 
) const

returns the index of the first occurrence of str within the current string, starting at index; returns UString::npos if nothing is found

str is a UTF-16 encoded string, but through implicit casting can also be a UTF-8 encoded string (const char* or std::string)

Definition at line 1285 of file MyGUI_UString.cpp.

◆ find() [6/8]

size_type MyGUI::UString::find ( const wchar_t *  w_str,
size_type  index,
size_type  length 
) const

returns the index of the first occurrence of str within the current string and within length code points, starting at index; returns UString::npos if nothing is found

cp_str is a UTF-16 encoded string

◆ find() [7/8]

UString::size_type MyGUI::UString::find ( unicode_char  ch,
size_type  index = 0 
) const

returns the index of the first occurrence ch within the current string, starting at index; returns UString::npos if nothing is found

ch can fully represent any Unicode character

Definition at line 1327 of file MyGUI_UString.cpp.

◆ find() [8/8]

size_type MyGUI::UString::find ( wchar_t  ch,
size_type  index = 0 
) const

returns the index of the first occurrence ch within the current string, starting at index; returns UString::npos if nothing is found

ch is only capable of representing Unicode values up to U+FFFF (65535)

◆ find_first_not_of() [1/5]

UString::size_type MyGUI::UString::find_first_not_of ( char  ch,
size_type  index = 0 
) const

returns the index of the first character within the current string that does not match ch, starting the search at index; returns UString::npos if nothing is found

Definition at line 1442 of file MyGUI_UString.cpp.

◆ find_first_not_of() [2/5]

UString::size_type MyGUI::UString::find_first_not_of ( code_point  ch,
size_type  index = 0 
) const

returns the index of the first character within the current string that does not match ch, starting the search at index; returns UString::npos if nothing is found

Definition at line 1435 of file MyGUI_UString.cpp.

◆ find_first_not_of() [3/5]

UString::size_type MyGUI::UString::find_first_not_of ( const UString str,
size_type  index = 0,
size_type  num = npos 
) const

returns the index of the first character within the current string that does not match any character in str, beginning the search at index and searching at most num characters; returns UString::npos if nothing is found

Definition at line 1422 of file MyGUI_UString.cpp.

◆ find_first_not_of() [4/5]

UString::size_type MyGUI::UString::find_first_not_of ( unicode_char  ch,
size_type  index = 0 
) const

returns the index of the first character within the current string that does not match ch, starting the search at index; returns UString::npos if nothing is found

Definition at line 1454 of file MyGUI_UString.cpp.

◆ find_first_not_of() [5/5]

size_type MyGUI::UString::find_first_not_of ( wchar_t  ch,
size_type  index = 0 
) const

returns the index of the first character within the current string that does not match ch, starting the search at index; returns UString::npos if nothing is found

◆ find_first_of() [1/5]

UString::size_type MyGUI::UString::find_first_of ( char  ch,
size_type  index = 0 
) const

returns the index of the first occurrence of ch in the current string, starting the search at index; returns UString::npos if nothing is found

Definition at line 1403 of file MyGUI_UString.cpp.

◆ find_first_of() [2/5]

UString::size_type MyGUI::UString::find_first_of ( code_point  ch,
size_type  index = 0 
) const

returns the index of the first occurrence of ch in the current string, starting the search at index; returns UString::npos if nothing is found

Definition at line 1396 of file MyGUI_UString.cpp.

◆ find_first_of() [3/5]

UString::size_type MyGUI::UString::find_first_of ( const UString str,
size_type  index = 0,
size_type  num = npos 
) const

Returns the index of the first character within the current string that matches any character in str, beginning the search at index and searching at most num characters; returns UString::npos if nothing is found.

Definition at line 1383 of file MyGUI_UString.cpp.

◆ find_first_of() [4/5]

UString::size_type MyGUI::UString::find_first_of ( unicode_char  ch,
size_type  index = 0 
) const

returns the index of the first occurrence of ch in the current string, starting the search at index; returns UString::npos if nothing is found

Definition at line 1415 of file MyGUI_UString.cpp.

◆ find_first_of() [5/5]

size_type MyGUI::UString::find_first_of ( wchar_t  ch,
size_type  index = 0 
) const

returns the index of the first occurrence of ch in the current string, starting the search at index; returns UString::npos if nothing is found

◆ find_last_not_of() [1/5]

UString::size_type MyGUI::UString::find_last_not_of ( char  ch,
size_type  index = npos 
) const

returns the index of the last occurrence of a character that does not match ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found

Definition at line 1531 of file MyGUI_UString.cpp.

◆ find_last_not_of() [2/5]

UString::size_type MyGUI::UString::find_last_not_of ( code_point  ch,
size_type  index = npos 
) const

returns the index of the last occurrence of a character that does not match ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found

Definition at line 1524 of file MyGUI_UString.cpp.

◆ find_last_not_of() [3/5]

UString::size_type MyGUI::UString::find_last_not_of ( const UString str,
size_type  index = npos,
size_type  num = npos 
) const

returns the index of the last character within the current string that does not match any character in str, doing a reverse search from index; returns UString::npos if nothing is found

Definition at line 1503 of file MyGUI_UString.cpp.

◆ find_last_not_of() [4/5]

UString::size_type MyGUI::UString::find_last_not_of ( unicode_char  ch,
size_type  index = npos 
) const

returns the index of the last occurrence of a character that does not match ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found

Definition at line 1543 of file MyGUI_UString.cpp.

◆ find_last_not_of() [5/5]

size_type MyGUI::UString::find_last_not_of ( wchar_t  ch,
size_type  index = npos 
) const

returns the index of the last occurrence of a character that does not match ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found

◆ find_last_of() [1/5]

size_type MyGUI::UString::find_last_of ( char  ch,
size_type  index = npos 
) const
inline

returns the index of the first occurrence of ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found

Definition at line 814 of file MyGUI_UString.h.

◆ find_last_of() [2/5]

UString::size_type MyGUI::UString::find_last_of ( code_point  ch,
size_type  index = npos 
) const

returns the index of the first occurrence of ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found

Definition at line 1482 of file MyGUI_UString.cpp.

◆ find_last_of() [3/5]

UString::size_type MyGUI::UString::find_last_of ( const UString str,
size_type  index = npos,
size_type  num = npos 
) const

returns the index of the first character within the current string that matches any character in str, doing a reverse search from index and searching at most num characters; returns UString::npos if nothing is found

Definition at line 1461 of file MyGUI_UString.cpp.

◆ find_last_of() [4/5]

UString::size_type MyGUI::UString::find_last_of ( unicode_char  ch,
size_type  index = npos 
) const

returns the index of the first occurrence of ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found

Definition at line 1496 of file MyGUI_UString.cpp.

◆ find_last_of() [5/5]

size_type MyGUI::UString::find_last_of ( wchar_t  ch,
size_type  index = npos 
) const

returns the index of the first occurrence of ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found

◆ getChar()

UString::unicode_char MyGUI::UString::getChar ( size_type  loc) const

returns the data point loc evaluated as a UTF-32 value

This function will will only properly decode surrogate pairs when loc points to the index of a lead code point that is followed by a trailing code point. Evaluating the trailing code point itself, or pointing to a code point that is a sentinel value (part of a broken pair) will return the value of just that code point (not a valid Unicode value, but useful as a sentinel value).

Definition at line 749 of file MyGUI_UString.cpp.

◆ insert() [1/16]

UString::iterator MyGUI::UString::insert ( iterator  i,
const code_point ch 
)

inserts ch before the code point denoted by i

Definition at line 1066 of file MyGUI_UString.cpp.

◆ insert() [2/16]

void MyGUI::UString::insert ( iterator  i,
iterator  start,
iterator  end 
)

inserts the code points denoted by start and end into the current string, before the code point specified by i

Definition at line 1086 of file MyGUI_UString.cpp.

◆ insert() [3/16]

void MyGUI::UString::insert ( iterator  i,
size_type  num,
const char &  ch 
)

inserts num copies of ch into the current string, before the code point denoted by i

Definition at line 1159 of file MyGUI_UString.cpp.

◆ insert() [4/16]

void MyGUI::UString::insert ( iterator  i,
size_type  num,
const code_point ch 
)

inserts num copies of ch into the current string, before the code point denoted by i

Definition at line 1148 of file MyGUI_UString.cpp.

◆ insert() [5/16]

void MyGUI::UString::insert ( iterator  i,
size_type  num,
const unicode_char ch 
)

inserts num copies of ch into the current string, before the code point denoted by i

Definition at line 1164 of file MyGUI_UString.cpp.

◆ insert() [6/16]

void MyGUI::UString::insert ( iterator  i,
size_type  num,
const wchar_t &  ch 
)

inserts num copies of ch into the current string, before the code point denoted by i

◆ insert() [7/16]

UString & MyGUI::UString::insert ( size_type  index,
const char *  c_str,
size_type  num 
)

inserts num code points of str into the current string, at location index

Definition at line 1106 of file MyGUI_UString.cpp.

◆ insert() [8/16]

UString & MyGUI::UString::insert ( size_type  index,
const code_point str 
)
inline

inserts str into the current string, at location index

Definition at line 634 of file MyGUI_UString.h.

◆ insert() [9/16]

UString & MyGUI::UString::insert ( size_type  index,
const code_point str,
size_type  num 
)

inserts num code points of str into the current string, at location index

Definition at line 1091 of file MyGUI_UString.cpp.

◆ insert() [10/16]

UString & MyGUI::UString::insert ( size_type  index,
const UString str 
)

inserts str into the current string, at location index

Definition at line 1074 of file MyGUI_UString.cpp.

◆ insert() [11/16]

UString & MyGUI::UString::insert ( size_type  index,
const wchar_t *  w_str,
size_type  num 
)

inserts num code points of str into the current string, at location index

◆ insert() [12/16]

UString & MyGUI::UString::insert ( size_type  index,
size_type  num,
char  ch 
)

inserts num copies of ch into the current string, at location index

Definition at line 1127 of file MyGUI_UString.cpp.

◆ insert() [13/16]

UString & MyGUI::UString::insert ( size_type  index,
size_type  num,
code_point  ch 
)

inserts num copies of ch into the current string, at location index

Definition at line 1113 of file MyGUI_UString.cpp.

◆ insert() [14/16]

UString & MyGUI::UString::insert ( size_type  index,
size_type  num,
unicode_char  ch 
)

inserts num copies of ch into the current string, at location index

Definition at line 1133 of file MyGUI_UString.cpp.

◆ insert() [15/16]

UString & MyGUI::UString::insert ( size_type  index,
size_type  num,
wchar_t  ch 
)

inserts num copies of ch into the current string, at location index

◆ insert() [16/16]

UString & MyGUI::UString::insert ( size_type  index1,
const UString str,
size_type  index2,
size_type  num 
)

inserts a substring of str (starting at index2 and num code points long) into the current string, at location index1

Definition at line 1080 of file MyGUI_UString.cpp.

◆ inString()

bool MyGUI::UString::inString ( unicode_char  ch) const

returns true if the given Unicode character ch is in this string

Definition at line 693 of file MyGUI_UString.cpp.

◆ length()

UString::size_type MyGUI::UString::length ( ) const

Returns the number of code points in the current string.

Definition at line 597 of file MyGUI_UString.cpp.

◆ length_Characters()

UString::size_type MyGUI::UString::length_Characters ( ) const

Returns the number of Unicode characters in the string.

Executes in linear time.

Definition at line 602 of file MyGUI_UString.cpp.

◆ max_size()

UString::size_type MyGUI::UString::max_size ( ) const

returns the maximum number of UTF-16 code points that the string can hold

Definition at line 613 of file MyGUI_UString.cpp.

◆ operator std::string()

MyGUI::UString::operator std::string ( ) const

implicit cast to std::string

Definition at line 1621 of file MyGUI_UString.cpp.

◆ operator std::wstring()

MyGUI::UString::operator std::wstring ( ) const

implicit cast to std::wstring

Definition at line 1627 of file MyGUI_UString.cpp.

◆ operator!=()

bool MyGUI::UString::operator!= ( const UString right) const

inequality operator

Definition at line 1606 of file MyGUI_UString.cpp.

◆ operator<()

bool MyGUI::UString::operator< ( const UString right) const

less than operator

Definition at line 1550 of file MyGUI_UString.cpp.

◆ operator<=()

bool MyGUI::UString::operator<= ( const UString right) const

less than or equal operator

Definition at line 1555 of file MyGUI_UString.cpp.

◆ operator=() [1/5]

UString & MyGUI::UString::operator= ( char  ch)

assignment operator

Definition at line 1571 of file MyGUI_UString.cpp.

◆ operator=() [2/5]

UString & MyGUI::UString::operator= ( code_point  ch)

assignment operator

Definition at line 1565 of file MyGUI_UString.cpp.

◆ operator=() [3/5]

UString & MyGUI::UString::operator= ( const UString s)

assignment operator, implicitly casts all compatible types

Definition at line 1560 of file MyGUI_UString.cpp.

◆ operator=() [4/5]

UString & MyGUI::UString::operator= ( unicode_char  ch)

assignment operator

Definition at line 1585 of file MyGUI_UString.cpp.

◆ operator=() [5/5]

UString & MyGUI::UString::operator= ( wchar_t  ch)

assignment operator

◆ operator==()

bool MyGUI::UString::operator== ( const UString right) const

equality operator

Definition at line 1601 of file MyGUI_UString.cpp.

◆ operator>()

bool MyGUI::UString::operator> ( const UString right) const

greater than operator

Definition at line 1591 of file MyGUI_UString.cpp.

◆ operator>=()

bool MyGUI::UString::operator>= ( const UString right) const

greater than or equal operator

Definition at line 1596 of file MyGUI_UString.cpp.

◆ operator[]() [1/2]

UString::code_point & MyGUI::UString::operator[] ( size_type  index)

code point dereference operator

Definition at line 1611 of file MyGUI_UString.cpp.

◆ operator[]() [2/2]

const UString::code_point & MyGUI::UString::operator[] ( size_type  index) const

code point dereference operator

Definition at line 1616 of file MyGUI_UString.cpp.

◆ push_back() [1/4]

void MyGUI::UString::push_back ( char  val)

appends val to the end of the string

Limited to characters under the 127 value barrier.

Definition at line 688 of file MyGUI_UString.cpp.

◆ push_back() [2/4]

void MyGUI::UString::push_back ( code_point  val)

appends val to the end of the string

This can be used to push surrogate pair code points, you'll just need to push them one after the other.

Definition at line 683 of file MyGUI_UString.cpp.

◆ push_back() [3/4]

void MyGUI::UString::push_back ( unicode_char  val)

appends val to the end of the string

Definition at line 667 of file MyGUI_UString.cpp.

◆ push_back() [4/4]

void MyGUI::UString::push_back ( wchar_t  val)

appends val to the end of the string

◆ rbegin() [1/2]

UString::reverse_iterator MyGUI::UString::rbegin ( )

returns a reverse iterator to the last element of the string

Definition at line 825 of file MyGUI_UString.cpp.

◆ rbegin() [2/2]

UString::const_reverse_iterator MyGUI::UString::rbegin ( ) const

returns a reverse iterator to the last element of the string

Definition at line 833 of file MyGUI_UString.cpp.

◆ rend() [1/2]

UString::reverse_iterator MyGUI::UString::rend ( )

returns a reverse iterator just past the beginning of the string

Definition at line 841 of file MyGUI_UString.cpp.

◆ rend() [2/2]

UString::const_reverse_iterator MyGUI::UString::rend ( ) const

returns a reverse iterator just past the beginning of the string

Definition at line 849 of file MyGUI_UString.cpp.

◆ replace() [1/6]

UString & MyGUI::UString::replace ( iterator  start,
iterator  end,
const UString str,
size_type  num = npos 
)

replaces code points in the current string from start to end with num code points from str

Definition at line 1222 of file MyGUI_UString.cpp.

◆ replace() [2/6]

UString & MyGUI::UString::replace ( iterator  start,
iterator  end,
size_type  num,
code_point  ch 
)

replaces the code points in the current string from start to end with num copies of ch

Definition at line 1237 of file MyGUI_UString.cpp.

◆ replace() [3/6]

UString & MyGUI::UString::replace ( size_type  index,
size_type  num1,
size_type  num2,
code_point  ch 
)

replaces up to num1 code points in the current string (beginning at index) with num2 copies of ch

Definition at line 1231 of file MyGUI_UString.cpp.

◆ replace() [4/6]

UString & MyGUI::UString::replace ( size_type  index1,
size_type  num1,
const UString str 
)

replaces up to num1 code points of the current string (starting at index1) with str

Definition at line 1204 of file MyGUI_UString.cpp.

◆ replace() [5/6]

UString & MyGUI::UString::replace ( size_type  index1,
size_type  num1,
const UString str,
size_type  index2,
size_type  num2 
)

replaces up to num1 code points of the current string (starting at index1) with up to num2 code points from str beginning at index2

Definition at line 1216 of file MyGUI_UString.cpp.

◆ replace() [6/6]

UString & MyGUI::UString::replace ( size_type  index1,
size_type  num1,
const UString str,
size_type  num2 
)

replaces up to num1 code points of the current string (starting at index1) with up to num2 code points from str

Definition at line 1210 of file MyGUI_UString.cpp.

◆ reserve()

void MyGUI::UString::reserve ( size_type  size)

sets the capacity of the string to at least size code points

Definition at line 618 of file MyGUI_UString.cpp.

◆ resize()

void MyGUI::UString::resize ( size_type  num,
const code_point val = 0 
)

changes the size of the string to size, filling in any new area with val

Definition at line 623 of file MyGUI_UString.cpp.

◆ rfind() [1/8]

UString::size_type MyGUI::UString::rfind ( char  ch,
size_type  index = 0 
) const

returns the location of the first occurrence of ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found

Definition at line 1359 of file MyGUI_UString.cpp.

◆ rfind() [2/8]

UString::size_type MyGUI::UString::rfind ( code_point  ch,
size_type  index 
) const

returns the location of the first occurrence of ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found

Definition at line 1364 of file MyGUI_UString.cpp.

◆ rfind() [3/8]

UString::size_type MyGUI::UString::rfind ( const char *  c_str,
size_type  index,
size_type  num 
) const

returns the location of the first occurrence of str in the current string, doing a reverse search from index, searching at most num characters; returns UString::npos if nothing is found

Definition at line 1345 of file MyGUI_UString.cpp.

◆ rfind() [4/8]

UString::size_type MyGUI::UString::rfind ( const code_point cp_str,
size_type  index,
size_type  num 
) const

returns the location of the first occurrence of str in the current string, doing a reverse search from index, searching at most num characters; returns UString::npos if nothing is found

Definition at line 1339 of file MyGUI_UString.cpp.

◆ rfind() [5/8]

UString::size_type MyGUI::UString::rfind ( const UString str,
size_type  index = 0 
) const

returns the location of the first occurrence of str in the current string, doing a reverse search from index; returns UString::npos if nothing is found

Definition at line 1334 of file MyGUI_UString.cpp.

◆ rfind() [6/8]

size_type MyGUI::UString::rfind ( const wchar_t *  w_str,
size_type  index,
size_type  num 
) const

returns the location of the first occurrence of str in the current string, doing a reverse search from index, searching at most num characters; returns UString::npos if nothing is found

◆ rfind() [7/8]

UString::size_type MyGUI::UString::rfind ( unicode_char  ch,
size_type  index = 0 
) const

returns the location of the first occurrence of ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found

Definition at line 1376 of file MyGUI_UString.cpp.

◆ rfind() [8/8]

size_type MyGUI::UString::rfind ( wchar_t  ch,
size_type  index = 0 
) const

returns the location of the first occurrence of ch in the current string, doing a reverse search from index; returns UString::npos if nothing is found

◆ setChar()

int MyGUI::UString::setChar ( size_type  loc,
unicode_char  ch 
)

sets the value of the character at loc to the Unicode value ch (UTF-32)

Providing sentinel values (values between U+D800-U+DFFF) are accepted, but you should be aware that you can also unwittingly create a valid surrogate pair if you don't pay attention to what you are doing.

Note
This operation may also lengthen the string if a surrogate pair is needed to represent the value given, but one is not available to replace; or alternatively shorten the string if an existing surrogate pair is replaced with a character that is representable without a surrogate pair. The return value will signify any lengthening or shortening performed, returning 0 if no change was made, -1 if the string was shortened, or 1 if the string was lengthened. Any single call can only change the string length by + or - 1.

Definition at line 766 of file MyGUI_UString.cpp.

◆ size()

UString::size_type MyGUI::UString::size ( ) const

Returns the number of code points in the current string.

Definition at line 592 of file MyGUI_UString.cpp.

◆ substr()

UString MyGUI::UString::substr ( size_type  index,
size_type  num = npos 
) const

returns a substring of the current string, starting at index, and num characters long.

If num is omitted, it will default to UString::npos, and the substr() function will simply return the remainder of the string starting at index.

Definition at line 658 of file MyGUI_UString.cpp.

◆ swap()

void MyGUI::UString::swap ( UString from)

exchanges the elements of the current string with those of from

Definition at line 628 of file MyGUI_UString.cpp.

Friends And Related Function Documentation

◆ operator+() [1/9]

UString operator+ ( char  c,
const UString s2 
)
related

string addition operator

Definition at line 1008 of file MyGUI_UString.h.

◆ operator+() [2/9]

UString operator+ ( const UString s1,
char  c 
)
related

string addition operator

Definition at line 990 of file MyGUI_UString.h.

◆ operator+() [3/9]

UString operator+ ( const UString s1,
const UString s2 
)
related

string addition operator

Definition at line 978 of file MyGUI_UString.h.

◆ operator+() [4/9]

UString operator+ ( const UString s1,
UString::code_point  c 
)
related

string addition operator

Definition at line 982 of file MyGUI_UString.h.

◆ operator+() [5/9]

UString operator+ ( const UString s1,
UString::unicode_char  c 
)
related

string addition operator

Definition at line 986 of file MyGUI_UString.h.

◆ operator+() [6/9]

UString operator+ ( const UString s1,
wchar_t  c 
)
related

string addition operator

Definition at line 995 of file MyGUI_UString.h.

◆ operator+() [7/9]

UString operator+ ( UString::code_point  c,
const UString s2 
)
related

string addition operator

Definition at line 1000 of file MyGUI_UString.h.

◆ operator+() [8/9]

UString operator+ ( UString::unicode_char  c,
const UString s2 
)
related

string addition operator

Definition at line 1004 of file MyGUI_UString.h.

◆ operator+() [9/9]

UString operator+ ( wchar_t  c,
const UString s2 
)
related

string addition operator

Definition at line 1013 of file MyGUI_UString.h.

◆ operator<<() [1/2]

std::ostream & operator<< ( std::ostream &  os,
const UString s 
)
related

std::ostream write operator

Definition at line 1066 of file MyGUI_UString.h.

◆ operator<<() [2/2]

std::wostream & operator<< ( std::wostream &  os,
const UString s 
)
related

std::wostream write operator

Definition at line 1071 of file MyGUI_UString.h.

Field Documentation

◆ mStrBuffer

std::string* MyGUI::UString::mStrBuffer
mutable

Definition at line 970 of file MyGUI_UString.h.

◆ mUTF32StrBuffer

utf32string* MyGUI::UString::mUTF32StrBuffer
mutable

Definition at line 972 of file MyGUI_UString.h.

◆ mVoidBuffer

void* MyGUI::UString::mVoidBuffer
mutable

Definition at line 969 of file MyGUI_UString.h.

◆ mWStrBuffer

std::wstring* MyGUI::UString::mWStrBuffer
mutable

Definition at line 971 of file MyGUI_UString.h.

◆ npos

const size_type MyGUI::UString::npos = static_cast<size_type>(~0)
static

the usual constant representing: not found, no limit, etc

Definition at line 154 of file MyGUI_UString.h.


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