31 #ifndef __IRR_USTRING_H_INCLUDED__ 32 #define __IRR_USTRING_H_INCLUDED__ 34 #if (__cplusplus > 199711L) || (_MSC_VER >= 1600) || defined(__GXX_EXPERIMENTAL_CXX0X__) 35 # define USTRING_CPP0X 36 # if defined(__GXX_EXPERIMENTAL_CXX0X__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))) 37 # define USTRING_CPP0X_NEWLITERALS 42 #define USTRING_NO_STL 52 #ifndef USTRING_NO_STL 56 # include <functional> 67 static const irr::u16 UTF16_HI_SURROGATE = 0xD800;
68 static const irr::u16 UTF16_LO_SURROGATE = 0xDC00;
71 #define UTF16_IS_SURROGATE(c) (((c) & 0xF800) == 0xD800) 72 #define UTF16_IS_SURROGATE_HI(c) (((c) & 0xFC00) == 0xD800) 73 #define UTF16_IS_SURROGATE_LO(c) (((c) & 0xFC00) == 0xDC00) 80 #ifdef USTRING_CPP0X_NEWLITERALS // C++0x 106 uchar32_t x = ((high & ((1 << 6) -1)) << 10) | (low & ((1 << 10) -1));
107 uchar32_t wu = ((high >> 6) & ((1 << 5) - 1)) + 1;
108 return (wu << 16) |
x;
115 return ((
c >> 8) & 0x00FF) | ((
c << 8) & 0xFF00);
122 return ((
c >> 24) & 0x000000FF) |
123 ((
c >> 8) & 0x0000FF00) |
124 ((
c << 8) & 0x00FF0000) |
125 ((
c << 24) & 0xFF000000);
176 #define COPY_ARRAY(source, size) \ 177 memcpy(ret.pointer(), source, size); \ 187 #ifdef __BIG_ENDIAN__ 200 #ifdef __BIG_ENDIAN__ 235 template <
typename TAlloc = irrAllocator<u
char16_t> >
390 return static_cast<uchar32_t>(
a[pos]);
393 if (pos + 1 >=
ref->size_raw())
403 ustring16<TAlloc>* ref2 =
const_cast<ustring16<TAlloc>*
>(
ref);
409 uchar16_t vh = UTF16_HI_SURROGATE | ((((
c >> 16) & ((1 << 5) - 1)) - 1) << 6) | (
x >> 10);
410 uchar16_t vl = UTF16_LO_SURROGATE | (
x & ((1 << 10) - 1));
414 ref2->replace_raw(vl, pos + 1);
415 else ref2->insert_raw(vl, pos + 1);
417 ref2->replace_raw(vh, pos);
426 ref2->erase_raw(pos + 1);
428 ref2->replace_raw(vh, pos);
432 const ustring16<TAlloc>*
ref;
439 #ifndef USTRING_NO_STL 441 std::bidirectional_iterator_tag,
457 #ifndef USTRING_NO_STL 458 typedef std::iterator<std::bidirectional_iterator_tag, access, ptrdiff_t, const access, const access> _Base;
459 typedef typename _Base::value_type
value_type;
477 if (
ref->size_raw() == 0 ||
p == 0)
482 size_t sr =
ref->size_raw();
484 while (i != 0 &&
pos < sr)
512 if (
pos ==
ref->size_raw())
return *
this;
532 if (
pos == 0)
return *
this;
552 if (
v == 0)
return *
this;
555 if (
pos >=
ref->size_raw())
560 size_t sr =
ref->size_raw();
562 while (i != 0 &&
pos < sr)
579 if (
v == 0)
return *
this;
588 while (i != 0 &&
pos != 0)
648 if (
pos >=
ref->size_raw())
651 size_t p =
ref->size_raw();
664 if (
pos >=
ref->size_raw())
667 size_t p =
ref->size_raw();
700 return (
pos + 1) >=
ref->size_raw();
701 else return pos >=
ref->size_raw();
755 if (
pos >=
ref->size_raw())
758 size_t p =
ref->size_raw();
771 if (
pos >=
ref->size_raw())
774 size_t p =
ref->size_raw();
813 :
array(0), allocated(1), used(0)
820 array = allocator.allocate(1);
827 :
array(0), allocated(0), used(0)
839 template <
class B,
class A>
841 :
array(0), allocated(0), used(0)
852 #ifndef USTRING_NO_STL 853 template <
class B,
class A,
typename Alloc>
855 ustring16(
const std::basic_string<B, A, Alloc>& other)
856 :
array(0), allocated(0), used(0)
863 *
this = other.c_str();
868 template <
typename Itr>
870 :
array(0), allocated(0), used(0)
886 #ifndef USTRING_CPP0X_NEWLITERALS 889 :
array(0), allocated(0), used(0)
904 :
array(0), allocated(0), used(0)
919 :
array(0), allocated(0), used(0)
933 :
array(0), allocated(0), used(0)
947 :
array(0), allocated(0), used(0)
961 :
array(0), allocated(0), used(0)
975 :
array(0), allocated(0), used(0)
989 :
array(0), allocated(0), used(0)
1003 :
array(0), allocated(0), used(0)
1017 :
array(0), allocated(0), used(0)
1025 if (
sizeof(
wchar_t) == 4)
1026 append(reinterpret_cast<const uchar32_t* const>(
c));
1027 else if (
sizeof(
wchar_t) == 2)
1028 append(reinterpret_cast<const uchar16_t* const>(
c));
1029 else if (
sizeof(
wchar_t) == 1)
1030 append(reinterpret_cast<const uchar8_t* const>(
c));
1036 :
array(0), allocated(0), used(0)
1044 if (
sizeof(
wchar_t) == 4)
1045 append(reinterpret_cast<const uchar32_t* const>(
c),
length);
1046 else if (
sizeof(
wchar_t) == 2)
1047 append(reinterpret_cast<const uchar16_t* const>(
c),
length);
1048 else if (
sizeof(
wchar_t) == 1)
1053 #ifdef USTRING_CPP0X 1056 :
array(other.
array), encoding(other.encoding), allocated(other.allocated), used(other.used)
1060 other.allocated = 0;
1069 allocator.deallocate(
array);
1080 if (used >= allocated)
1082 allocator.deallocate(
array);
1083 allocated = used + 1;
1084 array = allocator.allocate(used + 1);
1088 for (
size_t i=0; i<=used; ++i, ++
p)
1100 #ifdef USTRING_CPP0X 1107 allocator.deallocate(
array);
1110 allocated = other.allocated;
1111 encoding = other.encoding;
1122 template <
class B,
class A>
1125 *
this = other.
c_str();
1135 array = allocator.allocate(1);
1140 if (!
c)
return *
this;
1153 array = allocator.allocate(1);
1158 if (!
c)
return *
this;
1171 array = allocator.allocate(1);
1176 if (!
c)
return *
this;
1190 if (
sizeof(
wchar_t) == 4)
1191 *
this = reinterpret_cast<const uchar32_t* const>(
c);
1192 else if (
sizeof(
wchar_t) == 2)
1193 *
this = reinterpret_cast<const uchar16_t* const>(
c);
1194 else if (
sizeof(
wchar_t) == 1)
1195 *
this = reinterpret_cast<const uchar8_t* const>(
c);
1207 *
this = reinterpret_cast<const uchar32_t* const>(
c);
1208 else if (
sizeof(B) == 2)
1209 *
this = reinterpret_cast<const uchar16_t* const>(
c);
1210 else if (
sizeof(B) == 1)
1211 *
this = reinterpret_cast<const uchar8_t* const>(
c);
1222 return iter.operator*();
1231 return iter.operator*();
1242 for (i=0;
array[i] && str[i]; ++i)
1243 if (
array[i] != str[i])
1246 return !
array[i] && !str[i];
1253 for (
size_t i=0;
array[i] && other.array[i]; ++i)
1254 if (
array[i] != other.array[i])
1257 return used == other.used;
1264 for (
size_t i=0;
array[i] && other.array[i]; ++i)
1266 if (
array[i] == other.array[i])
1268 return array[i] < other.array[i];
1271 return used < other.used;
1278 return !(*
this == str);
1285 return !(*
this == other);
1328 for(i=0;
array[i] && oa[i] && i <
n; ++i)
1329 if (
array[i] != oa[i])
1334 return (i ==
n) || (used == other.used);
1347 for(i=0;
array[i] && str[i] && i <
n; ++i)
1348 if (
array[i] != str[i])
1353 return (i ==
n) || (
array[i] == 0 && str[i] == 0);
1362 if (used + 2 >= allocated)
1363 reallocate(used + 2);
1365 if (character > 0xFFFF)
1370 uchar16_t x = static_cast<uchar16_t>(character);
1371 uchar16_t vh = UTF16_HI_SURROGATE | ((((character >> 16) & ((1 << 5) - 1)) - 1) << 6) | (
x >> 10);
1372 uchar16_t vl = UTF16_LO_SURROGATE | (
x & ((1 << 10) - 1));
1379 array[used-1] = character;
1431 if (used +
len >= allocated)
1432 reallocate(used + (
len * 2));
1433 size_t start = used;
1437 for (
size_t l = 0; l<
len;)
1440 if (((c2[l] >> 6) & 0x03) == 0x02)
1445 else if (c2[l] == 0xC0 || c2[l] == 0xC1)
1450 else if ((c2[l] & 0xF8) == 0xF0)
1463 if (valid && (((c2[l+1] >> 6) & 0x03) == 0x02)) ++l2;
else valid =
false;
1464 if (valid && (((c2[l+2] >> 6) & 0x03) == 0x02)) ++l2;
else valid =
false;
1465 if (valid && (((c2[l+3] >> 6) & 0x03) == 0x02)) ++l2;
else valid =
false;
1474 uchar8_t b1 = ((c2[l] & 0x7) << 2) | ((c2[l+1] >> 4) & 0x3);
1475 uchar8_t b2 = ((c2[l+1] & 0xF) << 4) | ((c2[l+2] >> 2) & 0xF);
1476 uchar8_t b3 = ((c2[l+2] & 0x3) << 6) | (c2[l+3] & 0x3F);
1481 uchar16_t vh = UTF16_HI_SURROGATE | ((((
v >> 16) & ((1 << 5) - 1)) - 1) << 6) | (
x >> 10);
1482 uchar16_t vl = UTF16_LO_SURROGATE | (
x & ((1 << 10) - 1));
1489 else if ((c2[l] & 0xF0) == 0xE0)
1502 if (valid && (((c2[l+1] >> 6) & 0x03) == 0x02)) ++l2;
else valid =
false;
1503 if (valid && (((c2[l+2] >> 6) & 0x03) == 0x02)) ++l2;
else valid =
false;
1512 uchar8_t b1 = ((c2[l] & 0xF) << 4) | ((c2[l+1] >> 2) & 0xF);
1513 uchar8_t b2 = ((c2[l+1] & 0x3) << 6) | (c2[l+2] & 0x3F);
1518 else if ((c2[l] & 0xE0) == 0xC0)
1529 if (((c2[l+1] >> 6) & 0x03) != 0x02)
1538 uchar8_t b2 = ((c2[l] & 0x3) << 6) | (c2[l+1] & 0x3F);
1550 else array[pos++] = static_cast<uchar16_t>(c2[l]);
1606 if (used +
len >= allocated)
1607 reallocate(used + (
len * 2));
1608 size_t start = used;
1664 if (used + (
len * 2) >= allocated)
1665 reallocate(used + ((
len * 2) * 2));
1666 size_t start = used;
1671 for (
size_t l = 0; l<
len; ++l)
1683 uchar16_t vh = UTF16_HI_SURROGATE | ((((ch >> 16) & ((1 << 5) - 1)) - 1) << 6) | (
x >> 10);
1684 uchar16_t vl = UTF16_LO_SURROGATE | (
x & ((1 << 10) - 1));
1689 else if (ch >= 0xD800 && ch <= 0xDFFF)
1694 else array[pos++] = static_cast<uchar16_t>(ch);
1714 if (used +
len >= allocated)
1715 reallocate(used +
len);
1717 for (
size_t l=0; l<
len; ++l)
1718 array[used+l] = oa[l];
1733 if (other.
size() == 0)
1742 if (used +
length * 2 >= allocated)
1743 reallocate(used +
length * 2);
1747 while (!iter.
atEnd() && l)
1763 if (
count < allocated)
1805 for (
size_t j = 0; j <
count; ++j)
1832 for (j = 0; j <
count; ++j)
1857 size_t pos =
size();
1866 for (j = 0; j <
count; ++j)
1887 size_t pos = startPos;
1937 size_t pos =
size();
1941 for (
size_t j = 0; j <
count; ++j)
1958 size_t my_size =
size();
1959 size_t their_size = str.
size();
1961 if (their_size == 0 || my_size -
start < their_size)
2007 for (
size_t i =
start; i <= used -
len; ++i)
2101 #ifdef USTRING_CPP0X_NEWLITERALS 2197 if (toReplace.
size() == 0)
2202 const size_t other_size = toReplace.
size_raw();
2203 const size_t replace_size = replaceWith.
size_raw();
2206 if (replace_size == other_size)
2211 for (
size_t i = 0; i < replace_size; ++i)
2219 if (replace_size < other_size)
2222 for (
size_t pos = 0; pos <= used; ++i, ++pos)
2225 if (
array[pos] == *other)
2229 for (j = 0; j < other_size; ++j)
2231 if (
array[pos + j] != other[j])
2236 if (j == other_size)
2238 for (j = 0; j < replace_size; ++j)
2240 i += replace_size - 1;
2241 pos += other_size - 1;
2256 size_t delta = replace_size - other_size;
2260 size_t find_count = 0;
2269 size_t len = delta * find_count;
2270 if (used +
len >= allocated)
2271 reallocate(used +
len);
2282 while (ptr !=
start)
2290 for (
size_t i = 0; i < replace_size; ++i)
2293 pos += replace_size;
2310 size_t len = (
c > 0xFFFF ? 2 : 1);
2311 for (
size_t i=0; i<=used; ++i)
2316 else if (i + 1 <= used)
2321 size_t len2 = (uc32 > 0xFFFF ? 2 : 1);
2345 if (
size == 0)
return *
this;
2350 for (
size_t i=0; i<=used; ++i)
2355 if (
array[i + j] != tra[j])
2385 for (
size_t i=0; i<=used; ++i)
2390 else if (i + 1 <= used)
2395 size_t len2 = (uc32 > 0xFFFF ? 2 : 1);
2399 while (!iter.
atEnd())
2404 found += (
c > 0xFFFF ? 2 : 1);
2454 size_t len = (
t > 0xFFFF ? 2 : 1);
2456 for (
size_t j = i.
getPos() +
len; j <= used; ++j)
2471 for (
size_t i=0; i<allocated; ++i)
2487 if (
array[i] >= 0xFDD0 &&
array[i] <= 0xFDEF)
2495 used = allocated - 1;
2524 return array[used-1];
2547 template<
class container>
2548 size_t split(container& ret,
const uchar32_t*
const c,
size_t count=1,
bool ignoreEmptyTokens=
true,
bool keepSeparators=
false)
const 2554 const size_t oldSize=ret.size();
2557 size_t lastpospos = 0;
2558 bool lastWasSeparator =
false;
2562 bool foundSeparator =
false;
2563 for (
size_t j=0; j<
count; ++j)
2567 if ((!ignoreEmptyTokens || pos - lastpos != 0) &&
2570 foundSeparator =
true;
2571 lastpos = (keepSeparators ? pos : pos + 1);
2572 lastpospos = (keepSeparators ? i.
getPos() : i.
getPos() + 1);
2576 lastWasSeparator = foundSeparator;
2580 size_t s =
size() + 1;
2583 return ret.size()-oldSize;
2604 template<
class container>
2608 return split(ret,
v.pointer(),
v.size(), ignoreEmptyTokens, keepSeparators);
2634 u8 len = (
c > 0xFFFF ? 2 : 1);
2636 if (used +
len >= allocated)
2637 reallocate(used +
len);
2642 for (
size_t i = used - 2; i > iter.
getPos(); --i)
2649 uchar16_t vh = UTF16_HI_SURROGATE | ((((
c >> 16) & ((1 << 5) - 1)) - 1) << 6) | (
x >> 10);
2650 uchar16_t vl = UTF16_LO_SURROGATE | (
x & ((1 << 10) - 1));
2669 size_t len =
c.size_raw();
2670 if (
len == 0)
return *
this;
2672 if (used +
len >= allocated)
2673 reallocate(used +
len);
2678 for (
size_t i = used - 2; i > iter.
getPos() +
len; --i)
2682 for (
size_t i = 0; i <
len; ++i)
2699 if (used + 1 >= allocated)
2700 reallocate(used + 1);
2704 for (
size_t i = used - 1; i > pos; --i)
2718 for (
size_t i=pos; i<=used; ++i)
2813 while (!iter.
atEnd())
2818 uchar8_t b1 = (0x1E << 3) | ((
c >> 18) & 0x7);
2819 uchar8_t b2 = (0x2 << 6) | ((
c >> 12) & 0x3F);
2820 uchar8_t b3 = (0x2 << 6) | ((
c >> 6) & 0x3F);
2829 uchar8_t b1 = (0xE << 4) | ((
c >> 12) & 0xF);
2830 uchar8_t b2 = (0x2 << 6) | ((
c >> 6) & 0x3F);
2838 uchar8_t b1 = (0x6 << 5) | ((
c >> 6) & 0x1F);
2845 ret.
append(static_cast<uchar8_t>(
c));
2869 while (!iter.
atEnd())
2874 uchar8_t b1 = (0x1E << 3) | ((
c >> 18) & 0x7);
2875 uchar8_t b2 = (0x2 << 6) | ((
c >> 12) & 0x3F);
2876 uchar8_t b3 = (0x2 << 6) | ((
c >> 6) & 0x3F);
2885 uchar8_t b1 = (0xE << 4) | ((
c >> 12) & 0xF);
2886 uchar8_t b2 = (0x2 << 6) | ((
c >> 6) & 0x3F);
2894 uchar8_t b1 = (0x6 << 5) | ((
c >> 6) & 0x1F);
2910 #ifdef USTRING_CPP0X_NEWLITERALS // C++0x 2942 char16_t* ptr = ret.
c_str();
2943 for (
size_t i = 0; i < ret.
size(); ++i)
2968 uchar8_t* ptr8 = reinterpret_cast<uchar8_t*>(ptr);
2974 uchar8_t* ptr8 = reinterpret_cast<uchar8_t*>(ptr);
2984 for (
size_t i = 0; i <= used; ++i)
2993 #ifdef USTRING_CPP0X_NEWLITERALS // C++0x 3035 while (!iter.atEnd())
3090 while (!iter.
atEnd())
3110 if (
sizeof(
wchar_t) == 4)
3116 else if (
sizeof(
wchar_t) == 2)
3125 core::array<uchar16_t>
a(
toUTF16(endian, addBOM));
3130 else if (
sizeof(
wchar_t) == 1)
3132 core::array<uchar8_t>
a(
toUTF8(addBOM));
3150 if (
sizeof(
wchar_t) == 4)
3152 core::array<uchar32_t>
a(
toUTF32(endian, addBOM));
3153 core::array<wchar_t> ret(
a.size());
3154 ret.set_used(
a.size());
3155 memcpy((
void*)ret.pointer(), (
void*)
a.pointer(),
a.
size() *
sizeof(
uchar32_t));
3158 if (
sizeof(
wchar_t) == 2)
3162 core::array<wchar_t> ret(used);
3164 memcpy((
void*)ret.pointer(), (
void*)
array, used *
sizeof(
uchar16_t));
3169 core::array<uchar16_t>
a(
toUTF16(endian, addBOM));
3170 core::array<wchar_t> ret(
a.size());
3171 ret.set_used(
a.size());
3172 memcpy((
void*)ret.pointer(), (
void*)
a.pointer(),
a.
size() *
sizeof(
uchar16_t));
3176 if (
sizeof(
wchar_t) == 1)
3178 core::array<uchar8_t>
a(
toUTF8(addBOM));
3179 core::array<wchar_t> ret(
a.size());
3180 ret.set_used(
a.size());
3181 memcpy((
void*)ret.pointer(), (
void*)
a.pointer(),
a.
size() *
sizeof(
uchar8_t));
3186 return core::array<wchar_t>();
3195 #if defined(_IRR_WCHAR_FILESYSTEM) 3259 void reallocate(
size_t new_size)
3263 array = allocator.allocate(new_size + 1);
3264 allocated = new_size + 1;
3265 if (old_array == 0)
return;
3267 size_t amount = used < new_size ? used : new_size;
3268 for (
size_t i=0; i<=amount; ++i)
3269 array[i] = old_array[i];
3271 if (allocated <= used)
3272 used = allocated - 1;
3276 allocator.deallocate(old_array);
3293 template <
typename TAlloc>
3303 template <
typename TAlloc,
class B>
3313 template <
class B,
typename TAlloc>
3323 template <
typename TAlloc,
typename B,
typename BAlloc>
3333 template <
typename TAlloc,
typename B,
typename BAlloc>
3342 #ifndef USTRING_NO_STL 3343 template <
typename TAlloc,
typename B,
typename A,
typename BAlloc>
3345 inline ustring16<TAlloc>
operator+(
const ustring16<TAlloc>&
left,
const std::basic_string<B, A, BAlloc>&
right)
3347 ustring16<TAlloc> ret(
left);
3353 template <
typename TAlloc,
typename B,
typename A,
typename BAlloc>
3354 inline ustring16<TAlloc>
operator+(
const std::basic_string<B, A, BAlloc>&
left,
const ustring16<TAlloc>&
right)
3356 ustring16<TAlloc> ret(
left);
3363 template <
typename TAlloc>
3373 template <
typename TAlloc>
3382 #ifdef USTRING_CPP0X_NEWLITERALS 3383 template <
typename TAlloc>
3387 ustring16<TAlloc> ret(
left);
3394 template <
typename TAlloc>
3397 ustring16<TAlloc> ret(
left);
3405 template <
typename TAlloc>
3415 template <
typename TAlloc>
3425 template <
typename TAlloc>
3435 template <
typename TAlloc>
3445 template <
typename TAlloc>
3455 template <
typename TAlloc>
3465 template <
typename TAlloc>
3475 template <
typename TAlloc>
3485 template <
typename TAlloc>
3495 template <
typename TAlloc>
3505 template <
typename TAlloc>
3515 template <
typename TAlloc>
3525 template <
typename TAlloc>
3535 template <
typename TAlloc>
3545 template <
typename TAlloc>
3555 template <
typename TAlloc>
3564 #ifdef USTRING_CPP0X 3565 template <
typename TAlloc>
3567 inline ustring16<TAlloc>&&
operator+(
const ustring16<TAlloc>&
left, ustring16<TAlloc>&&
right)
3571 return std::move(
right);
3576 template <
typename TAlloc>
3577 inline ustring16<TAlloc>&&
operator+(ustring16<TAlloc>&&
left,
const ustring16<TAlloc>&
right)
3581 return std::move(
left);
3586 template <
typename TAlloc>
3587 inline ustring16<TAlloc>&&
operator+(ustring16<TAlloc>&&
left, ustring16<TAlloc>&&
right)
3590 if ((
right.size_raw() <=
left.capacity() -
left.size_raw()) ||
3594 return std::move(
left);
3599 return std::move(
right);
3605 template <
typename TAlloc,
class B>
3610 return std::move(
left);
3615 template <
class B,
typename TAlloc>
3620 return std::move(
right);
3625 template <
typename TAlloc,
typename B,
typename BAlloc>
3630 return std::move(
right);
3635 template <
typename TAlloc,
typename B,
typename BAlloc>
3640 return std::move(
left);
3645 template <
typename TAlloc,
typename B,
typename A,
typename BAlloc>
3646 inline ustring16<TAlloc>&&
operator+(
const std::basic_string<B, A, BAlloc>&
left, ustring16<TAlloc>&&
right)
3649 right.insert(core::ustring16<TAlloc>(
left), 0);
3650 return std::move(
right);
3655 template <
typename TAlloc,
typename B,
typename A,
typename BAlloc>
3656 inline ustring16<TAlloc>&&
operator+(ustring16<TAlloc>&&
left,
const std::basic_string<B, A, BAlloc>&
right)
3660 return std::move(
left);
3665 template <
typename TAlloc>
3669 return std::move(
left);
3674 template <
typename TAlloc>
3678 return std::move(
right);
3682 #ifdef USTRING_CPP0X_NEWLITERALS 3683 template <
typename TAlloc>
3688 return std::move(
left);
3693 template <
typename TAlloc>
3697 return std::move(
right);
3703 template <
typename TAlloc>
3707 return std::move(
left);
3712 template <
typename TAlloc>
3716 return std::move(
right);
3721 template <
typename TAlloc>
3722 inline ustring16<TAlloc>
operator+(ustring16<TAlloc>&&
left,
const unsigned short right)
3725 return std::move(
left);
3730 template <
typename TAlloc>
3731 inline ustring16<TAlloc>
operator+(
const unsigned short left, ustring16<TAlloc>&&
right)
3734 return std::move(
right);
3739 template <
typename TAlloc>
3743 return std::move(
left);
3748 template <
typename TAlloc>
3752 return std::move(
right);
3757 template <
typename TAlloc>
3758 inline ustring16<TAlloc>
operator+(ustring16<TAlloc>&&
left,
const unsigned int right)
3761 return std::move(
left);
3766 template <
typename TAlloc>
3767 inline ustring16<TAlloc>
operator+(
const unsigned int left, ustring16<TAlloc>&&
right)
3770 return std::move(
right);
3775 template <
typename TAlloc>
3779 return std::move(
left);
3784 template <
typename TAlloc>
3788 return std::move(
right);
3793 template <
typename TAlloc>
3794 inline ustring16<TAlloc>
operator+(ustring16<TAlloc>&&
left,
const unsigned long right)
3797 return std::move(
left);
3802 template <
typename TAlloc>
3803 inline ustring16<TAlloc>
operator+(
const unsigned long left, ustring16<TAlloc>&&
right)
3806 return std::move(
right);
3811 template <
typename TAlloc>
3815 return std::move(
left);
3820 template <
typename TAlloc>
3824 return std::move(
right);
3829 template <
typename TAlloc>
3833 return std::move(
left);
3838 template <
typename TAlloc>
3842 return std::move(
right);
3847 #ifndef USTRING_NO_STL 3848 template <
typename TAlloc>
3850 inline std::ostream& operator<<(std::ostream& out,
const ustring16<TAlloc>&
in)
3852 out <<
in.toUTF8_s().c_str();
3857 template <
typename TAlloc>
3858 inline std::wostream& operator<<(std::wostream& out,
const ustring16<TAlloc>&
in)
3860 out <<
in.toWCHAR_s().c_str();
3866 #ifndef USTRING_NO_STL 3873 class hash :
public std::unary_function<core::ustring, size_t>
3878 size_t ret = 2166136261U;
3880 size_t stride = 1 +
s.size_raw() / 10;
3883 while (i !=
s.end())
ustring16< TAlloc > & insert_raw(uchar16_t c, size_t pos)
ustring16(const uchar32_t *const c, size_t length)
Constructor for copying a UTF-32 from a pointer with a given length.
void set_used(u32 usedNow)
Sets the size of the array and allocates new elements if necessary.
_Iter operator++(int)
Switch to the next full character in the string, returning the previous position.
ustring16< TAlloc > & append(const uchar16_t *const other, size_t length=0xffffffff)
const u8 BOM_ENCODE_UTF32_LEN
bool operator !=(const ustring16< TAlloc > &other) const
Inequality operator.
ustring16< irrAllocator< uchar16_t > > ustring
uchar32_t operator--(int)
u32 size() const
Returns length of the string's content.
_ustring16_const_iterator(const _Iter &i)
Constructors.
const u8 BOM_ENCODE_UTF8[3]
Unicode byte order marks for file operations.
ustring16< TAlloc > & trim(const ustring16< TAlloc > &whitespace=" \t\n\r")
array()
Default constructor for empty array.
ustring16(const uchar8_t *const c, size_t length)
Constructor for copying a UTF-8 string from a pointer with a given length.
GLsizei const GLchar *const * string
access operator [](const size_t index)
Direct access operator.
_ustring16_iterator_access & operator=(const uchar32_t c)
_ustring16_iterator_access & operator--()
const_iterator end() const
bool operator==(const uchar16_t *const str) const
Equality operator.
string< T, TAlloc > & append(T character)
Appends a character to this string.
ustring16(const uchar8_t *const c)
Constructor for copying a UTF-8 string from a pointer.
ustring16(const wchar_t *const c)
Constructor for copying a wchar_t string from a pointer.
GLuint GLuint GLsizei count
const access operator [](const size_t index) const
Direct access operator.
_Iter operator--(int)
Switch to the previous full character in the string, returning the previous position.
bool atStart() const
Is the iterator at the start of the string?
const unicode::EUTF_ENDIAN getEndianness() const
ustring16< TAlloc >::_ustring16_iterator iterator
#define UTF16_IS_SURROGATE_LO(c)
const u8 BOM_ENCODE_UTF16_LEN
ustring16(const char *const c, size_t length)
Constructor for copying a character string from a pointer with a given length.
size_t find_raw(const ustring16< TAlloc > &str, const size_t start=0) const
core::array< uchar16_t > toUTF16(const unicode::EUTF_ENDIAN endian=unicode::EUTFEE_NATIVE, const bool addBOM=false) const
const_iterator cend() const
void toStart()
Moves the iterator to the start of the string.
bool operator!=(const _Iter &iter) const
Test for unequalness.
uchar32_t operator%(int val) const
bool atEnd() const
Is the iterator at the end of the string?
const T * const_pointer() const
Gets a const pointer to the array.
Iterator to iterate through a UTF-16 string.
#define COPY_ARRAY(source, size)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
bool operator<(const ustring16< TAlloc > &other) const
Is smaller comparator.
Iterator to iterate through a UTF-16 string.
ustring16< TAlloc > & append(const ustring16< TAlloc > &other)
_Iter & operator++()
Switch to the next full character in the string.
const access const_reference
const_reference operator *() const
Accesses the full character at the iterator's position.
const ustring16< TAlloc > * ref
_Iter & operator--()
Switch to the previous full character in the string.
ustring16< TAlloc > & replace_raw(uchar16_t c, size_t pos)
size_t findLastChar(const uchar32_t *const c, size_t count=1) const
const unicode::EUTF_ENCODE getEncoding() const
ustring16< TAlloc > & loadDataStream(const char *data, size_t data_size)
core::array< uchar8_t > toUTF8(const bool addBOM=false) const
#define UTF16_IS_SURROGATE_HI(c)
core::string< uchar8_t > toUTF8_s(const bool addBOM=false) const
core::array< wchar_t > toWCHAR(const unicode::EUTF_ENDIAN endian=unicode::EUTFEE_NATIVE, const bool addBOM=false) const
Converts the string to a wchar_t encoded string array.
Everything in the Irrlicht Engine can be found in this namespace.
ustring16(const wchar_t *const c, size_t length)
Constructor for copying a wchar_t string from a pointer with a given length.
const u16 BOM
The Unicode byte order mark.
uchar32_t swapEndian32(const uchar32_t &c)
_ustring16_iterator _Iter
core::string< wchar_t > toWCHAR_s(const unicode::EUTF_ENDIAN endian=unicode::EUTFEE_NATIVE, const bool addBOM=false) const
Converts the string to a wchar_t encoded string.
const access const_pointer
ustring16< TAlloc > & removeChars(const ustring16< TAlloc > &characters)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
Very simple string class with some useful features.
GLsizei const void * pointer
GLsizei GLsizei GLfloat distance
size_t find(const ustring16< TAlloc > &str, const size_t start=0) const
void push_back(const T &element)
Adds an element at back of array.
unsigned char u8
8 bit unsigned variable.
ustring16< TAlloc > & operator=(const string< B, A > &other)
Assignment operator for other string types.
const_pointer operator->() const
Accesses the full character at the iterator's position.
ustring16< TAlloc > & operator=(const wchar_t *const c)
Assignment operator for wchar_t strings.
EUTF_ENCODE
Unicode encoding type.
_Base::difference_type difference_type
EUTF_ENCODE determineUnicodeBOM(const char *data)
size_t findFirst(uchar32_t c) const
void reserve(u32 count)
Reserves some memory.
unsigned short u16
16 bit unsigned variable.
_ustring16_const_iterator(const ustring16< TAlloc > &s)
uchar32_t operator/(int val) const
ustring16< TAlloc > & validate()
const u8 BOM_ENCODE_UTF32_LE[4]
ustring16(const uchar16_t *const c, size_t length)
Constructor for copying a UTF-16 string from a pointer with a given length.
core::array< uchar32_t > toUTF32(const unicode::EUTF_ENDIAN endian=unicode::EUTFEE_NATIVE, const bool addBOM=false) const
ustring16< TAlloc >::_ustring16_iterator_access access
pointer operator->() const
Accesses the full character at the iterator's position.
size_t split(container &ret, const ustring16< TAlloc > &c, bool ignoreEmptyTokens=true, bool keepSeparators=false) const
Split the ustring16 into parts.
_ustring16_iterator_access & operator%=(int val)
_ustring16_iterator(const ustring16< TAlloc > &s)
_ustring16_iterator_access & operator-=(int val)
bool equalsn(const uchar16_t *const str, size_t n) const
ustring16< TAlloc > & insert(const ustring16< TAlloc > &c, size_t pos)
reference operator *() const
Accesses the full character at the iterator's position.
ustring16< TAlloc > & append(const ustring16< TAlloc > &other, size_t length)
const_iterator cbegin() const
ustring16< TAlloc > & append(uchar32_t character)
uchar32_t operator+(int val) const
const_iterator begin() const
const T * c_str() const
Returns character string.
ustring16< TAlloc > & erase_raw(size_t pos)
const u8 BOM_ENCODE_UTF16_BE[2]
_Iter operator-(const difference_type v) const
Return a new iterator that is a variable number of full characters backward from the current position...
uchar16_t swapEndian16(const uchar16_t &c)
unsigned int u32
32 bit unsigned variable.
ustring16(const ustring16< TAlloc > &other)
Constructor.
size_t findFirstChar(const uchar32_t *const c, size_t count=1) const
ustring16(const string< B, A > &other)
Constructor from other string types.
const_reference reference
_ustring16_iterator_access(const ustring16< TAlloc > *s, size_t p)
#define _IRR_DEBUG_BREAK_IF(_CONDITION_)
define a break macro for debugging.
core::array< u8 > getUnicodeBOM(EUTF_ENCODE mode)
pointer operator->()
Accesses the full character at the iterator's position.
pointer operator->()
Accesses the full character at the iterator's position.
ustring16< TAlloc > & insert(uchar32_t c, size_t pos)
string< c8 > stringc
Typedef for character strings.
_ustring16_iterator(const ustring16< TAlloc > &s, const size_t p)
_ustring16_const_iterator _Iter
size_t split(container &ret, const uchar32_t *const c, size_t count=1, bool ignoreEmptyTokens=true, bool keepSeparators=false) const
Split the ustring16 into parts.
ustring16()
Default constructor.
_ustring16_iterator_access & operator *=(int val)
const u8 BOM_UTF8_LEN
The size of the Unicode byte order mark in terms of the Unicode character size.
size_t findLastCharNotInList(const uchar32_t *const c, size_t count=1) const
bool equalsn(const ustring16< TAlloc > &other, size_t n) const
_Base::distance_type distance_type
ustring16(const char c)
Constructor for copying a UTF-8 string from a single char.
ustring16< TAlloc > & operator=(const uchar32_t *const c)
Assignment operator for UTF-32 strings.
uchar32_t toUTF32(uchar16_t high, uchar16_t low)
ustring16< TAlloc > & erase(size_t index)
size_t findLast(uchar32_t c, size_t start=ustring16< TAlloc >::npos) const
_Base::value_type value_type
Self reallocating template array (like stl vector) with additional features.
io::path toPATH_s(const unicode::EUTF_ENDIAN endian=unicode::EUTFEE_NATIVE, const bool addBOM=false) const
_ustring16_iterator_access & operator++()
GLint GLint GLint GLint GLint x
EUTF_ENDIAN
Unicode endianness.
uchar32_t operator *(int val) const
const irr::u16 UTF_REPLACEMENT_CHARACTER
The unicode replacement character. Used to replace invalid characters.
ustring16< TAlloc > & operator=(const B *const c)
Assignment operator for other strings.
ustring16< TAlloc > & append(const uchar32_t *const other, size_t length=0xffffffff)
ustring16< TAlloc > & replace(const ustring16< TAlloc > &toReplace, const ustring16< TAlloc > &replaceWith)
_Iter & operator-=(const difference_type v)
ustring16< TAlloc >::_ustring16_const_iterator const_iterator
size_t findNext(uchar32_t c, size_t startPos) const
ustring16(const uchar16_t *const c)
Constructor for copying a UTF-16 string from a pointer.
ustring16< TAlloc > & replace(uchar32_t toReplace, uchar32_t replaceWith)
const u8 BOM_ENCODE_UTF32_BE[4]
ustring16< TAlloc > & operator=(const uchar8_t *const c)
Assignment operator for UTF-8 strings.
bool operator !=(const uchar16_t *const str) const
Inequality operator.
ustring16< TAlloc > & remove(const ustring16< TAlloc > &toRemove)
_ustring16_const_iterator(const ustring16< TAlloc > &s, const size_t p)
uchar32_t operator-(int val) const
GLboolean GLboolean GLboolean GLboolean a
difference_type operator-(const _Iter &iter) const
Returns the distance between two iterators.
_ustring16_iterator_access & operator+=(int val)
_Iter operator+(const difference_type v) const
Return a new iterator that is a variable number of full characters forward from the current position.
ustring16< TAlloc > & operator=(const uchar16_t *const c)
Assignment operator for UTF-16 strings.
_ustring16_iterator(const _Iter &i)
Constructors.
uchar32_t lastChar() const
size_t findFirstCharNotInList(const uchar32_t *const c, size_t count=1) const
bool operator==(const _Iter &iter) const
Test for equalness.
GLuint GLsizei GLsizei * length
ustring16(const uchar32_t *const c)
Constructor for copying a UTF-32 string from a pointer.
ustring16< TAlloc > subString(size_t begin, size_t length) const
ustring16 & operator=(const ustring16< TAlloc > &other)
Assignment operator.
_Iter & operator+=(const difference_type v)
_ustring16_iterator_access & operator/=(int val)
const u8 BOM_ENCODE_UTF16_LE[2]
ustring16< TAlloc > & append(const uchar8_t *const other, size_t length=0xffffffff)
Access an element in a unicode string, allowing one to change it.
_Base::const_reference const_reference
ustring16< TAlloc > & operator+=(char c)
T * pointer()
Gets a pointer to the array.
uchar32_t operator++(int)
_Base::const_pointer const_pointer
void reserve(size_t count)
const u8 BOM_ENCODE_UTF8_LEN
The size in bytes of the Unicode byte marks for file operations.
const uchar16_t * c_str() const
_ustring16_const_iterator _Base
ustring16< TAlloc > & remove(uchar32_t c)
#define UTF16_IS_SURROGATE(c)
Is a UTF-16 code point a surrogate?
ustring16< TAlloc > operator+(const ustring16< TAlloc > &left, const ustring16< TAlloc > &right)
Appends two ustring16s.
void toEnd()
Moves the iterator to the end of the string.
string< wchar_t > stringw
Typedef for wide character strings.