32#include "CEGUI/Base.h"
47#if CEGUI_STRING_CLASS == CEGUI_STRING_CLASS_UNICODE
52#define CEGUI_STR_QUICKBUFF_SIZE 32
86 mutable utf8* d_encodedbuff;
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;
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;
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;
635 return (d_cplength == 0);
649 return (((
size_type)-1) /
sizeof(utf32));
667 return d_reserve - 1;
713 return compare(0, d_cplength,
str);
748 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
750 if ((
len == npos) || (
idx +
len > d_cplength))
783 return compare(0, d_cplength,
std_str);
822 if (d_cplength <
idx)
823 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
826 CEGUI_THROW(std::out_of_range(
"Index is out of range for std::string"));
828 if ((
len == npos) || (
idx +
len > d_cplength))
936 if (d_cplength <
idx)
937 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
940 CEGUI_THROW(std::length_error(
"Length for utf8 encoded string can not be 'npos'"));
942 if ((
len == npos) || (
idx +
len > d_cplength))
1030 if (d_cplength <
idx)
1031 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
1034 CEGUI_THROW(std::length_error(
"Length for char array can not be 'npos'"));
1036 if ((
len == npos) || (
idx +
len > d_cplength))
1064 return (ptr()[
idx]);
1100 if (d_cplength <=
idx)
1101 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
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;
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"));
1245 return encoded_size(&ptr()[
idx], ceguimin(
num,
maxlen));
1287 CEGUI_THROW(std::out_of_range(
"Index was out of range for CEGUI::String object"));
1346 CEGUI_THROW(std::out_of_range(
"Index was out of range for std::string object"));
1432 CEGUI_THROW(std::length_error(
"Length for utf8 encoded string can not be 'npos'"));
1475 CEGUI_THROW(std::length_error(
"Code point count can not be 'npos'"));
1546 *
pt++ =
static_cast<utf32
>(
static_cast<unsigned char>(*
chars++));
1567 d_cplength =
str.d_cplength;
1571 d_reserve =
str.d_reserve;
1575 d_buffer =
str.d_buffer;
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));
1632 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
1691 CEGUI_THROW(std::out_of_range(
"Index is out of range for std::string"));
1780 CEGUI_THROW(std::length_error(
"Length for utf8 encoded string can not be 'npos'"));
1828 CEGUI_THROW(std::length_error(
"Code point count can not be 'npos'"));
1833 utf32*
p = &ptr()[d_cplength];
1935 CEGUI_THROW(std::length_error(
"Length for char array can not be 'npos'"));
1973 return insert(
idx,
str, 0, npos);
2001 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
2068 if (d_cplength <
idx)
2069 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
2072 CEGUI_THROW(std::out_of_range(
"Index is out of range for std::string"));
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'"));
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'"));
2316 if (d_cplength <
idx)
2317 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
2320 CEGUI_THROW(std::length_error(
"Length of char array can not be 'npos'"));
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"));
2430 return erase(safe_iter_dif(
pos, begin()), 1);
2468 resize(
num, utf32());
2488 if (
num < d_cplength)
2580 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
2585 if (((
len +
idx) > d_cplength) || (
len == npos))
2592 if ((
idx +
len) < d_cplength)
2691 if (d_cplength <
idx)
2692 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
2695 CEGUI_THROW(std::out_of_range(
"Index is out of range for std::string"));
2700 if (((
len +
idx) > d_cplength) || (
len == npos))
2707 if ((
idx +
len) < d_cplength)
2813 if (d_cplength <
idx)
2814 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
2817 CEGUI_THROW(std::length_error(
"Length for utf8 encoded string can not be 'npos'"));
2819 if (((
len +
idx) > d_cplength) || (
len == npos))
2827 if ((
idx +
len) < d_cplength)
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))
2908 if ((
idx +
len) < d_cplength)
2987 if ((
len +
idx) > d_cplength)
2994 if ((
idx +
len) < d_cplength)
3081 if (d_cplength <
idx)
3082 CEGUI_THROW(std::out_of_range(
"Index is out of range for CEGUI::String"));
3085 CEGUI_THROW(std::length_error(
"Length for the char array can not be 'npos'"));
3087 if (((
len +
idx) > d_cplength) || (
len == npos))
3094 if ((
idx +
len) < d_cplength)
3156 if (
idx < d_cplength)
3158 const utf32*
pt = &ptr()[
idx];
3160 while (
idx < d_cplength)
3189 if (
idx >= d_cplength)
3190 idx = d_cplength - 1;
3194 const utf32*
pt = &ptr()[
idx];
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);
3304 if ((
sze == 0) && (
idx < d_cplength))
3307 if (
idx < d_cplength)
3310 while (d_cplength -
idx >=
sze)
3346 return (
idx < d_cplength) ?
idx : d_cplength;
3348 if (
sze <= d_cplength)
3350 if (
idx > (d_cplength -
sze))
3358 }
while (
idx-- != 0);
3447 CEGUI_THROW(std::length_error(
"Length for utf8 encoded string can not be 'npos'"));
3451 if ((
sze == 0) && (
idx < d_cplength))
3454 if (
idx < d_cplength)
3457 while (d_cplength -
idx >=
sze)
3498 CEGUI_THROW(std::length_error(
"Length for utf8 encoded string can not be 'npos'"));
3503 return (
idx < d_cplength) ?
idx : d_cplength;
3505 if (
sze <= d_cplength)
3507 if (
idx > (d_cplength -
sze))
3515 }
while (
idx-- != 0);
3589 CEGUI_THROW(std::length_error(
"Length for char array can not be 'npos'"));
3594 if (
idx < d_cplength)
3633 CEGUI_THROW(std::length_error(
"Length for char array can not be 'npos'"));
3636 return (
idx < d_cplength) ?
idx : d_cplength;
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);
3879 CEGUI_THROW(std::length_error(
"Length for utf8 encoded string can not be 'npos'"));
3881 if (
idx < d_cplength)
3885 const utf32*
pt = &ptr()[
idx];
3892 }
while (++
idx != d_cplength);
3927 CEGUI_THROW(std::length_error(
"Length for utf8 encoded string can not be 'npos'"));
3929 if (
idx < d_cplength)
3933 const utf32*
pt = &ptr()[
idx];
3940 }
while (++
idx != d_cplength);
3985 if (
idx < d_cplength)
3992 }
while(
idx++ < d_cplength);
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];
4077 }
while (++
idx != d_cplength);
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];
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);
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);
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;
4370 const utf32*
pt = &ptr()[
idx];
4377 }
while (
idx-- != 0);
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;
4421 const utf32*
pt = &ptr()[
idx];
4428 }
while (
idx-- != 0);
4473 if (
idx >= d_cplength)
4474 idx = d_cplength - 1;
4481 }
while(
idx-- != 0);
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];
4569 }
while (
idx-- != 0);
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];
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"));
4683 return iterator(&ptr()[d_cplength]);
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])))
5597#if CEGUI_STRING_CLASS == CEGUI_STRING_CLASS_STD
5599typedef std::string
String;
5625#if defined(_MSC_VER)
5626# pragma warning(disable : 4251)
Definition MemoryAllocatedObject.h:110
const iterator for String.
Definition String.h:204
regular iterator for String.
Definition String.h:99
String class used within the GUI system.
Definition String.h:64
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
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
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
const utf8 * data(void) const
Returns contents of the String as utf8 encoded data.
Definition String.h:1161
utf32 * pointer
Type used for utf32 code point pointers.
Definition String.h:74
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
String(const_iterator iter_beg, const_iterator iter_end)
Construct a new string object and initialise it with code-points from the range [beg,...
Definition String.h:549
String & insert(size_type idx, const char *cstr)
Inserts the given c-string at the specified position.
Definition String.h:2289
const utf32 * ptr(void) const
Returns a pointer to the buffer in use. (const version)
Definition String.h:1179
String & assign(const char *cstr)
Assign to this String the given C-string.
Definition String.h:1518
bool empty(void) const
Returns true if the String is empty.
Definition String.h:633
std::reverse_iterator< const_iterator > const_reverse_iterator
Constant reverse iterator class for String objects.
Definition String.h:321
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 & 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
const utf32 * const_pointer
Type used for constant utf32 code point pointers.
Definition String.h:75
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
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
void insert(iterator pos, size_type num, utf32 code_point)
Inserts a code point multiple times into the String.
Definition String.h:2223
reference operator[](size_type idx)
Returns the code point at the given index.
Definition String.h:1062
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 find(const utf8 *utf8_str, size_type idx, size_type str_len) const
Search forwards for a sub-string.
Definition String.h:3444
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
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(const String &str, size_type idx=0) const
Search forwards for a sub-string.
Definition String.h:3225
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
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
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
size_type size(void) const
Returns the size of the String in code points.
Definition String.h:609
String substr(size_type idx=0, size_type len=npos) const
Returns a substring of this String.
Definition String.h:4639
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
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
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
const_reverse_iterator rbegin(void) const
Return a constant reverse iterator that describes the beginning of the String.
Definition String.h:4717
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
String & insert(size_type idx, const std::string &std_str)
Inserts the given std::string object at the specified position.
Definition String.h:2035
String & erase(iterator iter_beg, iterator iter_end)
Erase a range of code points described by the iterators [beg, end).
Definition String.h:2446
String(void)
Constructs an empty string.
Definition String.h:342
String & erase(size_type idx)
Erase a single code point from the string.
Definition String.h:2379
int compare(const utf8 *utf8_str) const
Compares this String with the null-terminated utf8 encoded 'utf8_str'.
Definition String.h:861
const utf32 & const_reference
Type used for constant utf32 code point references.
Definition String.h:73
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
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(const std::string &std_str, size_type idx=0) const
Search forwards for a sub-string.
Definition String.h:3300
size_type rfind(const char *cstr, size_type idx=npos) const
Search backwards for a sub-string.
Definition String.h:3561
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 & operator=(const char *cstr)
Assign to this String the given C-string.
Definition String.h:1500
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
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
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
String & append(const_iterator iter_beg, const_iterator iter_end)
Appends the code points in the reange [beg, end)
Definition String.h:1875
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
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
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
utf32 value_type
Basic 'code point' type used for String (utf32)
Definition String.h:69
size_t size_type
Unsigned type used for size values and indices.
Definition String.h:70
String(const char *cstr)
Constructs a new String object and initialise it using the provided c-string.
Definition String.h:571
void resize(size_type num, utf32 code_point)
Resizes the String either by inserting the given utf32 code point to make it larger,...
Definition String.h:2486
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
const_reference at(size_type idx) const
Returns the code point at the given index.
Definition String.h:1118
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
void resize(size_type num)
Resizes the String either by inserting default utf32 code points to make it larger,...
Definition String.h:2466
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_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
const_iterator end(void) const
Return a constant forwards iterator that describes the end of the String.
Definition String.h:4693
iterator end(void)
Return a forwards iterator that describes the end of the String.
Definition String.h:4681
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
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
String & operator=(const std::string &std_str)
Assign the value of std::string std_str to this String.
Definition String.h:1315
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 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
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
size_type find(const char *cstr, size_type idx=0) const
Search forwards for a sub-string.
Definition String.h:3539
reverse_iterator rend(void)
Return a reverse iterator that describes the end of the String.
Definition String.h:4729
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 & 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_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
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
int compare(const std::string &std_str) const
Compares this String with the std::string 'std_str'.
Definition String.h:781
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
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_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 & operator+=(const std::string &std_str)
Appends the std::string std_str.
Definition String.h:1660
int compare(const String &str) const
Compares this String with the String 'str'.
Definition String.h:711
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
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(const char *chars, size_type idx, size_type chars_len) const
Search forwards for a sub-string.
Definition String.h:3586
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 & operator+=(const utf8 *utf8_str)
Appends to the String the null-terminated utf8 encoded data in the buffer utf8_str.
Definition String.h:1727
size_type length(void) const
Returns the size of the String in code points.
Definition String.h:621
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
utf32 & reference
Type used for utf32 code point references.
Definition String.h:72
String & append(size_type num, utf32 code_point)
Appends a single code point multiple times to the string.
Definition String.h:1825
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
size_type rfind(const char *chars, size_type idx, size_type chars_len) const
Search backwards for a sub-string.
Definition String.h:3630
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
reference at(size_type idx)
Returns the code point at the given index.
Definition String.h:1098
String & erase(iterator pos)
Erase the code point described by the given iterator.
Definition String.h:2428
reverse_iterator rbegin(void)
Return a reverse iterator that describes the beginning of the String.
Definition String.h:4705
size_type rfind(utf32 code_point, size_type idx=npos) const
Search backwards for a given code point.
Definition String.h:3187
String(const std::string &std_str)
Constructs a new string and initialises it using the std::string std_str.
Definition String.h:414
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 & operator+=(utf32 code_point)
Appends a single code point to the string.
Definition String.h:1805
size_type rfind(const utf8 *utf8_str, size_type idx=npos) const
Search backwards for a sub-string.
Definition String.h:3414
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
~String(void)
Destructor for String objects.
String & assign(size_type num, utf32 code_point)
Assigns the specified code point repeatedly to the String.
Definition String.h:1472
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,...
Definition String.h:2975
std::reverse_iterator< iterator > reverse_iterator
Reverse iterator class for String objects.
Definition String.h:331
String & operator+=(const String &str)
Appends the String str.
Definition String.h:1605
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
const char * c_str(void) const
Returns contents of the String as a null terminated string of utf8 encoded data.
Definition String.h:1143
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
size_type find(utf32 code_point, size_type idx=0) const
Search forwards for a given code point.
Definition String.h:3154
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
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
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
size_type find(const utf8 *utf8_str, size_type idx=0) const
Search forwards for a sub-string.
Definition String.h:3387
String & insert(size_type idx, const String &str)
Inserts the given String object at the specified position.
Definition String.h:1971
utf32 * ptr(void)
Returns a pointer to the buffer in use.
Definition String.h:1170
int compare(const char *cstr) const
Compares this String with the given c-string.
Definition String.h:966
std::ptrdiff_t difference_type
Signed type used for differences.
Definition String.h:71
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
iterator begin(void)
Return a forwards iterator that describes the beginning of the String.
Definition String.h:4657
String & append(const char *chars, size_type chars_len)
Appends to the String chars from the given char array.
Definition String.h:1932
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_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 & erase(void)
Removes all data from the String.
Definition String.h:2361
size_type rfind(const String &str, size_type idx=npos) const
Search backwards for a sub-string.
Definition String.h:3260
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
String & operator+=(const char *cstr)
Appends to the String the given c-string.
Definition String.h:1893
void clear(void)
Removes all data from the String.
Definition String.h:2348
String(const String &str)
Copy constructor - Creates a new string with the same value as str.
Definition String.h:366
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 & 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_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
const_iterator begin(void) const
Return a constant forwards iterator that describes the beginning of the String.
Definition String.h:4669
void push_back(utf32 code_point)
Appends a single code point to the string.
Definition String.h:1855
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 & 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 & assign(const char *chars, size_type chars_len)
Assign to this String a number of chars from a char array.
Definition String.h:1539
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
String & append(const char *cstr)
Appends to the String the given c-string.
Definition String.h:1911
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
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
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
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
iterator insert(iterator pos, utf32 code_point)
Inserts a single code point into the String.
Definition String.h:2243
static const size_type npos
Value used to represent 'not found' conditions and 'all code points' etc.
Definition String.h:77
String & erase(size_type idx, size_type len)
Erase a range of code points.
Definition String.h:2399
value_type operator[](size_type idx) const
Returns the code point at the given index.
Definition String.h:1081
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
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
String & operator=(const String &str)
Assign the value of String str to this String.
Definition String.h:1261
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, const String &str)
Replace the code points in the range [beg, end) with the specified String object.
Definition String.h:2547
size_type max_size(void) const
Returns the maximum size of a String.
Definition String.h:647
void reserve(size_type num=0)
Specifies the amount of reserve capacity to allocate.
Definition String.h:685
size_type rfind(const std::string &std_str, size_type idx=npos) const
Search backwards for a sub-string.
Definition String.h:3341
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
String(size_type num, utf32 code_point)
Constructs a new String that is initialised with the specified code point.
Definition String.h:526
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
void swap(String &str)
Swaps the value of this String with the given String str.
Definition String.h:1564
base class for properties able to do native set/get
Definition TypedProperty.h:50
Main namespace for Crazy Eddie's GUI Library.
Definition arch_overview.dox:1
bool CEGUIEXPORT operator<=(const String &str1, const String &str2)
Return true if String str1 is lexicographically less than or equal to String str2.
bool CEGUIEXPORT operator>(const String &str1, const String &str2)
Return true if String str1 is lexicographically greater than String str2.
utf8 encoded_char
encoded char signifies that it's a char (8bit) with encoding (in this case utf8)
Definition String.h:50
bool CEGUIEXPORT operator<(const String &str1, const String &str2)
Return true if String str1 is lexicographically less than String str2.
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 greater than or equal to String str2.
bool CEGUIEXPORT operator!=(const String &str1, const String &str2)
Return true if String str1 is not equal to String str2.
bool CEGUIEXPORT operator==(const String &str1, const String &str2)
Return true if String str1 is equal to String str2.
void CEGUIEXPORT swap(String &str1, String &str2)
Swap the contents for two String objects.
Functor that can be used as comparator in a std::map with String keys. It's faster than using the def...
Definition String.h:5580