32 #include "CEGUI/Base.h"
47 #if CEGUI_STRING_CLASS == CEGUI_STRING_CLASS_UNICODE
52 #define CEGUI_STR_QUICKBUFF_SIZE 32
77 static const size_type
npos;
86 mutable utf8* d_encodedbuff;
87 mutable size_type d_encodeddatlen;
88 mutable size_type d_encodedbufflen;
90 utf32 d_quickbuff[CEGUI_STR_QUICKBUFF_SIZE];
98 class iterator :
public std::iterator<std::random_access_iterator_tag, utf32>
102 explicit iterator(utf32*
const ptr) : d_ptr(ptr) {}
104 utf32& operator*()
const
109 utf32* operator->()
const
149 return temp += offset;
154 return *
this += -offset;
160 return temp -= offset;
163 utf32& operator[](difference_type offset)
const
165 return *(*
this + offset);
170 {
return lhs.d_ptr - rhs.d_ptr; }
173 {
return iter + offset; }
177 {
return lhs.d_ptr == rhs.d_ptr; }
181 {
return lhs.d_ptr != rhs.d_ptr; }
185 {
return lhs.d_ptr < rhs.d_ptr; }
189 {
return lhs.d_ptr > rhs.d_ptr; }
193 {
return lhs.d_ptr <= rhs.d_ptr; }
197 {
return lhs.d_ptr >= rhs.d_ptr; }
203 class const_iterator :
public std::iterator<std::random_access_iterator_tag, const utf32>
210 const utf32& operator*()
const
215 const utf32* operator->()
const
255 return temp += offset;
260 return *
this += -offset;
266 return temp -= offset;
269 const utf32& operator[](difference_type offset)
const
271 return *(*
this + offset);
281 {
return iter + offset; }
285 {
return lhs.d_ptr - rhs.d_ptr; }
289 {
return lhs.d_ptr == rhs.d_ptr; }
293 {
return lhs.d_ptr != rhs.d_ptr; }
297 {
return lhs.d_ptr < rhs.d_ptr; }
301 {
return lhs.d_ptr > rhs.d_ptr; }
305 {
return lhs.d_ptr <= rhs.d_ptr; }
309 {
return lhs.d_ptr >= rhs.d_ptr; }
318 #if defined(_MSC_VER) && ((_MSC_VER <= 1200) || ((_MSC_VER <= 1300) && defined(_STLPORT_VERSION)))
319 typedef std::reverse_iterator<const_iterator, const_pointer, const_reference, difference_type>
const_reverse_iterator;
328 #if defined(_MSC_VER) && ((_MSC_VER <= 1200) || ((_MSC_VER <= 1300) && defined(_STLPORT_VERSION)))
329 typedef std::reverse_iterator<iterator, pointer, reference, difference_type>
reverse_iterator;
392 assign(str, str_idx, str_num);
442 String(
const std::string& std_str, size_type str_idx, size_type str_num = npos)
445 assign(std_str, str_idx, str_num);
502 String(
const utf8* utf8_str, size_type chars_len)
505 assign(utf8_str, chars_len);
529 assign(num, code_point);
552 append(iter_beg, iter_end);
592 String(
const char* chars, size_type chars_len)
595 assign(chars, chars_len);
635 return (d_cplength == 0);
649 return (((size_type)-1) /
sizeof(utf32));
667 return d_reserve - 1;
713 return compare(0, d_cplength, str);
745 int compare(size_type idx, size_type len,
const String& str, size_type str_idx = 0, size_type str_len = npos)
const
747 if ((d_cplength < idx) || (str.d_cplength < str_idx))
748 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
750 if ((len == npos) || (idx + len > d_cplength))
751 len = d_cplength - idx;
753 if ((str_len == npos) || (str_idx + str_len > str.d_cplength))
754 str_len = str.d_cplength - str_idx;
756 int val = (len == 0) ? 0 : utf32_comp_utf32(&ptr()[idx], &str.
ptr()[str_idx], (len < str_len) ? len : str_len);
758 return (val != 0) ? ((val < 0) ? -1 : 1) : (len < str_len) ? -1 : (len == str_len) ? 0 : 1;
783 return compare(0, d_cplength, std_str);
820 int compare(size_type idx, size_type len,
const std::string& std_str, size_type str_idx = 0, size_type str_len = npos)
const
822 if (d_cplength < idx)
823 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
825 if (std_str.size() < str_idx)
826 CEGUI_THROW(std::out_of_range(
"Index is out of range for std::string"));
828 if ((len == npos) || (idx + len > d_cplength))
829 len = d_cplength - idx;
831 if ((str_len == npos) || (str_idx + str_len > std_str.size()))
832 str_len = (size_type)std_str.size() - str_idx;
834 int val = (len == 0) ? 0 : utf32_comp_char(&ptr()[idx], &std_str.c_str()[str_idx], (len < str_len) ? len : str_len);
836 return (val != 0) ? ((val < 0) ? -1 : 1) : (len < str_len) ? -1 : (len == str_len) ? 0 : 1;
863 return compare(0, d_cplength, utf8_str, encoded_size(utf8_str));
896 int compare(size_type idx, size_type len,
const utf8* utf8_str)
const
898 return compare(idx, len, utf8_str, encoded_size(utf8_str));
934 int compare(size_type idx, size_type len,
const utf8* utf8_str, size_type str_cplen)
const
936 if (d_cplength < idx)
937 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
939 if (str_cplen == npos)
940 CEGUI_THROW(std::length_error(
"Length for utf8 encoded string can not be 'npos'"));
942 if ((len == npos) || (idx + len > d_cplength))
943 len = d_cplength - idx;
945 int val = (len == 0) ? 0 : utf32_comp_utf8(&ptr()[idx], utf8_str, (len < str_cplen) ? len : str_cplen);
947 return (val != 0) ? ((val < 0) ? -1 : 1) : (len < str_cplen) ? -1 : (len == str_cplen) ? 0 : 1;
968 return compare(0, d_cplength, cstr, strlen(cstr));
995 int compare(size_type idx, size_type len,
const char* cstr)
const
997 return compare(idx, len, cstr, strlen(cstr));
1028 int compare(size_type idx, size_type len,
const char* chars, size_type chars_len)
const
1030 if (d_cplength < idx)
1031 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
1033 if (chars_len == npos)
1034 CEGUI_THROW(std::length_error(
"Length for char array can not be 'npos'"));
1036 if ((len == npos) || (idx + len > d_cplength))
1037 len = d_cplength - idx;
1039 int val = (len == 0) ? 0 : utf32_comp_char(&ptr()[idx], chars, (len < chars_len) ? len : chars_len);
1041 return (val != 0) ? ((val < 0) ? -1 : 1) : (len < chars_len) ? -1 : (len == chars_len) ? 0 : 1;
1064 return (ptr()[idx]);
1098 reference
at(size_type idx)
1100 if (d_cplength <= idx)
1101 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
1118 const_reference
at(size_type idx)
const
1120 if (d_cplength <= idx)
1121 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
1145 return (
const char*)build_utf8_buff();
1163 return build_utf8_buff();
1172 return (d_reserve > CEGUI_STR_QUICKBUFF_SIZE) ? d_buffer : d_quickbuff;
1181 return (d_reserve > CEGUI_STR_QUICKBUFF_SIZE) ? d_buffer : d_quickbuff;
1206 size_type
copy(utf8* buf, size_type len = npos, size_type idx = 0)
const
1208 if (d_cplength < idx)
1209 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
1214 return encode(&ptr()[idx], buf, npos, len);
1238 using namespace std;
1240 if (d_cplength < idx)
1241 CEGUI_THROW(out_of_range(
"Index was out of range for CEGUI::String object"));
1243 size_type maxlen = d_cplength - idx;
1245 return encoded_size(&ptr()[idx], ceguimin(num, maxlen));
1286 if (str.d_cplength < str_idx)
1287 CEGUI_THROW(std::out_of_range(
"Index was out of range for CEGUI::String object"));
1289 if ((str_num == npos) || (str_num > str.d_cplength - str_idx))
1290 str_num = str.d_cplength - str_idx;
1294 memcpy(ptr(), &str.
ptr()[str_idx], str_num *
sizeof(utf32));
1317 return assign(std_str);
1343 String&
assign(
const std::string& std_str, size_type str_idx = 0, size_type str_num = npos)
1345 if (std_str.size() < str_idx)
1346 CEGUI_THROW(std::out_of_range(
"Index was out of range for std::string object"));
1348 if ((str_num == npos) || (str_num > (size_type)std_str.size() - str_idx))
1349 str_num = (size_type)std_str.size() - str_idx;
1356 ((*this)[str_num]) = static_cast<utf32>(static_cast<unsigned char>(std_str[str_num + str_idx]));
1382 return assign(utf8_str, utf_length(utf8_str));
1405 return assign(utf8_str, utf_length(utf8_str));
1431 if (str_num == npos)
1432 CEGUI_THROW(std::length_error(
"Length for utf8 encoded string can not be 'npos'"));
1434 size_type enc_sze = encoded_size(utf8_str, str_num);
1437 encode(utf8_str, ptr(), d_reserve, str_num);
1454 return assign(1, code_point);
1475 CEGUI_THROW(std::length_error(
"Code point count can not be 'npos'"));
1502 return assign(cstr, strlen(cstr));
1520 return assign(cstr, strlen(cstr));
1544 for (size_type i = 0; i < chars_len; ++i)
1546 *pt++ =
static_cast<utf32
>(
static_cast<unsigned char>(*chars++));
1566 size_type temp_len = d_cplength;
1567 d_cplength = str.d_cplength;
1568 str.d_cplength = temp_len;
1570 size_type temp_res = d_reserve;
1571 d_reserve = str.d_reserve;
1572 str.d_reserve = temp_res;
1574 utf32* temp_buf = d_buffer;
1575 d_buffer = str.d_buffer;
1576 str.d_buffer = temp_buf;
1579 if (temp_res <= CEGUI_STR_QUICKBUFF_SIZE)
1581 utf32 temp_qbf[CEGUI_STR_QUICKBUFF_SIZE];
1583 memcpy(temp_qbf, d_quickbuff, CEGUI_STR_QUICKBUFF_SIZE *
sizeof(utf32));
1584 memcpy(d_quickbuff, str.d_quickbuff, CEGUI_STR_QUICKBUFF_SIZE *
sizeof(utf32));
1585 memcpy(str.d_quickbuff, temp_qbf, CEGUI_STR_QUICKBUFF_SIZE *
sizeof(utf32));
1631 if (str.d_cplength < str_idx)
1632 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
1634 if ((str_num == npos) || (str_num > str.d_cplength - str_idx))
1635 str_num = str.d_cplength - str_idx;
1637 grow(d_cplength + str_num);
1638 memcpy(&ptr()[d_cplength], &str.
ptr()[str_idx], str_num *
sizeof(utf32));
1639 setlen(d_cplength + str_num);
1662 return append(std_str);
1688 String&
append(
const std::string& std_str, size_type str_idx = 0, size_type str_num = npos)
1690 if (std_str.size() < str_idx)
1691 CEGUI_THROW(std::out_of_range(
"Index is out of range for std::string"));
1693 if ((str_num == npos) || (str_num > (size_type)std_str.size() - str_idx))
1694 str_num = (size_type)std_str.size() - str_idx;
1696 size_type newsze = d_cplength + str_num;
1699 utf32* pt = &ptr()[newsze-1];
1702 *pt-- =
static_cast<utf32
>(
static_cast<unsigned char>(std_str[str_num]));
1729 return append(utf8_str, utf_length(utf8_str));
1752 return append(utf8_str, utf_length(utf8_str));
1780 CEGUI_THROW(std::length_error(
"Length for utf8 encoded string can not be 'npos'"));
1782 size_type encsz = encoded_size(utf8_str, len);
1783 size_type newsz = d_cplength + encsz;
1786 encode(utf8_str, &ptr()[d_cplength], encsz, len);
1807 return append(1, code_point);
1828 CEGUI_THROW(std::length_error(
"Code point count can not be 'npos'"));
1830 size_type newsz = d_cplength + num;
1833 utf32* p = &ptr()[d_cplength];
1857 append(1, code_point);
1877 return replace(end(), end(), iter_beg, iter_end);
1895 return append(cstr, strlen(cstr));
1913 return append(cstr, strlen(cstr));
1934 if (chars_len == npos)
1935 CEGUI_THROW(std::length_error(
"Length for char array can not be 'npos'"));
1937 size_type newsz = d_cplength + chars_len;
1941 utf32* pt = &ptr()[newsz-1];
1944 *pt-- =
static_cast<utf32
>(
static_cast<unsigned char>(chars[chars_len]));
1973 return insert(idx, str, 0, npos);
2000 if ((d_cplength < idx) || (str.d_cplength < str_idx))
2001 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
2003 if ((str_num == npos) || (str_num > str.d_cplength - str_idx))
2004 str_num = str.d_cplength - str_idx;
2006 size_type newsz = d_cplength + str_num;
2008 memmove(&ptr()[idx + str_num], &ptr()[idx], (d_cplength - idx) *
sizeof(utf32));
2009 memcpy(&ptr()[idx], &str.
ptr()[str_idx], str_num *
sizeof(utf32));
2037 return insert(idx, std_str, 0, npos);
2066 String&
insert(size_type idx,
const std::string& std_str, size_type str_idx, size_type str_num)
2068 if (d_cplength < idx)
2069 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
2071 if (std_str.size() < str_idx)
2072 CEGUI_THROW(std::out_of_range(
"Index is out of range for std::string"));
2074 if ((str_num == npos) || (str_num > (size_type)std_str.size() - str_idx))
2075 str_num = (size_type)std_str.size() - str_idx;
2077 size_type newsz = d_cplength + str_num;
2080 memmove(&ptr()[idx + str_num], &ptr()[idx], (d_cplength - idx) *
sizeof(utf32));
2082 utf32* pt = &ptr()[idx + str_num - 1];
2085 *pt-- =
static_cast<utf32
>(
static_cast<unsigned char>(std_str[str_idx + str_num]));
2116 return insert(idx, utf8_str, utf_length(utf8_str));
2146 if (d_cplength < idx)
2147 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
2150 CEGUI_THROW(std::length_error(
"Length of utf8 encoded string can not be 'npos'"));
2152 size_type encsz = encoded_size(utf8_str, len);
2153 size_type newsz = d_cplength + encsz;
2156 memmove(&ptr()[idx + encsz], &ptr()[idx], (d_cplength - idx) *
sizeof(utf32));
2157 encode(utf8_str, &ptr()[idx], encsz, len);
2184 if (d_cplength < idx)
2185 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
2188 CEGUI_THROW(std::length_error(
"Code point count can not be 'npos'"));
2190 size_type newsz = d_cplength + num;
2193 memmove(&ptr()[idx + num], &ptr()[idx], (d_cplength - idx) *
sizeof(utf32));
2195 utf32* pt = &ptr()[idx + num - 1];
2225 insert(safe_iter_dif(pos, begin()), num, code_point);
2245 insert(pos, 1, code_point);
2269 replace(iter_pos, iter_pos, iter_beg, iter_end);
2291 return insert(idx, cstr, strlen(cstr));
2316 if (d_cplength < idx)
2317 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
2319 if (chars_len == npos)
2320 CEGUI_THROW(std::length_error(
"Length of char array can not be 'npos'"));
2322 size_type newsz = d_cplength + chars_len;
2325 memmove(&ptr()[idx + chars_len], &ptr()[idx], (d_cplength - idx) *
sizeof(utf32));
2327 utf32* pt = &ptr()[idx + chars_len - 1];
2330 *pt-- =
static_cast<utf32
>(
static_cast<unsigned char>(chars[chars_len]));
2381 return erase(idx, 1);
2405 if (d_cplength <= idx)
2406 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
2409 len = d_cplength - idx;
2411 size_type newsz = d_cplength - len;
2413 memmove(&ptr()[idx], &ptr()[idx + len], (d_cplength - idx - len) *
sizeof(utf32));
2430 return erase(safe_iter_dif(pos, begin()), 1);
2448 return erase(safe_iter_dif(iter_beg, begin()), safe_iter_dif(iter_end, iter_beg));
2468 resize(num, utf32());
2488 if (num < d_cplength)
2494 append(num - d_cplength, code_point);
2523 return replace(idx, len, str, 0, npos);
2549 return replace(safe_iter_dif(iter_beg, begin()), safe_iter_dif(iter_end, iter_beg), str, 0, npos);
2579 if ((d_cplength < idx) || (str.d_cplength < str_idx))
2580 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
2582 if (((str_idx + str_num) > str.d_cplength) || (str_num == npos))
2583 str_num = str.d_cplength - str_idx;
2585 if (((len + idx) > d_cplength) || (len == npos))
2586 len = d_cplength - idx;
2588 size_type newsz = d_cplength + str_num - len;
2592 if ((idx + len) < d_cplength)
2593 memmove(&ptr()[idx + str_num], &ptr()[len + idx], (d_cplength - idx - len) *
sizeof(utf32));
2595 memcpy(&ptr()[idx], &str.
ptr()[str_idx], str_num *
sizeof(utf32));
2627 return replace(idx, len, std_str, 0, npos);
2657 return replace(safe_iter_dif(iter_beg, begin()), safe_iter_dif(iter_end, iter_beg), std_str, 0, npos);
2689 String&
replace(size_type idx, size_type len,
const std::string& std_str, size_type str_idx, size_type str_num)
2691 if (d_cplength < idx)
2692 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
2694 if (std_str.size() < str_idx)
2695 CEGUI_THROW(std::out_of_range(
"Index is out of range for std::string"));
2697 if (((str_idx + str_num) > std_str.size()) || (str_num == npos))
2698 str_num = (size_type)std_str.size() - str_idx;
2700 if (((len + idx) > d_cplength) || (len == npos))
2701 len = d_cplength - idx;
2703 size_type newsz = d_cplength + str_num - len;
2707 if ((idx + len) < d_cplength)
2708 memmove(&ptr()[idx + str_num], &ptr()[len + idx], (d_cplength - idx - len) *
sizeof(utf32));
2710 utf32* pt = &ptr()[idx + str_num - 1];
2713 *pt-- =
static_cast<utf32
>(
static_cast<unsigned char>(std_str[str_idx + str_num]));
2748 return replace(idx, len, utf8_str, utf_length(utf8_str));
2780 return replace(iter_beg, iter_end, utf8_str, utf_length(utf8_str));
2811 String&
replace(size_type idx, size_type len,
const utf8* utf8_str, size_type str_len)
2813 if (d_cplength < idx)
2814 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
2816 if (str_len == npos)
2817 CEGUI_THROW(std::length_error(
"Length for utf8 encoded string can not be 'npos'"));
2819 if (((len + idx) > d_cplength) || (len == npos))
2820 len = d_cplength - idx;
2822 size_type encsz = encoded_size(utf8_str, str_len);
2823 size_type newsz = d_cplength + encsz - len;
2827 if ((idx + len) < d_cplength)
2828 memmove(&ptr()[idx + encsz], &ptr()[len + idx], (d_cplength - idx - len) *
sizeof(utf32));
2830 encode(utf8_str, &ptr()[idx], encsz, str_len);
2868 return replace(safe_iter_dif(iter_beg, begin()), safe_iter_dif(iter_end, iter_beg), utf8_str, str_len);
2895 if (d_cplength < idx)
2896 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
2899 CEGUI_THROW(std::length_error(
"Code point count can not be 'npos'"));
2901 if (((len + idx) > d_cplength) || (len == npos))
2902 len = d_cplength - idx;
2904 size_type newsz = d_cplength + num - len;
2908 if ((idx + len) < d_cplength)
2909 memmove(&ptr()[idx + num], &ptr()[len + idx], (d_cplength - idx - len) *
sizeof(utf32));
2911 utf32* pt = &ptr()[idx + num - 1];
2947 return replace(safe_iter_dif(iter_beg, begin()), safe_iter_dif(iter_end, iter_beg), num, code_point);
2977 if (iter_newBeg == iter_newEnd)
2979 erase(safe_iter_dif(iter_beg, begin()), safe_iter_dif(iter_end, iter_beg));
2983 size_type str_len = safe_iter_dif(iter_newEnd, iter_newBeg);
2984 size_type idx = safe_iter_dif(iter_beg, begin());
2985 size_type len = safe_iter_dif(iter_end, iter_beg);
2987 if ((len + idx) > d_cplength)
2988 len = d_cplength - idx;
2990 size_type newsz = d_cplength + str_len - len;
2994 if ((idx + len) < d_cplength)
2995 memmove(&ptr()[idx + str_len], &ptr()[len + idx], (d_cplength - idx - len) *
sizeof(utf32));
2997 memcpy(&ptr()[idx], iter_newBeg.d_ptr, str_len *
sizeof(utf32));
3026 return replace(idx, len, cstr, strlen(cstr));
3053 return replace(iter_beg, iter_end, cstr, strlen(cstr));
3079 String&
replace(size_type idx, size_type len,
const char* chars, size_type chars_len)
3081 if (d_cplength < idx)
3082 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
3084 if (chars_len == npos)
3085 CEGUI_THROW(std::length_error(
"Length for the char array can not be 'npos'"));
3087 if (((len + idx) > d_cplength) || (len == npos))
3088 len = d_cplength - idx;
3090 size_type newsz = d_cplength + chars_len - len;
3094 if ((idx + len) < d_cplength)
3095 memmove(&ptr()[idx + chars_len], &ptr()[len + idx], (d_cplength - idx - len) *
sizeof(utf32));
3097 utf32* pt = &ptr()[idx + chars_len - 1];
3100 *pt-- =
static_cast<utf32
>(
static_cast<unsigned char>(chars[chars_len]));
3133 return replace(safe_iter_dif(iter_beg, begin()), safe_iter_dif(iter_end, iter_beg), chars, chars_len);
3154 size_type
find(utf32 code_point, size_type idx = 0)
const
3156 if (idx < d_cplength)
3158 const utf32* pt = &ptr()[idx];
3160 while (idx < d_cplength)
3162 if (*pt++ == code_point)
3187 size_type
rfind(utf32 code_point, size_type idx = npos)
const
3189 if (idx >= d_cplength)
3190 idx = d_cplength - 1;
3194 const utf32* pt = &ptr()[idx];
3198 if (*pt-- == code_point)
3201 }
while (idx-- != 0);
3227 if ((str.d_cplength == 0) && (idx < d_cplength))
3230 if (idx < d_cplength)
3233 while (d_cplength - idx >= str.d_cplength)
3235 if (0 == compare(idx, str.d_cplength, str))
3262 if (str.d_cplength == 0)
3263 return (idx < d_cplength) ? idx : d_cplength;
3265 if (str.d_cplength <= d_cplength)
3267 if (idx > (d_cplength - str.d_cplength))
3268 idx = d_cplength - str.d_cplength;
3272 if (0 == compare(idx, str.d_cplength, str))
3275 }
while (idx-- != 0);
3300 size_type
find(
const std::string& std_str, size_type idx = 0)
const
3302 std::string::size_type sze = std_str.size();
3304 if ((sze == 0) && (idx < d_cplength))
3307 if (idx < d_cplength)
3310 while (d_cplength - idx >= sze)
3312 if (0 == compare(idx, (size_type)sze, std_str))
3341 size_type
rfind(
const std::string& std_str, size_type idx = npos)
const
3343 std::string::size_type sze = std_str.size();
3346 return (idx < d_cplength) ? idx : d_cplength;
3348 if (sze <= d_cplength)
3350 if (idx > (d_cplength - sze))
3351 idx = d_cplength - sze;
3355 if (0 == compare(idx, (size_type)sze, std_str))
3358 }
while (idx-- != 0);
3387 size_type
find(
const utf8* utf8_str, size_type idx = 0)
const
3389 return find(utf8_str, idx, utf_length(utf8_str));
3414 size_type
rfind(
const utf8* utf8_str, size_type idx = npos)
const
3416 return rfind(utf8_str, idx, utf_length(utf8_str));
3444 size_type
find(
const utf8* utf8_str, size_type idx, size_type str_len)
const
3446 if (str_len == npos)
3447 CEGUI_THROW(std::length_error(
"Length for utf8 encoded string can not be 'npos'"));
3449 size_type sze = encoded_size(utf8_str, str_len);
3451 if ((sze == 0) && (idx < d_cplength))
3454 if (idx < d_cplength)
3457 while (d_cplength - idx >= sze)
3459 if (0 == compare(idx, sze, utf8_str, sze))
3495 size_type
rfind(
const utf8* utf8_str, size_type idx, size_type str_len)
const
3497 if (str_len == npos)
3498 CEGUI_THROW(std::length_error(
"Length for utf8 encoded string can not be 'npos'"));
3500 size_type sze = encoded_size(utf8_str, str_len);
3503 return (idx < d_cplength) ? idx : d_cplength;
3505 if (sze <= d_cplength)
3507 if (idx > (d_cplength - sze))
3508 idx = d_cplength - sze;
3512 if (0 == compare(idx, sze, utf8_str, sze))
3515 }
while (idx-- != 0);
3539 size_type
find(
const char* cstr, size_type idx = 0)
const
3541 return find(cstr, idx, strlen(cstr));
3561 size_type
rfind(
const char* cstr, size_type idx = npos)
const
3563 return rfind(cstr, idx, strlen(cstr));
3586 size_type
find(
const char* chars, size_type idx, size_type chars_len)
const
3588 if (chars_len == npos)
3589 CEGUI_THROW(std::length_error(
"Length for char array can not be 'npos'"));
3591 if ((chars_len == 0) && (idx < d_cplength))
3594 if (idx < d_cplength)
3597 while (d_cplength - idx >= chars_len)
3599 if (0 == compare(idx, chars_len, chars, chars_len))
3630 size_type
rfind(
const char* chars, size_type idx, size_type chars_len)
const
3632 if (chars_len == npos)
3633 CEGUI_THROW(std::length_error(
"Length for char array can not be 'npos'"));
3636 return (idx < d_cplength) ? idx : d_cplength;
3638 if (chars_len <= d_cplength)
3640 if (idx > (d_cplength - chars_len))
3641 idx = d_cplength - chars_len;
3645 if (0 == compare(idx, chars_len, chars, chars_len))
3648 }
while (idx-- != 0);
3675 if (idx < d_cplength)
3677 const utf32* pt = &ptr()[idx];
3681 if (npos != str.
find(*pt++))
3684 }
while (++idx != d_cplength);
3707 if (idx < d_cplength)
3709 const utf32* pt = &ptr()[idx];
3713 if (npos == str.
find(*pt++))
3716 }
while (++idx != d_cplength);
3744 if (idx < d_cplength)
3746 const utf32* pt = &ptr()[idx];
3750 if (npos != find_codepoint(std_str, *pt++))
3753 }
while (++idx != d_cplength);
3780 if (idx < d_cplength)
3782 const utf32* pt = &ptr()[idx];
3786 if (npos == find_codepoint(std_str, *pt++))
3789 }
while (++idx != d_cplength);
3821 return find_first_of(utf8_str, idx, utf_length(utf8_str));
3848 return find_first_not_of(utf8_str, idx, utf_length(utf8_str));
3876 size_type
find_first_of(
const utf8* utf8_str, size_type idx, size_type str_len)
const
3878 if (str_len == npos)
3879 CEGUI_THROW(std::length_error(
"Length for utf8 encoded string can not be 'npos'"));
3881 if (idx < d_cplength)
3883 size_type encsze = encoded_size(utf8_str, str_len);
3885 const utf32* pt = &ptr()[idx];
3889 if (npos != find_codepoint(utf8_str, encsze, *pt++))
3892 }
while (++idx != d_cplength);
3926 if (str_len == npos)
3927 CEGUI_THROW(std::length_error(
"Length for utf8 encoded string can not be 'npos'"));
3929 if (idx < d_cplength)
3931 size_type encsze = encoded_size(utf8_str, str_len);
3933 const utf32* pt = &ptr()[idx];
3937 if (npos == find_codepoint(utf8_str, encsze, *pt++))
3940 }
while (++idx != d_cplength);
3964 return find(code_point, idx);
3985 if (idx < d_cplength)
3989 if ((*
this)[idx] != code_point)
3992 }
while(idx++ < d_cplength);
4018 return find_first_of(cstr, idx, strlen(cstr));
4040 return find_first_not_of(cstr, idx, strlen(cstr));
4063 size_type
find_first_of(
const char* chars, size_type idx, size_type chars_len)
const
4065 if (chars_len == npos)
4066 CEGUI_THROW(std::length_error(
"Length for char array can not be 'npos'"));
4068 if (idx < d_cplength)
4070 const utf32* pt = &ptr()[idx];
4074 if (npos != find_codepoint(chars, chars_len, *pt++))
4077 }
while (++idx != d_cplength);
4106 if (chars_len == npos)
4107 CEGUI_THROW(std::length_error(
"Length for char array can not be 'npos'"));
4109 if (idx < d_cplength)
4111 const utf32* pt = &ptr()[idx];
4115 if (npos == find_codepoint(chars, chars_len, *pt++))
4118 }
while (++idx != d_cplength);
4147 if (idx >= d_cplength)
4148 idx = d_cplength - 1;
4150 const utf32* pt = &ptr()[idx];
4154 if (npos != str.
find(*pt--))
4157 }
while (idx-- != 0);
4182 if (idx >= d_cplength)
4183 idx = d_cplength - 1;
4185 const utf32* pt = &ptr()[idx];
4189 if (npos == str.
find(*pt--))
4192 }
while (idx-- != 0);
4218 size_type
find_last_of(
const std::string& std_str, size_type idx = npos)
const
4222 if (idx >= d_cplength)
4223 idx = d_cplength - 1;
4225 const utf32* pt = &ptr()[idx];
4229 if (npos != find_codepoint(std_str, *pt--))
4232 }
while (idx-- != 0);
4261 if (idx >= d_cplength)
4262 idx = d_cplength - 1;
4264 const utf32* pt = &ptr()[idx];
4268 if (npos == find_codepoint(std_str, *pt--))
4271 }
while (idx-- != 0);
4303 return find_last_of(utf8_str, idx, utf_length(utf8_str));
4330 return find_last_not_of(utf8_str, idx, utf_length(utf8_str));
4358 size_type
find_last_of(
const utf8* utf8_str, size_type idx, size_type str_len)
const
4360 if (str_len == npos)
4361 CEGUI_THROW(std::length_error(
"Length for utf8 encoded string can not be 'npos'"));
4365 if (idx >= d_cplength)
4366 idx = d_cplength - 1;
4368 size_type encsze = encoded_size(utf8_str, str_len);
4370 const utf32* pt = &ptr()[idx];
4374 if (npos != find_codepoint(utf8_str, encsze, *pt--))
4377 }
while (idx-- != 0);
4411 if (str_len == npos)
4412 CEGUI_THROW(std::length_error(
"Length for utf8 encoded string can not be 'npos'"));
4416 if (idx >= d_cplength)
4417 idx = d_cplength - 1;
4419 size_type encsze = encoded_size(utf8_str, str_len);
4421 const utf32* pt = &ptr()[idx];
4425 if (npos == find_codepoint(utf8_str, encsze, *pt--))
4428 }
while (idx-- != 0);
4452 return rfind(code_point, idx);
4473 if (idx >= d_cplength)
4474 idx = d_cplength - 1;
4478 if ((*
this)[idx] != code_point)
4481 }
while(idx-- != 0);
4507 return find_last_of(cstr, idx, strlen(cstr));
4529 return find_last_not_of(cstr, idx, strlen(cstr));
4552 size_type
find_last_of(
const char* chars, size_type idx, size_type chars_len)
const
4554 if (chars_len == npos)
4555 CEGUI_THROW(std::length_error(
"Length for char array can not be 'npos'"));
4559 if (idx >= d_cplength)
4560 idx = d_cplength - 1;
4562 const utf32* pt = &ptr()[idx];
4566 if (npos != find_codepoint(chars, chars_len, *pt--))
4569 }
while (idx-- != 0);
4598 if (chars_len == npos)
4599 CEGUI_THROW(std::length_error(
"Length for char array can not be 'npos'"));
4603 if (idx >= d_cplength)
4604 idx = d_cplength - 1;
4606 const utf32* pt = &ptr()[idx];
4610 if (npos == find_codepoint(chars, chars_len, *pt--))
4613 }
while (idx-- != 0);
4641 if (d_cplength < idx)
4642 CEGUI_THROW(std::out_of_range(
"Index is out of range for this CEGUI::String"));
4644 return String(*
this, idx, len);
4683 return iterator(&ptr()[d_cplength]);
4707 return reverse_iterator(end());
4719 return const_reverse_iterator(end());
4731 return reverse_iterator(begin());
4741 const_reverse_iterator
rend(
void)
const
4743 return const_reverse_iterator(begin());
4755 bool grow(size_type new_size);
4761 void setlen(size_type len)
4764 ptr()[len] = (utf32)(0);
4770 d_reserve = CEGUI_STR_QUICKBUFF_SIZE;
4772 d_encodedbufflen = 0;
4773 d_encodeddatlen = 0;
4779 bool inside(utf32* inptr)
4781 if (inptr < ptr() || ptr() + d_cplength <= inptr)
4788 size_type safe_iter_dif(
const const_iterator& iter1,
const const_iterator& iter2)
const
4790 return (iter1.d_ptr == 0) ? 0 : (iter1 - iter2);
4798 size_type encode(
const utf32* src, utf8* dest, size_type dest_len, size_type src_len = 0)
const
4803 src_len = utf_length(src);
4806 size_type destCapacity = dest_len;
4809 for (uint idx = 0; idx < src_len; ++idx)
4811 utf32 cp = src[idx];
4814 if (destCapacity < encoded_size(cp))
4824 else if (cp < 0x0800)
4826 *dest++ = (utf8)((cp >> 6) | 0xC0);
4827 *dest++ = (utf8)((cp & 0x3F) | 0x80);
4830 else if (cp < 0x10000)
4832 *dest++ = (utf8)((cp >> 12) | 0xE0);
4833 *dest++ = (utf8)(((cp >> 6) & 0x3F) | 0x80);
4834 *dest++ = (utf8)((cp & 0x3F) | 0x80);
4839 *dest++ = (utf8)((cp >> 18) | 0xF0);
4840 *dest++ = (utf8)(((cp >> 12) & 0x3F) | 0x80);
4841 *dest++ = (utf8)(((cp >> 6) & 0x3F) | 0x80);
4842 *dest++ = (utf8)((cp & 0x3F) | 0x80);
4848 return dest_len - destCapacity;
4851 size_type encode(
const utf8* src, utf32* dest, size_type dest_len, size_type src_len = 0)
const
4856 src_len = utf_length(src);
4859 size_type destCapacity = dest_len;
4862 for (uint idx = 0; ((idx < src_len) && (destCapacity > 0));)
4865 utf8 cu = src[idx++];
4873 cp = ((cu & 0x1F) << 6);
4874 cp |= (src[idx++] & 0x3F);
4878 cp = ((cu & 0x0F) << 12);
4879 cp |= ((src[idx++] & 0x3F) << 6);
4880 cp |= (src[idx++] & 0x3F);
4884 cp = ((cu & 0x07) << 18);
4885 cp |= ((src[idx++] & 0x3F) << 12);
4886 cp |= ((src[idx++] & 0x3F) << 6);
4887 cp |= (src[idx++] & 0x3F);
4894 return dest_len - destCapacity;
4898 size_type encoded_size(utf32 code_point)
const
4900 if (code_point < 0x80)
4902 else if (code_point < 0x0800)
4904 else if (code_point < 0x10000)
4911 size_type encoded_size(
const utf32* buf)
const
4913 return encoded_size(buf, utf_length(buf));
4917 size_type encoded_size(
const utf32* buf, size_type len)
const
4919 size_type count = 0;
4923 count += encoded_size(*buf++);
4930 size_type encoded_size(
const utf8* buf)
const
4932 return encoded_size(buf, utf_length(buf));
4936 size_type encoded_size(
const utf8* buf, size_type len)
const
4939 size_type count = 0;
4950 else if (tcp < 0xE0)
4955 else if (tcp < 0xF0)
4976 size_type utf_length(
const utf8* utf8_str)
const
4986 size_type utf_length(
const utf32* utf32_str)
const
4989 while (*utf32_str++)
4996 utf8* build_utf8_buff(
void)
const;
4999 int utf32_comp_utf32(
const utf32* buf1,
const utf32* buf2, size_type cp_count)
const
5004 while ((--cp_count) && (*buf1 == *buf2))
5007 return *buf1 - *buf2;
5011 int utf32_comp_char(
const utf32* buf1,
const char* buf2, size_type cp_count)
const
5016 while ((--cp_count) && (*buf1 == static_cast<utf32>(static_cast<unsigned char>(*buf2))))
5019 return *buf1 -
static_cast<utf32
>(
static_cast<unsigned char>(*buf2));
5023 int utf32_comp_utf8(
const utf32* buf1,
const utf8* buf2, size_type cp_count)
const
5041 cp = ((cu & 0x1F) << 6);
5042 cp |= (*buf2++ & 0x3F);
5046 cp = ((cu & 0x0F) << 12);
5047 cp |= ((*buf2++ & 0x3F) << 6);
5048 cp |= (*buf2++ & 0x3F);
5052 cp = ((cu & 0x07) << 18);
5053 cp |= ((*buf2++ & 0x3F) << 12);
5054 cp |= ((*buf2++ & 0x3F) << 6);
5055 cp |= (*buf2++ & 0x3F);
5058 }
while ((*buf1++ == cp) && (--cp_count));
5060 return (*--buf1) - cp;
5064 size_type find_codepoint(
const std::string& str, utf32 code_point)
const
5066 size_type idx = 0, sze = (size_type)str.size();
5070 if (code_point == static_cast<utf32>(static_cast<unsigned char>(str[idx])))
5080 size_type find_codepoint(
const utf8* str, size_type len, utf32 code_point)
const
5087 while (idx != len) {
5096 cp = ((cu & 0x1F) << 6);
5097 cp |= (*str++ & 0x3F);
5101 cp = ((cu & 0x0F) << 12);
5102 cp |= ((*str++ & 0x3F) << 6);
5103 cp |= (*str++ & 0x3F);
5107 cp = ((cu & 0x07) << 18);
5108 cp |= ((*str++ & 0x3F) << 12);
5109 cp |= ((*str++ & 0x3F) << 6);
5110 cp |= (*str++ & 0x3F);
5113 if (code_point == cp)
5124 size_type find_codepoint(
const char* chars, size_type chars_len, utf32 code_point)
const
5126 for (size_type idx = 0; idx != chars_len; ++idx)
5128 if (code_point == static_cast<utf32>(static_cast<unsigned char>(chars[idx])))
5145 bool CEGUIEXPORT
operator==(
const String& str1,
const String& str2);
5151 bool CEGUIEXPORT
operator==(
const String& str,
const std::string& std_str);
5157 bool CEGUIEXPORT
operator==(
const std::string& std_str,
const String& str);
5163 bool CEGUIEXPORT
operator==(
const String& str,
const utf8* utf8_str);
5169 bool CEGUIEXPORT
operator==(
const utf8* utf8_str,
const String& str);
5175 bool CEGUIEXPORT
operator!=(
const String& str1,
const String& str2);
5181 bool CEGUIEXPORT
operator!=(
const String& str,
const std::string& std_str);
5187 bool CEGUIEXPORT
operator!=(
const std::string& std_str,
const String& str);
5193 bool CEGUIEXPORT
operator!=(
const String& str,
const utf8* utf8_str);
5199 bool CEGUIEXPORT
operator!=(
const utf8* utf8_str,
const String& str);
5205 bool CEGUIEXPORT
operator<(
const String& str1,
const String& str2);
5211 bool CEGUIEXPORT
operator<(
const String& str,
const std::string& std_str);
5217 bool CEGUIEXPORT
operator<(
const std::string& std_str,
const String& str);
5223 bool CEGUIEXPORT
operator<(
const String& str,
const utf8* utf8_str);
5229 bool CEGUIEXPORT
operator<(
const utf8* utf8_str,
const String& str);
5235 bool CEGUIEXPORT
operator>(
const String& str1,
const String& str2);
5241 bool CEGUIEXPORT
operator>(
const String& str,
const std::string& std_str);
5247 bool CEGUIEXPORT
operator>(
const std::string& std_str,
const String& str);
5253 bool CEGUIEXPORT
operator>(
const String& str,
const utf8* utf8_str);
5259 bool CEGUIEXPORT
operator>(
const utf8* utf8_str,
const String& str);
5265 bool CEGUIEXPORT
operator<=(
const String& str1,
const String& str2);
5271 bool CEGUIEXPORT
operator<=(
const String& str,
const std::string& std_str);
5277 bool CEGUIEXPORT
operator<=(
const std::string& std_str,
const String& str);
5283 bool CEGUIEXPORT
operator<=(
const String& str,
const utf8* utf8_str);
5289 bool CEGUIEXPORT
operator<=(
const utf8* utf8_str,
const String& str);
5295 bool CEGUIEXPORT
operator>=(
const String& str1,
const String& str2);
5301 bool CEGUIEXPORT
operator>=(
const String& str,
const std::string& std_str);
5307 bool CEGUIEXPORT
operator>=(
const std::string& std_str,
const String& str);
5313 bool CEGUIEXPORT
operator>=(
const String& str,
const utf8* utf8_str);
5319 bool CEGUIEXPORT
operator>=(
const utf8* utf8_str,
const String& str);
5325 bool CEGUIEXPORT
operator==(
const String& str,
const char* c_str);
5331 bool CEGUIEXPORT
operator==(
const char* c_str,
const String& str);
5337 bool CEGUIEXPORT
operator!=(
const String& str,
const char* c_str);
5343 bool CEGUIEXPORT
operator!=(
const char* c_str,
const String& str);
5349 bool CEGUIEXPORT
operator<(
const String& str,
const char* c_str);
5355 bool CEGUIEXPORT
operator<(
const char* c_str,
const String& str);
5361 bool CEGUIEXPORT
operator>(
const String& str,
const char* c_str);
5367 bool CEGUIEXPORT
operator>(
const char* c_str,
const String& str);
5373 bool CEGUIEXPORT
operator<=(
const String& str,
const char* c_str);
5379 bool CEGUIEXPORT
operator<=(
const char* c_str,
const String& str);
5385 bool CEGUIEXPORT
operator>=(
const String& str,
const char* c_str);
5391 bool CEGUIEXPORT
operator>=(
const char* c_str,
const String& str);
5411 String CEGUIEXPORT
operator+(
const String& str1,
const String& str2);
5428 String CEGUIEXPORT
operator+(
const String& str,
const std::string& std_str);
5445 String CEGUIEXPORT
operator+(
const std::string& std_str,
const String& str);
5462 String CEGUIEXPORT
operator+(
const String& str,
const utf8* utf8_str);
5479 String CEGUIEXPORT
operator+(
const utf8* utf8_str,
const String& str);
5496 String CEGUIEXPORT
operator+(
const String& str, utf32 code_point);
5513 String CEGUIEXPORT
operator+(utf32 code_point,
const String& str);
5530 String CEGUIEXPORT
operator+(
const String& str,
const char* c_str);
5547 String CEGUIEXPORT
operator+(
const char* c_str,
const String& str);
5553 CEGUIEXPORT std::ostream& operator<<(std::ostream& s,
const String& str);
5572 void CEGUIEXPORT
swap(String& str1, String& str2);
5581 bool operator() (
const String& a,
const String& b)
const
5583 const size_t la = a.
length();
5584 const size_t lb = b.
length();
5586 return (memcmp(a.
ptr(), b.
ptr(), la *
sizeof(utf32)) < 0);
5597 #if CEGUI_STRING_CLASS == CEGUI_STRING_CLASS_STD
5599 typedef std::string
String;
5601 #else // CEGUI_STRING_CLASS_STD_AO
5603 typedef std::basic_string<char, std::char_traits<char>, STLAllocatorWrapper<char, AllocatorConfig<STLAllocator>::Allocator> > String;
5614 bool operator() (
const String& a,
const String& b)
const
5616 const size_t la = a.
length();
5617 const size_t lb = b.
length();
5625 #if defined(_MSC_VER)
5626 # pragma warning(disable : 4251)
5634 #endif // end of guard _CEGUIString_h_
String & replace(iterator iter_beg, iterator iter_end, const utf8 *utf8_str, size_type str_len)
Replace the code points in the range [beg, end) with the specified null-terminated utf8 encoded data...
Definition: String.h:2866
String & replace(iterator iter_beg, iterator iter_end, const char *chars, size_type chars_len)
Replace the code points in the range [beg, end) with chars from the given char array.
Definition: String.h:3131
size_type find_first_of(const utf8 *utf8_str, size_type idx, size_type str_len) const
Find the first occurrence of one of a set of code points.
Definition: String.h:3876
const_iterator begin(void) const
Return a constant forwards iterator that describes the beginning of the String.
Definition: String.h:4669
std::reverse_iterator< const_iterator > const_reverse_iterator
Constant reverse iterator class for String objects.
Definition: String.h:321
size_type find_last_of(utf32 code_point, size_type idx=npos) const
Search for last occurrence of a given code point.
Definition: String.h:4450
String(const std::string &std_str)
Constructs a new string and initialises it using the std::string std_str.
Definition: String.h:414
bool CEGUIEXPORT operator>(const String &str1, const String &str2)
Return true if String str1 is lexicographically greater than String str2.
String & erase(iterator pos)
Erase the code point described by the given iterator.
Definition: String.h:2428
const utf32 * ptr(void) const
Returns a pointer to the buffer in use. (const version)
Definition: String.h:1179
size_type find(const char *cstr, size_type idx=0) const
Search forwards for a sub-string.
Definition: String.h:3539
Functor that can be used as comparator in a std::map with String keys. It's faster than using the def...
Definition: String.h:5579
void CEGUIEXPORT swap(String &str1, String &str2)
Swap the contents for two String objects.
reference operator[](size_type idx)
Returns the code point at the given index.
Definition: String.h:1062
size_type find_last_of(const char *cstr, size_type idx=npos) const
Find the last occurrence of one of a set of chars.
Definition: String.h:4505
String & append(const utf8 *utf8_str)
Appends to the String the null-terminated utf8 encoded data in the buffer utf8_str.
Definition: String.h:1750
String & operator+=(utf32 code_point)
Appends a single code point to the string.
Definition: String.h:1805
size_type rfind(utf32 code_point, size_type idx=npos) const
Search backwards for a given code point.
Definition: String.h:3187
String & insert(size_type idx, const utf8 *utf8_str)
Inserts the given null-terminated utf8 encoded data at the specified position.
Definition: String.h:2114
String & operator+=(const std::string &std_str)
Appends the std::string std_str.
Definition: String.h:1660
size_type find(const utf8 *utf8_str, size_type idx, size_type str_len) const
Search forwards for a sub-string.
Definition: String.h:3444
regular iterator for String.
Definition: String.h:98
String & replace(iterator iter_beg, iterator iter_end, const utf8 *utf8_str)
Replace the code points in the range [beg, end) with the specified null-terminated utf8 encoded data...
Definition: String.h:2778
Definition: MemoryAllocatedObject.h:109
size_type find(const String &str, size_type idx=0) const
Search forwards for a sub-string.
Definition: String.h:3225
size_type find_first_of(const std::string &std_str, size_type idx=0) const
Find the first occurrence of one of a set of code points.
Definition: String.h:3742
String & replace(iterator iter_beg, iterator iter_end, const_iterator iter_newBeg, const_iterator iter_newEnd)
Replace the code points in the range [beg, end) with code points from the range [newBeg, newEnd).
Definition: String.h:2975
String & insert(size_type idx, const char *cstr)
Inserts the given c-string at the specified position.
Definition: String.h:2289
String & replace(size_type idx, size_type len, const utf8 *utf8_str)
Replace code points in the String with the specified null-terminated utf8 encoded data...
Definition: String.h:2746
String & erase(void)
Removes all data from the String.
Definition: String.h:2361
void swap(String &str)
Swaps the value of this String with the given String str.
Definition: String.h:1564
bool CEGUIEXPORT operator==(const String &str1, const String &str2)
Return true if String str1 is equal to String str2.
std::ptrdiff_t difference_type
Signed type used for differences.
Definition: String.h:71
String(const char *chars, size_type chars_len)
Constructs a new String object and initialise it using characters from the provided char array...
Definition: String.h:592
String(const_iterator iter_beg, const_iterator iter_end)
Construct a new string object and initialise it with code-points from the range [beg, end).
Definition: String.h:549
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
size_type rfind(const std::string &std_str, size_type idx=npos) const
Search backwards for a sub-string.
Definition: String.h:3341
size_t size_type
Unsigned type used for size values and indices.
Definition: String.h:70
bool empty(void) const
Returns true if the String is empty.
Definition: String.h:633
bool CEGUIEXPORT operator>=(const String &str1, const String &str2)
Return true if String str1 is lexicographically greater than or equal to String str2.
String(const utf8 *utf8_str, size_type chars_len)
Constructs a new String object and initialise it using the provided utf8 encoded string buffer...
Definition: String.h:502
size_type find_last_of(const char *chars, size_type idx, size_type chars_len) const
Find the last occurrence of one of a set of chars.
Definition: String.h:4552
String & append(const_iterator iter_beg, const_iterator iter_end)
Appends the code points in the reange [beg, end)
Definition: String.h:1875
String & operator=(const char *cstr)
Assign to this String the given C-string.
Definition: String.h:1500
String & append(const std::string &std_str, size_type str_idx=0, size_type str_num=npos)
Appends a sub-string of the std::string std_str.
Definition: String.h:1688
size_type find_first_not_of(utf32 code_point, size_type idx=0) const
Search forwards for the first code point that does not match a given code point.
Definition: String.h:3983
String & assign(const char *chars, size_type chars_len)
Assign to this String a number of chars from a char array.
Definition: String.h:1539
value_type operator[](size_type idx) const
Returns the code point at the given index.
Definition: String.h:1081
String & operator=(const utf8 *utf8_str)
Assign to this String the string value represented by the given null-terminated utf8 encoded data...
Definition: String.h:1380
size_type find_last_of(const utf8 *utf8_str, size_type idx=npos) const
Find the last occurrence of one of a set of code points.
Definition: String.h:4301
size_type length(void) const
Returns the size of the String in code points.
Definition: String.h:621
String & assign(const utf8 *utf8_str, size_type str_num)
Assign to this String the string value represented by the given utf8 encoded data.
Definition: String.h:1429
String & replace(size_type idx, size_type len, const utf8 *utf8_str, size_type str_len)
Replace code points in the String with the specified utf8 encoded data.
Definition: String.h:2811
String substr(size_type idx=0, size_type len=npos) const
Returns a substring of this String.
Definition: String.h:4639
const iterator for String.
Definition: String.h:203
String & insert(size_type idx, const std::string &std_str, size_type str_idx, size_type str_num)
Inserts a sub-string of the given std::string object at the specified position.
Definition: String.h:2066
size_type utf8_stream_len(size_type num=npos, size_type idx=0) const
Return the number of utf8 code units required to hold an area of the String when encoded as utf8 data...
Definition: String.h:1236
String & replace(iterator iter_beg, iterator iter_end, const char *cstr)
Replace the code points in the range [beg, end) with the specified c-string.
Definition: String.h:3051
iterator end(void)
Return a forwards iterator that describes the end of the String.
Definition: String.h:4681
String & operator+=(const char *cstr)
Appends to the String the given c-string.
Definition: String.h:1893
void push_back(utf32 code_point)
Appends a single code point to the string.
Definition: String.h:1855
int compare(const std::string &std_str) const
Compares this String with the std::string 'std_str'.
Definition: String.h:781
const utf8 * data(void) const
Returns contents of the String as utf8 encoded data.
Definition: String.h:1161
std::reverse_iterator< iterator > reverse_iterator
Reverse iterator class for String objects.
Definition: String.h:331
size_type capacity(void) const
Return the number of code points that the String could hold before a re-allocation would be required...
Definition: String.h:665
size_type rfind(const String &str, size_type idx=npos) const
Search backwards for a sub-string.
Definition: String.h:3260
void insert(iterator pos, size_type num, utf32 code_point)
Inserts a code point multiple times into the String.
Definition: String.h:2223
size_type find_first_of(const char *chars, size_type idx, size_type chars_len) const
Find the first occurrence of one of a set of chars.
Definition: String.h:4063
const_reverse_iterator rbegin(void) const
Return a constant reverse iterator that describes the beginning of the String.
Definition: String.h:4717
String & operator=(const String &str)
Assign the value of String str to this String.
Definition: String.h:1261
String(const std::string &std_str, size_type str_idx, size_type str_num=npos)
Constructs a new string initialised with characters from the given std::string object.
Definition: String.h:442
utf32 * ptr(void)
Returns a pointer to the buffer in use.
Definition: String.h:1170
int compare(size_type idx, size_type len, const utf8 *utf8_str) const
Compares code points from this String with the null-terminated utf8 encoded 'utf8_str'.
Definition: String.h:896
utf32 * pointer
Type used for utf32 code point pointers.
Definition: String.h:74
size_type size(void) const
Returns the size of the String in code points.
Definition: String.h:609
size_type find_first_of(const char *cstr, size_type idx=0) const
Find the first occurrence of one of a set of chars.
Definition: String.h:4016
size_type find(utf32 code_point, size_type idx=0) const
Search forwards for a given code point.
Definition: String.h:3154
const_reference at(size_type idx) const
Returns the code point at the given index.
Definition: String.h:1118
const_iterator end(void) const
Return a constant forwards iterator that describes the end of the String.
Definition: String.h:4693
size_type find_first_not_of(const utf8 *utf8_str, size_type idx=0) const
Find the first code point that is not one of a set of code points.
Definition: String.h:3846
String & replace(size_type idx, size_type len, const String &str)
Replace code points in the String with the specified String object.
Definition: String.h:2521
String & operator=(utf32 code_point)
Assigns the specified utf32 code point to this String. Result is always a String 1 code point in leng...
Definition: String.h:1452
String & insert(size_type idx, size_type num, utf32 code_point)
Inserts a code point multiple times into the String.
Definition: String.h:2182
size_type find_last_not_of(utf32 code_point, size_type idx=npos) const
Search for the last code point that does not match a given code point.
Definition: String.h:4469
String & assign(const utf8 *utf8_str)
Assign to this String the string value represented by the given null-terminated utf8 encoded data...
Definition: String.h:1403
String & replace(iterator iter_beg, iterator iter_end, size_type num, utf32 code_point)
Replace the code points in the range [beg, end) with occurrences of a given code point.
Definition: String.h:2945
String & replace(size_type idx, size_type len, const String &str, size_type str_idx, size_type str_num)
Replace code points in the String with a specified sub-string of a given String object.
Definition: String.h:2577
String & replace(iterator iter_beg, iterator iter_end, const std::string &std_str)
Replace the code points in the range [beg, end) with the specified std::string object.
Definition: String.h:2655
const char * c_str(void) const
Returns contents of the String as a null terminated string of utf8 encoded data.
Definition: String.h:1143
const utf32 * const_pointer
Type used for constant utf32 code point pointers.
Definition: String.h:75
int compare(size_type idx, size_type len, const std::string &std_str, size_type str_idx=0, size_type str_len=npos) const
Compares code points from this String with code points from the std::string 'std_str'.
Definition: String.h:820
int compare(size_type idx, size_type len, const char *cstr) const
Compares code points from this String with the given c-string.
Definition: String.h:995
void resize(size_type num)
Resizes the String either by inserting default utf32 code points to make it larger, or by truncating to make it smaller.
Definition: String.h:2466
String & assign(size_type num, utf32 code_point)
Assigns the specified code point repeatedly to the String.
Definition: String.h:1472
int compare(size_type idx, size_type len, const char *chars, size_type chars_len) const
Compares code points from this String with chars in the given char array.
Definition: String.h:1028
String & insert(size_type idx, const char *chars, size_type chars_len)
Inserts chars from the given char array at the specified position.
Definition: String.h:2314
utf32 & reference
Type used for utf32 code point references.
Definition: String.h:72
size_type find_first_not_of(const char *chars, size_type idx, size_type chars_len) const
Find the first code point that is not one of a set of chars.
Definition: String.h:4104
String & insert(size_type idx, const String &str)
Inserts the given String object at the specified position.
Definition: String.h:1971
size_type rfind(const utf8 *utf8_str, size_type idx=npos) const
Search backwards for a sub-string.
Definition: String.h:3414
bool CEGUIEXPORT operator<=(const String &str1, const String &str2)
Return true if String str1 is lexicographically less than or equal to String str2.
size_type copy(utf8 *buf, size_type len=npos, size_type idx=0) const
Copies an area of the String into the provided buffer as encoded utf8 data.
Definition: String.h:1206
utf8 encoded_char
encoded char signifies that it's a char (8bit) with encoding (in this case utf8)
Definition: String.h:50
void insert(iterator iter_pos, const_iterator iter_beg, const_iterator iter_end)
Inserts code points specified by the range [beg, end).
Definition: String.h:2267
String & replace(size_type idx, size_type len, const char *cstr)
Replace code points in the String with the specified c-string.
Definition: String.h:3024
size_type find_first_not_of(const std::string &std_str, size_type idx=0) const
Find the first code point that is not one of a set of code points.
Definition: String.h:3778
String & erase(iterator iter_beg, iterator iter_end)
Erase a range of code points described by the iterators [beg, end).
Definition: String.h:2446
const utf32 & const_reference
Type used for constant utf32 code point references.
Definition: String.h:73
String(const String &str, size_type str_idx, size_type str_num=npos)
Constructs a new string initialised with code points from another String object.
Definition: String.h:389
String & assign(const std::string &std_str, size_type str_idx=0, size_type str_num=npos)
Assign a sub-string of std::string std_str to this String.
Definition: String.h:1343
String & assign(const char *cstr)
Assign to this String the given C-string.
Definition: String.h:1518
String(void)
Constructs an empty string.
Definition: String.h:342
String CEGUIEXPORT operator+(const String &str1, const String &str2)
Return String object that is the concatenation of the given inputs.
bool CEGUIEXPORT operator<(const String &str1, const String &str2)
Return true if String str1 is lexicographically less than String str2.
size_type find_last_not_of(const char *cstr, size_type idx=npos) const
Find the last code point that is not one of a set of chars.
Definition: String.h:4527
String & insert(size_type idx, const std::string &std_str)
Inserts the given std::string object at the specified position.
Definition: String.h:2035
size_type find_first_of(const String &str, size_type idx=0) const
Find the first occurrence of one of a set of code points.
Definition: String.h:3673
String & replace(size_type idx, size_type len, const std::string &std_str, size_type str_idx, size_type str_num)
Replace code points in the String with a specified sub-string of a given std::string object...
Definition: String.h:2689
size_type find_first_of(utf32 code_point, size_type idx=0) const
Search forwards for a given code point.
Definition: String.h:3962
size_type find_last_of(const std::string &std_str, size_type idx=npos) const
Find the last occurrence of one of a set of code points.
Definition: String.h:4218
String & append(const char *cstr)
Appends to the String the given c-string.
Definition: String.h:1911
size_type find_last_of(const utf8 *utf8_str, size_type idx, size_type str_len) const
Find the last occurrence of one of a set of code points.
Definition: String.h:4358
void reserve(size_type num=0)
Specifies the amount of reserve capacity to allocate.
Definition: String.h:685
size_type find_last_of(const String &str, size_type idx=npos) const
Find the last occurrence of one of a set of code points.
Definition: String.h:4143
size_type rfind(const char *cstr, size_type idx=npos) const
Search backwards for a sub-string.
Definition: String.h:3561
String(const char *cstr)
Constructs a new String object and initialise it using the provided c-string.
Definition: String.h:571
iterator insert(iterator pos, utf32 code_point)
Inserts a single code point into the String.
Definition: String.h:2243
String & append(size_type num, utf32 code_point)
Appends a single code point multiple times to the string.
Definition: String.h:1825
size_type find_last_not_of(const std::string &std_str, size_type idx=npos) const
Find the last code point that is not one of a set of code points.
Definition: String.h:4257
size_type rfind(const utf8 *utf8_str, size_type idx, size_type str_len) const
Search backwards for a sub-string.
Definition: String.h:3495
reverse_iterator rbegin(void)
Return a reverse iterator that describes the beginning of the String.
Definition: String.h:4705
String & operator+=(const String &str)
Appends the String str.
Definition: String.h:1605
size_type find_first_not_of(const char *cstr, size_type idx=0) const
Find the first code point that is not one of a set of chars.
Definition: String.h:4038
utf32 value_type
Basic 'code point' type used for String (utf32)
Definition: String.h:69
size_type find_last_not_of(const utf8 *utf8_str, size_type idx=npos) const
Find the last code point that is not one of a set of code points.
Definition: String.h:4328
bool CEGUIEXPORT operator!=(const String &str1, const String &str2)
Return true if String str1 is not equal to String str2.
String & operator=(const std::string &std_str)
Assign the value of std::string std_str to this String.
Definition: String.h:1315
size_type rfind(const char *chars, size_type idx, size_type chars_len) const
Search backwards for a sub-string.
Definition: String.h:3630
size_type find_last_not_of(const utf8 *utf8_str, size_type idx, size_type str_len) const
Find the last code point that is not one of a set of code points.
Definition: String.h:4409
int compare(const String &str) const
Compares this String with the String 'str'.
Definition: String.h:711
String & replace(size_type idx, size_type len, const char *chars, size_type chars_len)
Replace code points in the String with chars from the given char array.
Definition: String.h:3079
size_type find_first_not_of(const String &str, size_type idx=0) const
Find the first code point that is not one of a set of code points.
Definition: String.h:3705
int compare(size_type idx, size_type len, const utf8 *utf8_str, size_type str_cplen) const
Compares code points from this String with the utf8 encoded data in buffer 'utf8_str'.
Definition: String.h:934
iterator begin(void)
Return a forwards iterator that describes the beginning of the String.
Definition: String.h:4657
String & insert(size_type idx, const String &str, size_type str_idx, size_type str_num)
Inserts a sub-string of the given String object at the specified position.
Definition: String.h:1998
int compare(const char *cstr) const
Compares this String with the given c-string.
Definition: String.h:966
const_reverse_iterator rend(void) const
Return a constant reverse iterator that describes the end of the String.
Definition: String.h:4741
size_type find_first_of(const utf8 *utf8_str, size_type idx=0) const
Find the first occurrence of one of a set of code points.
Definition: String.h:3819
String(size_type num, utf32 code_point)
Constructs a new String that is initialised with the specified code point.
Definition: String.h:526
String & replace(size_type idx, size_type len, const std::string &std_str)
Replace code points in the String with the specified std::string object.
Definition: String.h:2625
String & insert(size_type idx, const utf8 *utf8_str, size_type len)
Inserts the given utf8 encoded data at the specified position.
Definition: String.h:2144
size_type find(const char *chars, size_type idx, size_type chars_len) const
Search forwards for a sub-string.
Definition: String.h:3586
static const size_type npos
Value used to represent 'not found' conditions and 'all code points' etc.
Definition: String.h:77
reference at(size_type idx)
Returns the code point at the given index.
Definition: String.h:1098
String(const String &str)
Copy constructor - Creates a new string with the same value as str.
Definition: String.h:366
int compare(const utf8 *utf8_str) const
Compares this String with the null-terminated utf8 encoded 'utf8_str'.
Definition: String.h:861
size_type find_first_not_of(const utf8 *utf8_str, size_type idx, size_type str_len) const
Find the first code point that is not one of a set of code points.
Definition: String.h:3924
size_type find_last_not_of(const String &str, size_type idx=npos) const
Find the last code point that is not one of a set of code points.
Definition: String.h:4178
void resize(size_type num, utf32 code_point)
Resizes the String either by inserting the given utf32 code point to make it larger, or by truncating to make it smaller.
Definition: String.h:2486
String & replace(size_type idx, size_type len, size_type num, utf32 code_point)
Replaces a specified range of code points with occurrences of a given code point. ...
Definition: String.h:2893
String & erase(size_type idx, size_type len)
Erase a range of code points.
Definition: String.h:2399
int compare(size_type idx, size_type len, const String &str, size_type str_idx=0, size_type str_len=npos) const
Compares code points from this String with code points from the String 'str'.
Definition: String.h:745
size_type max_size(void) const
Returns the maximum size of a String.
Definition: String.h:647
String & assign(const String &str, size_type str_idx=0, size_type str_num=npos)
Assign a sub-string of String str to this String.
Definition: String.h:1284
void clear(void)
Removes all data from the String.
Definition: String.h:2348
size_type find_last_not_of(const char *chars, size_type idx, size_type chars_len) const
Find the last code point that is not one of a set of chars.
Definition: String.h:4596
String & append(const char *chars, size_type chars_len)
Appends to the String chars from the given char array.
Definition: String.h:1932
String & replace(iterator iter_beg, iterator iter_end, const String &str)
Replace the code points in the range [beg, end) with the specified String object. ...
Definition: String.h:2547
size_type find(const utf8 *utf8_str, size_type idx=0) const
Search forwards for a sub-string.
Definition: String.h:3387
reverse_iterator rend(void)
Return a reverse iterator that describes the end of the String.
Definition: String.h:4729
String & append(const utf8 *utf8_str, size_type len)
Appends to the String the utf8 encoded data in the buffer utf8_str.
Definition: String.h:1777
String & erase(size_type idx)
Erase a single code point from the string.
Definition: String.h:2379
String & operator+=(const utf8 *utf8_str)
Appends to the String the null-terminated utf8 encoded data in the buffer utf8_str.
Definition: String.h:1727
String(const utf8 *utf8_str)
Constructs a new String object and initialise it using the provided utf8 encoded string buffer...
Definition: String.h:470
String & append(const String &str, size_type str_idx=0, size_type str_num=npos)
Appends a sub-string of the String str.
Definition: String.h:1629
String class used within the GUI system.
Definition: String.h:62
size_type find(const std::string &std_str, size_type idx=0) const
Search forwards for a sub-string.
Definition: String.h:3300