1 /***********************************************************************
2 filename: CEGUIString.h
6 purpose: Defines string class used within the GUI system.
7 *************************************************************************/
8 /***************************************************************************
9 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
11 * Permission is hereby granted, free of charge, to any person obtaining
12 * a copy of this software and associated documentation files (the
13 * "Software"), to deal in the Software without restriction, including
14 * without limitation the rights to use, copy, modify, merge, publish,
15 * distribute, sublicense, and/or sell copies of the Software, and to
16 * permit persons to whom the Software is furnished to do so, subject to
17 * the following conditions:
19 * The above copyright notice and this permission notice shall be
20 * included in all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
29 ***************************************************************************/
30 #ifndef _CEGUIString_h_
31 #define _CEGUIString_h_
33 #include "CEGUIBase.h"
39 // Start of CEGUI namespace section
42 #define STR_QUICKBUFF_SIZE 32
43 /*************************************************************************
45 *************************************************************************/
47 //typedef uint16 utf16; // removed typedef to prevent usage, as utf16 is not supported (yet)
52 String class used within the GUI system.
54 For the most part, this class can replace std::string in basic usage. However, currently String does not use the
55 current locale, and also comparisons do not take into account the Unicode data tables, so are not 'correct'
58 class CEGUIEXPORT String
61 /*************************************************************************
63 *************************************************************************/
64 typedef utf32 value_type
; //!< Basic 'code point' type used for String (utf32)
65 typedef size_t size_type
; //!< Unsigned type used for size values and indices
66 typedef ptrdiff_t difference_type
; //!< Signed type used for differences
67 typedef utf32
& reference
; //!< Type used for utf32 code point references
68 typedef const utf32
& const_reference
; //!< Type used for constant utf32 code point references
69 typedef utf32
* pointer
; //!< Type used for utf32 code point pointers
70 typedef const utf32
* const_pointer
; //!< Type used for constant utf32 code point pointers
72 static const size_type npos
; //!< Value used to represent 'not found' conditions and 'all code points' etc.
75 /*************************************************************************
77 *************************************************************************/
78 size_type d_cplength
; //!< holds length of string in code points (not including null termination)
79 size_type d_reserve
; //!< code point reserve size (currently allocated buffer size in code points).
81 mutable utf8
* d_encodedbuff
; //!< holds string data encoded as utf8 (generated only by calls to c_str() and data())
82 mutable size_type d_encodeddatlen
; //!< holds length of encoded data (in case it's smaller than buffer).
83 mutable size_type d_encodedbufflen
; //!< length of above buffer (since buffer can be bigger then the data it holds to save re-allocations).
85 utf32 d_quickbuff
[STR_QUICKBUFF_SIZE
]; //!< This is a integrated 'quick' buffer to save allocations for smallish strings
86 utf32
* d_buffer
; //!< Pointer the the main buffer memory. This is only valid when quick-buffer is not being used
89 /*************************************************************************
91 *************************************************************************/
94 Constant forward iterator class for String objects
96 #if defined(_MSC_VER) && (_MSC_VER <= 1200)
97 class const_iterator
: public std::iterator
<std::random_access_iterator_tag
, utf32
>
99 class const_iterator
: public std::iterator
<std::random_access_iterator_tag
, utf32
, std::ptrdiff_t, const utf32
*, const utf32
&>
104 //////////////////////////////////////////////////////////////////////////
106 //////////////////////////////////////////////////////////////////////////
110 //////////////////////////////////////////////////////////////////////////
112 //////////////////////////////////////////////////////////////////////////
117 const_iterator(const_pointer ptr
)
122 const_reference
operator*() const
127 #if defined(_MSC_VER) && (_MSC_VER <= 1200)
128 # pragma warning (push)
129 # pragma warning (disable : 4284)
131 const_pointer
operator->() const
136 #if defined(_MSC_VER) && (_MSC_VER <= 1200)
137 # pragma warning (pop)
140 const_iterator
& operator++()
146 const_iterator
operator++(int)
148 const_iterator temp
= *this;
153 const_iterator
& operator--()
159 const_iterator
operator--(int)
161 const_iterator temp
= *this;
166 const_iterator
& operator+=(difference_type offset
)
172 const_iterator
operator+(difference_type offset
) const
174 const_iterator temp
= *this;
175 return temp
+= offset
;
178 const_iterator
& operator-=(difference_type offset
)
180 return *this += -offset
;
183 const_iterator
operator-(difference_type offset
) const
185 const_iterator temp
= *this;
186 return temp
-= offset
;
189 difference_type
operator-(const const_iterator
& iter
) const
191 return d_ptr
- iter
.d_ptr
;
194 const_reference
operator[](difference_type offset
) const
196 return *(*this + offset
);
199 bool operator==(const const_iterator
& iter
) const
201 return d_ptr
== iter
.d_ptr
;
204 bool operator!=(const const_iterator
& iter
) const
206 return !(*this == iter
);
209 bool operator<(const const_iterator
& iter
) const
211 return d_ptr
< iter
.d_ptr
;
214 bool operator>(const const_iterator
& iter
) const
216 return (!(iter
< *this));
219 bool operator<=(const const_iterator
& iter
) const
221 return (!(iter
< *this));
224 bool operator>=(const const_iterator
& iter
) const
226 return (!(*this < iter
));
229 friend const_iterator
operator+(difference_type offset
, const const_iterator
& iter
)
231 return iter
+ offset
;
238 Forward iterator class for String objects
240 class iterator
: public const_iterator
244 iterator(pointer ptr
) : const_iterator(ptr
) {}
247 reference
operator*() const
249 return ((reference
)**(const_iterator
*)this);
252 #if defined(_MSC_VER) && (_MSC_VER <= 1200)
253 # pragma warning (push)
254 # pragma warning (disable : 4284)
257 pointer
operator->() const
262 #if defined(_MSC_VER) && (_MSC_VER <= 1200)
263 # pragma warning (pop)
266 iterator
& operator++()
272 iterator
operator++(int)
274 iterator temp
= *this;
279 iterator
& operator--()
285 iterator
operator--(int)
287 iterator temp
= *this;
292 iterator
& operator+=(difference_type offset
)
294 this->d_ptr
+= offset
;
298 iterator
operator+(difference_type offset
) const
300 iterator temp
= *this;
301 return temp
+ offset
;
304 iterator
& operator-=(difference_type offset
)
306 return *this += -offset
;
309 iterator
operator-(difference_type offset
) const
311 iterator temp
= *this;
312 return temp
-= offset
;
315 difference_type
operator-(const const_iterator
& iter
) const
317 return ((const_iterator
)*this - iter
);
320 reference
operator[](difference_type offset
) const
322 return *(*this + offset
);
325 friend iterator
operator+(difference_type offset
, const iterator
& iter
)
327 return iter
+ offset
;
334 Constant reverse iterator class for String objects
336 #if defined(_MSC_VER) && ((_MSC_VER <= 1200) || ((_MSC_VER <= 1300) && defined(_STLPORT_VERSION)))
337 typedef std::reverse_iterator
<const_iterator
, const_pointer
, const_reference
, difference_type
> const_reverse_iterator
;
339 typedef std::reverse_iterator
<const_iterator
> const_reverse_iterator
;
344 Reverse iterator class for String objects
346 #if defined(_MSC_VER) && ((_MSC_VER <= 1200) || ((_MSC_VER <= 1300) && defined(_STLPORT_VERSION)))
347 typedef std::reverse_iterator
<iterator
, pointer
, reference
, difference_type
> reverse_iterator
;
349 typedef std::reverse_iterator
<iterator
> reverse_iterator
;
355 Functor that can be used as comparator in a std::map with String keys.
356 It's faster than using the default, but the map will no longer be sorted alphabetically.
358 struct FastLessCompare
360 bool operator() (const String
& a
, const String
& b
) const
362 const size_t la
= a
.length();
363 const size_t lb
= b
.length();
365 return (memcmp(a
.ptr(), b
.ptr(), la
*sizeof(utf32
)) < 0);
371 //////////////////////////////////////////////////////////////////////////
372 // Default Construction and Destructor
373 //////////////////////////////////////////////////////////////////////////
376 Constructs an empty string
385 Destructor for String objects
389 //////////////////////////////////////////////////////////////////////////
390 // Construction via CEGUI::String
391 //////////////////////////////////////////////////////////////////////////
394 Copy constructor - Creates a new string with the same value as \a str
397 String object used to initialise the newly created string
402 String(const String
& str
)
411 Constructs a new string initialised with code points from another String object.
414 String object used to initialise the newly created string
417 Starting code-point of \a str to be used when initialising the new String
420 Maximum number of code points from \a str that are to be assigned to the new String
425 String(const String
& str
, size_type str_idx
, size_type str_num
= npos
)
428 assign(str
, str_idx
, str_num
);
431 //////////////////////////////////////////////////////////////////////////
432 // Construction via std::string
433 //////////////////////////////////////////////////////////////////////////
436 Constructs a new string and initialises it using the std::string std_str
439 The std::string object that is to be used to initialise the new String object.
442 The characters of \a std_str are taken to be unencoded data which represent Unicode code points 0x00..0xFF. No translation of
443 the provided data will occur.
448 \exception std::length_error Thrown if resulting String object would be too big.
450 String(const std::string
& std_str
)
458 Constructs a new string initialised with characters from the given std::string object.
461 std::string object used to initialise the newly created string
464 Starting character of \a std_str to be used when initialising the new String
467 The characters of \a std_str are taken to be unencoded data which represent Unicode code points 0x00..0xFF. No translation of
468 the provided data will occur.
471 Maximum number of characters from \a std_str that are to be assigned to the new String
476 \exception std::length_error Thrown if resulting String object would be too big.
478 String(const std::string
& std_str
, size_type str_idx
, size_type str_num
= npos
)
481 assign(std_str
, str_idx
, str_num
);
485 //////////////////////////////////////////////////////////////////////////
486 // Construction via UTF-8 stream (for straight ASCII use, only codes 0x00 - 0x7f are valid)
487 //////////////////////////////////////////////////////////////////////////
490 Constructs a new String object and initialise it using the provided utf8 encoded string buffer.
493 Pointer to a buffer containing a null-terminated Unicode string encoded as utf8 data.
496 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
497 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
498 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
504 \exception std::length_error Thrown if resulting String object would be too big.
506 String(const utf8
* utf8_str
)
514 Constructs a new String object and initialise it using the provided utf8 encoded string buffer.
516 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
517 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
518 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
522 Pointer to a buffer containing Unicode string data encoded as utf8.
525 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
526 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
527 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
531 Length of the provided utf8 string in code units (not code-points).
536 \exception std::length_error Thrown if resulting String object would be too big.
538 String(const utf8
* utf8_str
, size_type chars_len
)
541 assign(utf8_str
, chars_len
);
544 //////////////////////////////////////////////////////////////////////////
545 // Construction via code-point (using a UTF-32 code unit)
546 //////////////////////////////////////////////////////////////////////////
549 Constructs a new String that is initialised with the specified code point
552 The number of times \a code_point is to be put into new String object
555 The Unicode code point to be used when initialising the String object
560 \exception std::length_error Thrown if resulting String object would be too big.
562 String(size_type num
, utf32 code_point
)
565 assign(num
, code_point
);
568 //////////////////////////////////////////////////////////////////////////
569 // Construction via iterator
570 //////////////////////////////////////////////////////////////////////////
571 // Create string with characters in the range [beg, end)
574 Construct a new string object and initialise it with code-points from the range [beg, end).
577 Iterator describing the start of the data to be used when initialising the String object
580 Iterator describing the (exclusive) end of the data to be used when initialising the String object
585 String(const_iterator iter_beg
, const_iterator iter_end
)
588 append(iter_beg
, iter_end
);
592 //////////////////////////////////////////////////////////////////////////
593 // Construction via c-string
594 //////////////////////////////////////////////////////////////////////////
597 Constructs a new String object and initialise it using the provided c-string.
600 Pointer to a c-string.
605 \exception std::length_error Thrown if resulting String object would be too big.
607 String(const char* cstr
)
615 Constructs a new String object and initialise it using characters from the provided char array.
621 Number of chars from the array to be used.
626 \exception std::length_error Thrown if resulting String object would be too big.
628 String(const char* chars
, size_type chars_len
)
631 assign(chars
, chars_len
);
635 //////////////////////////////////////////////////////////////////////////
637 //////////////////////////////////////////////////////////////////////////
640 Returns the size of the String in code points
643 Number of code points currently in the String
645 size_type
size(void) const
652 Returns the size of the String in code points
655 Number of code points currently in the String
657 size_type
length(void) const
664 Returns true if the String is empty
667 true if the String is empty, else false.
669 bool empty(void) const
671 return (d_cplength
== 0);
676 Returns the maximum size of a String.
678 Any operation that would result in a String that is larger than this value will throw the std::length_error exception.
681 The maximum number of code points that a string can contain
683 static size_type
max_size(void)
685 return (((size_type
)-1) / sizeof(utf32
));
688 //////////////////////////////////////////////////////////////////////////
689 // Capacity Operations
690 //////////////////////////////////////////////////////////////////////////
691 // return the number of code points the string could hold without re-allocation
692 // (due to internal encoding this will always report the figure for worst-case encoding, and could even be < size()!)
695 Return the number of code points that the String could hold before a re-allocation would be required.
698 Size of the current reserve buffer. This is the maximum number of code points the String could hold before a buffer
699 re-allocation would be required
701 size_type
capacity(void) const
703 return d_reserve
- 1;
706 // reserve internal memory for at-least 'num' code-points (characters). if num is 0, request is shrink-to-fit.
709 Specifies the amount of reserve capacity to allocate.
712 The number of code points to allocate space for. If \a num is larger that the current reserve, then a re-allocation will occur. If
713 \a num is smaller than the current reserve (but not 0) the buffer may be shrunk to the larger of the specified number, or the current
714 String size (operation is currently not implemented). If \a num is 0, then the buffer is re-allocated to fit the current String size.
719 \exception std::length_error Thrown if resulting String object would be too big.
721 void reserve(size_type num
= 0)
729 //////////////////////////////////////////////////////////////////////////
731 //////////////////////////////////////////////////////////////////////////
734 Compares this String with the String 'str'.
737 This does currently not properly consider Unicode and / or the system locale.
740 The String object that is to compared with this String.
743 - 0 if the String objects are equal
744 - <0 if this String is lexicographically smaller than \a str
745 - >0 if this String is lexicographically greater than \a str
747 int compare(const String
& str
) const
749 return compare(0, d_cplength
, str
);
754 Compares code points from this String with code points from the String 'str'.
757 This does currently not properly consider Unicode and / or the system locale.
760 Index of the first code point from this String to consider.
763 Maximum number of code points from this String to consider.
766 The String object that is to compared with this String.
769 Index of the first code point from String \a str to consider.
772 Maximum number of code points from String \a str to consider
775 - 0 if the specified sub-strings are equal
776 - <0 if specified sub-strings are lexicographically smaller than \a str
777 - >0 if specified sub-strings are lexicographically greater than \a str
779 \exception std::out_of_range Thrown if either \a idx or \a str_idx are invalid.
781 int compare(size_type idx
, size_type len
, const String
& str
, size_type str_idx
= 0, size_type str_len
= npos
) const
783 if ((d_cplength
< idx
) || (str
.d_cplength
< str_idx
))
784 throw std::out_of_range("Index is out of range for CEGUI::String");
786 if ((len
== npos
) || (idx
+ len
> d_cplength
))
787 len
= d_cplength
- idx
;
789 if ((str_len
== npos
) || (str_idx
+ str_len
> str
.d_cplength
))
790 str_len
= str
.d_cplength
- str_idx
;
792 int val
= (len
== 0) ? 0 : utf32_comp_utf32(&ptr()[idx
], &str
.ptr()[str_idx
], (len
< str_len
) ? len
: str_len
);
794 return (val
!= 0) ? ((val
< 0) ? -1 : 1) : (len
< str_len
) ? -1 : (len
== str_len
) ? 0 : 1;
800 Compares this String with the std::string 'std_str'.
803 This does currently not properly consider Unicode and / or the system locale.
806 The std::string object that is to compared with this String.
809 Characters from \a std_str are considered to represent Unicode code points in the range 0x00..0xFF. No translation of
810 the encountered data is performed.
813 - 0 if the string objects are equal
814 - <0 if this string is lexicographically smaller than \a std_str
815 - >0 if this string is lexicographically greater than \a std_str
817 int compare(const std::string
& std_str
) const
819 return compare(0, d_cplength
, std_str
);
825 Compares code points from this String with code points from the std::string 'std_str'.
828 This does currently not properly consider Unicode and / or the system locale.
831 Index of the first code point from this String to consider.
834 Maximum number of code points from this String to consider.
837 The std::string object that is to compared with this String.
840 Characters from \a std_str are considered to represent Unicode code points in the range 0x00..0xFF. No translation of
841 the encountered data is performed.
844 Index of the first character from std::string \a std_str to consider.
847 Maximum number of characters from std::string \a std_str to consider
850 - 0 if the specified sub-strings are equal
851 - <0 if specified sub-strings are lexicographically smaller than \a std_str
852 - >0 if specified sub-strings are lexicographically greater than \a std_str
854 \exception std::out_of_range Thrown if either \a idx or \a str_idx are invalid.
856 int compare(size_type idx
, size_type len
, const std::string
& std_str
, size_type str_idx
= 0, size_type str_len
= npos
) const
858 if (d_cplength
< idx
)
859 throw std::out_of_range("Index is out of range for CEGUI::String");
861 if (std_str
.size() < str_idx
)
862 throw std::out_of_range("Index is out of range for std::string");
864 if ((len
== npos
) || (idx
+ len
> d_cplength
))
865 len
= d_cplength
- idx
;
867 if ((str_len
== npos
) || (str_idx
+ str_len
> std_str
.size()))
868 str_len
= (size_type
)std_str
.size() - str_idx
;
870 int val
= (len
== 0) ? 0 : utf32_comp_char(&ptr()[idx
], &std_str
.c_str()[str_idx
], (len
< str_len
) ? len
: str_len
);
872 return (val
!= 0) ? ((val
< 0) ? -1 : 1) : (len
< str_len
) ? -1 : (len
== str_len
) ? 0 : 1;
878 Compares this String with the null-terminated utf8 encoded 'utf8_str'.
881 This does currently not properly consider Unicode and / or the system locale.
884 The buffer containing valid Unicode data encoded as utf8 that is to compared with this String.
887 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
888 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
889 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
893 - 0 if the strings are equal
894 - <0 if this string is lexicographically smaller than \a utf8_str
895 - >0 if this string is lexicographically greater than \a utf8_str
897 int compare(const utf8
* utf8_str
) const
899 return compare(0, d_cplength
, utf8_str
, encoded_size(utf8_str
));
905 Compares code points from this String with the null-terminated utf8 encoded 'utf8_str'.
908 This does currently not properly consider Unicode and / or the system locale.
911 Index of the first code point from this String to consider.
914 Maximum number of code points from this String to consider.
917 The buffer containing valid Unicode data encoded as utf8 that is to compared with this String.
920 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
921 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
922 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
926 - 0 if the specified sub-strings are equal
927 - <0 if specified sub-strings are lexicographically smaller than \a utf8_str
928 - >0 if specified sub-strings are lexicographically greater than \a utf8_str
930 \exception std::out_of_range Thrown if \a idx is invalid.
932 int compare(size_type idx
, size_type len
, const utf8
* utf8_str
) const
934 return compare(idx
, len
, utf8_str
, encoded_size(utf8_str
));
939 Compares code points from this String with the utf8 encoded data in buffer 'utf8_str'.
942 This does currently not properly consider Unicode and / or the system locale.
945 Index of the first code point from this String to consider.
948 Maximum number of code points from this String to consider.
951 The buffer containing valid Unicode data encoded as utf8 that is to compared with this String.
954 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
955 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
956 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
960 The number of encoded code points in the buffer \a utf8_str (this is not the same as the number of code units).
963 - 0 if the specified sub-strings are equal
964 - <0 if specified sub-strings are lexicographically smaller than \a utf8_str
965 - >0 if specified sub-strings are lexicographically greater than \a utf8_str
967 \exception std::out_of_range Thrown if \a idx is invalid.
968 \exception std::length_error Thrown if \a str_cplen is set to npos.
970 int compare(size_type idx
, size_type len
, const utf8
* utf8_str
, size_type str_cplen
) const
972 if (d_cplength
< idx
)
973 throw std::out_of_range("Index is out of range for CEGUI::String");
975 if (str_cplen
== npos
)
976 throw std::length_error("Length for utf8 encoded string can not be 'npos'");
978 if ((len
== npos
) || (idx
+ len
> d_cplength
))
979 len
= d_cplength
- idx
;
981 int val
= (len
== 0) ? 0 : utf32_comp_utf8(&ptr()[idx
], utf8_str
, (len
< str_cplen
) ? len
: str_cplen
);
983 return (val
!= 0) ? ((val
< 0) ? -1 : 1) : (len
< str_cplen
) ? -1 : (len
== str_cplen
) ? 0 : 1;
989 Compares this String with the given c-string.
992 This does currently not properly consider Unicode and / or the system locale.
995 The c-string that is to compared with this String.
998 - 0 if the strings are equal
999 - <0 if this string is lexicographically smaller than \a c_str
1000 - >0 if this string is lexicographically greater than \a c_str
1002 int compare(const char* cstr
) const
1004 return compare(0, d_cplength
, cstr
, strlen(cstr
));
1010 Compares code points from this String with the given c-string.
1013 This does currently not properly consider Unicode and / or the system locale.
1016 Index of the first code point from this String to consider.
1019 Maximum number of code points from this String to consider.
1022 The c-string that is to compared with this String.
1025 - 0 if the specified sub-strings are equal
1026 - <0 if specified sub-strings are lexicographically smaller than \a c_str
1027 - >0 if specified sub-strings are lexicographically greater than \a c_str
1029 \exception std::out_of_range Thrown if \a idx is invalid.
1031 int compare(size_type idx
, size_type len
, const char* cstr
) const
1033 return compare(idx
, len
, cstr
, strlen(cstr
));
1039 Compares code points from this String with chars in the given char array.
1042 This does currently not properly consider Unicode and / or the system locale.
1045 Index of the first code point from this String to consider.
1048 Maximum number of code points from this String to consider.
1051 The array containing the chars that are to compared with this String.
1054 The number of chars in the array.
1057 - 0 if the specified sub-strings are equal
1058 - <0 if specified sub-strings are lexicographically smaller than \a chars
1059 - >0 if specified sub-strings are lexicographically greater than \a chars
1061 \exception std::out_of_range Thrown if \a idx is invalid.
1062 \exception std::length_error Thrown if \a chars_len is set to npos.
1064 int compare(size_type idx
, size_type len
, const char* chars
, size_type chars_len
) const
1066 if (d_cplength
< idx
)
1067 throw std::out_of_range("Index is out of range for CEGUI::String");
1069 if (chars_len
== npos
)
1070 throw std::length_error("Length for char array can not be 'npos'");
1072 if ((len
== npos
) || (idx
+ len
> d_cplength
))
1073 len
= d_cplength
- idx
;
1075 int val
= (len
== 0) ? 0 : utf32_comp_char(&ptr()[idx
], chars
, (len
< chars_len
) ? len
: chars_len
);
1077 return (val
!= 0) ? ((val
< 0) ? -1 : 1) : (len
< chars_len
) ? -1 : (len
== chars_len
) ? 0 : 1;
1081 //////////////////////////////////////////////////////////////////////////
1083 //////////////////////////////////////////////////////////////////////////
1086 Returns the code point at the given index.
1089 Zero based index of the code point to be returned.
1092 - For constant strings length()/size() provide a valid index and will access the default utf32 value.
1093 - For non-constant strings length()/size() is an invalid index, and acceesing (especially writing) this index could cause string corruption.
1096 The utf32 code point at the given index within the String.
1098 reference
operator[](size_type idx
)
1100 return (ptr()[idx
]);
1105 Returns the code point at the given index.
1108 Zero based index of the code point to be returned.
1111 - For constant strings length()/size() provide a valid index and will access the default utf32 value.
1112 - For non-constant strings length()/size() is an invalid index, and acceesing (especially writing) this index could cause string corruption.
1115 The utf32 code point at the given index within the String.
1117 value_type
operator[](size_type idx
) const
1124 Returns the code point at the given index.
1127 Zero based index of the code point to be returned.
1130 The utf32 code point at the given index within the String.
1132 \exception std::out_of_range Thrown if \a idx is >= length().
1134 reference
at(size_type idx
)
1136 if (d_cplength
<= idx
)
1137 throw std::out_of_range("Index is out of range for CEGUI::String");
1144 Returns the code point at the given index.
1147 Zero based index of the code point to be returned.
1150 The utf32 code point at the given index within the String.
1152 \exception std::out_of_range Thrown if \a idx is >= length().
1154 const_reference
at(size_type idx
) const
1156 if (d_cplength
<= idx
)
1157 throw std::out_of_range("Index is out of range for CEGUI::String");
1163 //////////////////////////////////////////////////////////////////////////
1164 // C-Strings and arrays
1165 //////////////////////////////////////////////////////////////////////////
1168 Returns contents of the String as a null terminated string of utf8 encoded data.
1171 Pointer to a char buffer containing the contents of the String encoded as null-terminated utf8 data.
1174 The buffer returned from this function is owned by the String object.
1177 Any function that modifies the String data will invalidate the buffer returned by this call.
1179 const char* c_str(void) const
1181 return (const char*)build_utf8_buff();
1186 Returns contents of the String as utf8 encoded data.
1189 Pointer to a buffer containing the contents of the String encoded utf8 data.
1192 The buffer returned from this function is owned by the String object.
1195 Any function that modifies the String data will invalidate the buffer returned by this call.
1197 const utf8
* data(void) const
1199 return build_utf8_buff();
1204 Returns a pointer to the buffer in use.
1208 return (d_reserve
> STR_QUICKBUFF_SIZE
) ? d_buffer
: d_quickbuff
;
1213 Returns a pointer to the buffer in use. (const version)
1215 const utf32
* ptr(void) const
1217 return (d_reserve
> STR_QUICKBUFF_SIZE
) ? d_buffer
: d_quickbuff
;
1220 // copy, at most, 'len' code-points of the string, begining with code-point 'idx', into the array 'buf' as valid utf8 encoded data
1221 // return number of utf8 code units placed into the buffer
1224 Copies an area of the String into the provided buffer as encoded utf8 data.
1227 Pointer to a buffer that is to receive the encoded data (this must be big enough to hold the encoded data)
1230 Maximum number of code points from the String that should be encoded into the buffer
1233 Index of the first code point to be encoded into the buffer
1236 The number of utf8 encoded code units transferred to the buffer.
1238 \note A code unit does not equal a code point. A utf32 code point, when encoded as utf8, can occupy between 1 and 4 code units.
1240 \exception std::out_of_range Thrown if \a idx was invalid for this String.
1242 size_type
copy(utf8
* buf
, size_type len
= npos
, size_type idx
= 0) const
1244 if (d_cplength
< idx
)
1245 throw std::out_of_range("Index is out of range for CEGUI::String");
1250 return encode(&ptr()[idx
], buf
, npos
, len
);
1253 //////////////////////////////////////////////////////////////////////////
1254 // UTF8 Encoding length information
1255 //////////////////////////////////////////////////////////////////////////
1256 // return the number of bytes required to hold 'num' code-points, starting at code-point 'idx', of the the string when encoded as utf8 data.
1259 Return the number of utf8 code units required to hold an area of the String when encoded as utf8 data
1262 Maximum number of code points to consider when calculating utf8 encoded size.
1265 Index of the first code point to consider when calculating the utf8 encoded size
1268 The number of utf8 code units (bytes) required to hold the specified sub-string when encoded as utf8 data.
1270 \exception std::out_of_range Thrown if \a idx was invalid for this String.
1272 size_type
utf8_stream_len(size_type num
= npos
, size_type idx
= 0) const
1274 using namespace std
;
1276 if (d_cplength
< idx
)
1277 throw out_of_range("Index was out of range for CEGUI::String object");
1279 size_type maxlen
= d_cplength
- idx
;
1281 return encoded_size(&ptr()[idx
], ceguimin(num
, maxlen
));
1284 //////////////////////////////////////////////////////////////////////////
1285 // Assignment Functions
1286 //////////////////////////////////////////////////////////////////////////
1289 Assign the value of String \a str to this String
1292 String object containing the string value to be assigned.
1295 This String after the assignment has happened
1297 String
& operator=(const String
& str
)
1304 Assign a sub-string of String \a str to this String
1307 String object containing the string data to be assigned.
1310 Index of the first code point in \a str that is to be assigned
1313 Maximum number of code points from \a str that are be be assigned
1316 This String after the assignment has happened
1318 \exception std::out_of_range Thrown if str_idx is invalid for \a str
1320 String
& assign(const String
& str
, size_type str_idx
= 0, size_type str_num
= npos
)
1322 if (str
.d_cplength
< str_idx
)
1323 throw std::out_of_range("Index was out of range for CEGUI::String object");
1325 if ((str_num
== npos
) || (str_num
> str
.d_cplength
- str_idx
))
1326 str_num
= str
.d_cplength
- str_idx
;
1330 memcpy(ptr(), &str
.ptr()[str_idx
], str_num
* sizeof(utf32
));
1337 Assign the value of std::string \a std_str to this String
1340 The characters of \a std_str are taken to be unencoded data which represent Unicode code points 0x00..0xFF. No translation of
1341 the provided data will occur.
1344 std::string object containing the string value to be assigned.
1347 This String after the assignment has happened
1349 \exception std::length_error Thrown if the resulting String would have been too large.
1351 String
& operator=(const std::string
& std_str
)
1353 return assign(std_str
);
1358 Assign a sub-string of std::string \a std_str to this String
1361 The characters of \a std_str are taken to be unencoded data which represent Unicode code points 0x00..0xFF. No translation of
1362 the provided data will occur.
1365 std::string object containing the string value to be assigned.
1368 Index of the first character of \a std_str to be assigned
1371 Maximum number of characters from \a std_str to be assigned
1374 This String after the assignment has happened
1376 \exception std::out_of_range Thrown if \a str_idx is invalid for \a std_str
1377 \exception std::length_error Thrown if the resulting String would have been too large.
1379 String
& assign(const std::string
& std_str
, size_type str_idx
= 0, size_type str_num
= npos
)
1381 if (std_str
.size() < str_idx
)
1382 throw std::out_of_range("Index was out of range for std::string object");
1384 if ((str_num
== npos
) || (str_num
> (size_type
)std_str
.size() - str_idx
))
1385 str_num
= (size_type
)std_str
.size() - str_idx
;
1392 ((*this)[str_num
]) = static_cast<utf32
>(static_cast<unsigned char>(std_str
[str_num
+ str_idx
]));
1400 Assign to this String the string value represented by the given null-terminated utf8 encoded data
1403 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
1404 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
1405 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
1409 Buffer containing valid null-terminated utf8 encoded data
1412 This String after the assignment has happened
1414 \exception std::length_error Thrown if the resulting String would have been too large.
1416 String
& operator=(const utf8
* utf8_str
)
1418 return assign(utf8_str
, utf_length(utf8_str
));
1423 Assign to this String the string value represented by the given null-terminated utf8 encoded data
1426 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
1427 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
1428 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
1432 Buffer containing valid null-terminated utf8 encoded data
1435 This String after the assignment has happened
1437 \exception std::length_error Thrown if the resulting String would have been too large.
1439 String
& assign(const utf8
* utf8_str
)
1441 return assign(utf8_str
, utf_length(utf8_str
));
1446 Assign to this String the string value represented by the given utf8 encoded data
1449 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
1450 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
1451 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
1455 Buffer containing valid utf8 encoded data
1458 Number of code units (not code points) in the buffer pointed to by \a utf8_str
1461 This String after the assignment has happened
1463 \exception std::length_error Thrown if the resulting String would have been too large, or if str_num is 'npos'.
1465 String
& assign(const utf8
* utf8_str
, size_type str_num
)
1467 if (str_num
== npos
)
1468 throw std::length_error("Length for utf8 encoded string can not be 'npos'");
1470 size_type enc_sze
= encoded_size(utf8_str
, str_num
);
1473 encode(utf8_str
, ptr(), d_reserve
, str_num
);
1480 Assigns the specified utf32 code point to this String. Result is always a String 1 code point in length.
1483 Valid utf32 Unicode code point to be assigned to the string
1486 This String after assignment
1488 String
& operator=(utf32 code_point
)
1490 return assign(1, code_point
);
1495 Assigns the specified code point repeatedly to the String
1498 The number of times to assign the code point
1501 Valid utf32 Unicode code point to be assigned to the string
1504 This String after assignment.
1506 \exception std::length_error Thrown if \a num was 'npos'
1508 String
& assign(size_type num
, utf32 code_point
)
1511 throw std::length_error("Code point count can not be 'npos'");
1526 Assign to this String the given C-string.
1529 Pointer to a valid C style string.
1532 This String after the assignment has happened
1534 \exception std::length_error Thrown if the resulting String would have been too large.
1536 String
& operator=(const char* cstr
)
1538 return assign(cstr
, strlen(cstr
));
1544 Assign to this String the given C-string.
1547 Pointer to a valid C style string.
1550 This String after the assignment has happened
1552 \exception std::length_error Thrown if the resulting String would have been too large.
1554 String
& assign(const char* cstr
)
1556 return assign(cstr
, strlen(cstr
));
1562 Assign to this String a number of chars from a char array.
1568 Number of chars to be assigned.
1571 This String after the assignment has happened
1573 \exception std::length_error Thrown if the resulting String would have been too large.
1575 String
& assign(const char* chars
, size_type chars_len
)
1580 for (size_type i
= 0; i
< chars_len
; ++i
)
1582 *pt
++ = static_cast<utf32
>(static_cast<unsigned char>(*chars
++));
1592 Swaps the value of this String with the given String \a str
1595 String object whos value is to be swapped with this String.
1600 void swap(String
& str
)
1602 size_type temp_len
= d_cplength
;
1603 d_cplength
= str
.d_cplength
;
1604 str
.d_cplength
= temp_len
;
1606 size_type temp_res
= d_reserve
;
1607 d_reserve
= str
.d_reserve
;
1608 str
.d_reserve
= temp_res
;
1610 utf32
* temp_buf
= d_buffer
;
1611 d_buffer
= str
.d_buffer
;
1612 str
.d_buffer
= temp_buf
;
1614 // see if we need to swap 'quick buffer' data
1615 if (temp_res
<= STR_QUICKBUFF_SIZE
)
1617 utf32 temp_qbf
[STR_QUICKBUFF_SIZE
];
1619 memcpy(temp_qbf
, d_quickbuff
, STR_QUICKBUFF_SIZE
* sizeof(utf32
));
1620 memcpy(d_quickbuff
, str
.d_quickbuff
, STR_QUICKBUFF_SIZE
* sizeof(utf32
));
1621 memcpy(str
.d_quickbuff
, temp_qbf
, STR_QUICKBUFF_SIZE
* sizeof(utf32
));
1626 //////////////////////////////////////////////////////////////////////////
1627 // Appending Functions
1628 //////////////////////////////////////////////////////////////////////////
1631 Appends the String \a str
1634 String object that is to be appended
1637 This String after the append operation
1639 \exception std::length_error Thrown if resulting String would be too large.
1641 String
& operator+=(const String
& str
)
1648 Appends a sub-string of the String \a str
1651 String object containing data to be appended
1654 Index of the first code point to be appended
1657 Maximum number of code points to be appended
1660 This String after the append operation
1662 \exception std::out_of_range Thrown if \a str_idx is invalid for \a str.
1663 \exception std::length_error Thrown if resulting String would be too large.
1665 String
& append(const String
& str
, size_type str_idx
= 0, size_type str_num
= npos
)
1667 if (str
.d_cplength
< str_idx
)
1668 throw std::out_of_range("Index is out of range for CEGUI::String");
1670 if ((str_num
== npos
) || (str_num
> str
.d_cplength
- str_idx
))
1671 str_num
= str
.d_cplength
- str_idx
;
1673 grow(d_cplength
+ str_num
);
1674 memcpy(&ptr()[d_cplength
], &str
.ptr()[str_idx
], str_num
* sizeof(utf32
));
1675 setlen(d_cplength
+ str_num
);
1682 Appends the std::string \a std_str
1685 std::string object that is to be appended
1688 The characters of \a std_str are taken to be unencoded data which represent Unicode code points 0x00..0xFF. No translation of
1689 the provided data will occur.
1692 This String after the append operation
1694 \exception std::length_error Thrown if resulting String would be too large.
1696 String
& operator+=(const std::string
& std_str
)
1698 return append(std_str
);
1703 Appends a sub-string of the std::string \a std_str
1706 std::string object containing data to be appended
1709 The characters of \a std_str are taken to be unencoded data which represent Unicode code points 0x00..0xFF. No translation of
1710 the provided data will occur.
1713 Index of the first character to be appended
1716 Maximum number of characters to be appended
1719 This String after the append operation
1721 \exception std::out_of_range Thrown if \a str_idx is invalid for \a std_str.
1722 \exception std::length_error Thrown if resulting String would be too large.
1724 String
& append(const std::string
& std_str
, size_type str_idx
= 0, size_type str_num
= npos
)
1726 if (std_str
.size() < str_idx
)
1727 throw std::out_of_range("Index is out of range for std::string");
1729 if ((str_num
== npos
) || (str_num
> (size_type
)std_str
.size() - str_idx
))
1730 str_num
= (size_type
)std_str
.size() - str_idx
;
1732 size_type newsze
= d_cplength
+ str_num
;
1735 utf32
* pt
= &ptr()[newsze
-1];
1738 *pt
-- = static_cast<utf32
>(static_cast<unsigned char>(std_str
[str_num
]));
1747 Appends to the String the null-terminated utf8 encoded data in the buffer utf8_str.
1750 buffer holding the null-terminated utf8 encoded data that is to be appended
1753 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
1754 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
1755 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
1759 This String after the append operation
1761 \exception std::length_error Thrown if resulting String would be too large.
1763 String
& operator+=(const utf8
* utf8_str
)
1765 return append(utf8_str
, utf_length(utf8_str
));
1770 Appends to the String the null-terminated utf8 encoded data in the buffer utf8_str.
1773 Buffer holding the null-terminated utf8 encoded data that is to be appended
1776 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
1777 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
1778 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
1782 This String after the append operation
1784 \exception std::length_error Thrown if resulting String would be too large.
1786 String
& append(const utf8
* utf8_str
)
1788 return append(utf8_str
, utf_length(utf8_str
));
1794 Appends to the String the utf8 encoded data in the buffer utf8_str.
1797 Buffer holding the utf8 encoded data that is to be appended
1800 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
1801 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
1802 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
1806 Number of code units (not code points) in the buffer to be appended
1809 This String after the append operation
1811 \exception std::length_error Thrown if resulting String would be too large, or if \a len was 'npos'
1813 String
& append(const utf8
* utf8_str
, size_type len
)
1816 throw std::length_error("Length for utf8 encoded string can not be 'npos'");
1818 size_type encsz
= encoded_size(utf8_str
, len
);
1819 size_type newsz
= d_cplength
+ encsz
;
1822 encode(utf8_str
, &ptr()[d_cplength
], encsz
, len
);
1831 Appends a single code point to the string
1834 utf32 Unicode code point that is to be appended
1837 This String after the append operation
1839 \exception std::length_error Thrown if resulting String would be too long.
1841 String
& operator+=(utf32 code_point
)
1843 return append(1, code_point
);
1848 Appends a single code point multiple times to the string
1851 Number of copies of the code point to be appended
1854 utf32 Unicode code point that is to be appended
1857 This String after the append operation
1859 \exception std::length_error Thrown if resulting String would be too long, or if \a num was 'npos'.
1861 String
& append(size_type num
, utf32 code_point
)
1864 throw std::length_error("Code point count can not be 'npos'");
1866 size_type newsz
= d_cplength
+ num
;
1869 utf32
* p
= &ptr()[d_cplength
];
1881 Appends a single code point to the string
1884 utf32 Unicode code point that is to be appended
1889 \exception std::length_error Thrown if resulting String would be too long.
1891 void push_back(utf32 code_point
)
1893 append(1, code_point
);
1898 Appends the code points in the reange [beg, end)
1901 Iterator describing the start of the range to be appended
1904 Iterator describing the (exclusive) end of the range to be appended.
1907 This String after the append operation
1909 \exception std::length_error Thrown if the resulting string would be too large.
1911 String
& append(const_iterator iter_beg
, const_iterator iter_end
)
1913 return replace(end(), end(), iter_beg
, iter_end
);
1919 Appends to the String the given c-string.
1922 c-string that is to be appended.
1925 This String after the append operation
1927 \exception std::length_error Thrown if resulting String would be too large.
1929 String
& operator+=(const char* cstr
)
1931 return append(cstr
, strlen(cstr
));
1937 Appends to the String the given c-string.
1940 c-string that is to be appended.
1943 This String after the append operation
1945 \exception std::length_error Thrown if resulting String would be too large.
1947 String
& append(const char* cstr
)
1949 return append(cstr
, strlen(cstr
));
1955 Appends to the String chars from the given char array.
1958 char array holding the chars that are to be appended
1961 Number of chars to be appended
1964 This String after the append operation
1966 \exception std::length_error Thrown if resulting String would be too large, or if \a chars_len was 'npos'
1968 String
& append(const char* chars
, size_type chars_len
)
1970 if (chars_len
== npos
)
1971 throw std::length_error("Length for char array can not be 'npos'");
1973 size_type newsz
= d_cplength
+ chars_len
;
1977 utf32
* pt
= &ptr()[newsz
-1];
1980 *pt
-- = static_cast<utf32
>(static_cast<unsigned char>(chars
[chars_len
]));
1988 //////////////////////////////////////////////////////////////////////////
1989 // Insertion Functions
1990 //////////////////////////////////////////////////////////////////////////
1993 Inserts the given String object at the specified position.
1996 Index where the string is to be inserted.
1999 String object that is to be inserted.
2002 This String after the insert.
2004 \exception std::out_of_range Thrown if \a idx is invalid for this String.
2005 \exception std::length_error Thrown if resulting String would be too large.
2007 String
& insert(size_type idx
, const String
& str
)
2009 return insert(idx
, str
, 0, npos
);
2014 Inserts a sub-string of the given String object at the specified position.
2017 Index where the string is to be inserted.
2020 String object containing data to be inserted.
2023 Index of the first code point from \a str to be inserted.
2026 Maximum number of code points from \a str to be inserted.
2029 This String after the insert.
2031 \exception std::out_of_range Thrown if \a idx or \a str_idx are out of range.
2032 \exception std::length_error Thrown if resulting String would be too large.
2034 String
& insert(size_type idx
, const String
& str
, size_type str_idx
, size_type str_num
)
2036 if ((d_cplength
< idx
) || (str
.d_cplength
< str_idx
))
2037 throw std::out_of_range("Index is out of range for CEGUI::String");
2039 if ((str_num
== npos
) || (str_num
> str
.d_cplength
- str_idx
))
2040 str_num
= str
.d_cplength
- str_idx
;
2042 size_type newsz
= d_cplength
+ str_num
;
2044 memmove(&ptr()[idx
+ str_num
], &ptr()[idx
], (d_cplength
- idx
) * sizeof(utf32
));
2045 memcpy(&ptr()[idx
], &str
.ptr()[str_idx
], str_num
* sizeof(utf32
));
2053 Inserts the given std::string object at the specified position.
2056 Index where the std::string is to be inserted.
2059 std::string object that is to be inserted.
2062 The characters of \a std_str are taken to be unencoded data which represent Unicode code points 0x00..0xFF. No translation of
2063 the provided data will occur.
2066 This String after the insert.
2068 \exception std::out_of_range Thrown if \a idx is invalid for this String.
2069 \exception std::length_error Thrown if resulting String would be too large.
2071 String
& insert(size_type idx
, const std::string
& std_str
)
2073 return insert(idx
, std_str
, 0, npos
);
2078 Inserts a sub-string of the given std::string object at the specified position.
2081 Index where the string is to be inserted.
2084 std::string object containing data to be inserted.
2087 The characters of \a std_str are taken to be unencoded data which represent Unicode code points 0x00..0xFF. No translation of
2088 the provided data will occur.
2091 Index of the first character from \a std_str to be inserted.
2094 Maximum number of characters from \a str to be inserted.
2097 This String after the insert.
2099 \exception std::out_of_range Thrown if \a idx or \a str_idx are out of range.
2100 \exception std::length_error Thrown if resulting String would be too large.
2102 String
& insert(size_type idx
, const std::string
& std_str
, size_type str_idx
, size_type str_num
)
2104 if (d_cplength
< idx
)
2105 throw std::out_of_range("Index is out of range for CEGUI::String");
2107 if (std_str
.size() < str_idx
)
2108 throw std::out_of_range("Index is out of range for std::string");
2110 if ((str_num
== npos
) || (str_num
> (size_type
)std_str
.size() - str_idx
))
2111 str_num
= (size_type
)std_str
.size() - str_idx
;
2113 size_type newsz
= d_cplength
+ str_num
;
2116 memmove(&ptr()[idx
+ str_num
], &ptr()[idx
], (d_cplength
- idx
) * sizeof(utf32
));
2118 utf32
* pt
= &ptr()[idx
+ str_num
- 1];
2121 *pt
-- = static_cast<utf32
>(static_cast<unsigned char>(std_str
[str_idx
+ str_num
]));
2130 Inserts the given null-terminated utf8 encoded data at the specified position.
2133 Index where the data is to be inserted.
2136 Buffer containing the null-terminated utf8 encoded data that is to be inserted.
2139 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
2140 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
2141 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
2145 This String after the insert.
2147 \exception std::out_of_range Thrown if \a idx is invalid for this String.
2148 \exception std::length_error Thrown if resulting String would be too large.
2150 String
& insert(size_type idx
, const utf8
* utf8_str
)
2152 return insert(idx
, utf8_str
, utf_length(utf8_str
));
2157 Inserts the given utf8 encoded data at the specified position.
2160 Index where the data is to be inserted.
2163 Buffer containing the utf8 encoded data that is to be inserted.
2166 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
2167 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
2168 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
2172 Length of the data to be inserted in uf8 code units (not code points)
2175 This String after the insert.
2177 \exception std::out_of_range Thrown if \a idx is invalid for this String.
2178 \exception std::length_error Thrown if resulting String would be too large, or if \a len is 'npos'
2180 String
& insert(size_type idx
, const utf8
* utf8_str
, size_type len
)
2182 if (d_cplength
< idx
)
2183 throw std::out_of_range("Index is out of range for CEGUI::String");
2186 throw std::length_error("Length of utf8 encoded string can not be 'npos'");
2188 size_type encsz
= encoded_size(utf8_str
, len
);
2189 size_type newsz
= d_cplength
+ encsz
;
2192 memmove(&ptr()[idx
+ encsz
], &ptr()[idx
], (d_cplength
- idx
) * sizeof(utf32
));
2193 encode(utf8_str
, &ptr()[idx
], encsz
, len
);
2201 Inserts a code point multiple times into the String
2204 Index where the code point(s) are to be inserted
2207 The number of times to insert the code point
2210 The utf32 code point that is to be inserted
2213 This String after the insertion.
2215 \exception std::out_of_range Thrown if \a idx is invalid for this String.
2216 \exception std::length_error Thrown if resulting String would be too large, or if \a num is 'npos'
2218 String
& insert(size_type idx
, size_type num
, utf32 code_point
)
2220 if (d_cplength
< idx
)
2221 throw std::out_of_range("Index is out of range for CEGUI::String");
2224 throw std::length_error("Code point count can not be 'npos'");
2226 size_type newsz
= d_cplength
+ num
;
2229 memmove(&ptr()[idx
+ num
], &ptr()[idx
], (d_cplength
- idx
) * sizeof(utf32
));
2231 utf32
* pt
= &ptr()[idx
+ num
- 1];
2243 Inserts a code point multiple times into the String
2246 Iterator describing the position where the code point(s) are to be inserted
2249 The number of times to insert the code point
2252 The utf32 code point that is to be inserted
2255 This String after the insertion.
2257 \exception std::length_error Thrown if resulting String would be too large, or if \a num is 'npos'
2259 void insert(iterator pos
, size_type num
, utf32 code_point
)
2261 insert(safe_iter_dif(pos
, begin()), num
, code_point
);
2266 Inserts a single code point into the String
2269 Iterator describing the position where the code point is to be inserted
2272 The utf32 code point that is to be inserted
2275 This String after the insertion.
2277 \exception std::length_error Thrown if resulting String would be too large.
2279 iterator
insert(iterator pos
, utf32 code_point
)
2281 insert(pos
, 1, code_point
);
2287 Inserts code points specified by the range [beg, end).
2290 Iterator describing the position where the data is to be inserted
2293 Iterator describing the begining of the range to be inserted
2296 Iterator describing the (exclusive) end of the range to be inserted.
2301 \exception std::length_error Thrown if resulting String would be too large.
2303 void insert(iterator iter_pos
, const_iterator iter_beg
, const_iterator iter_end
)
2305 replace(iter_pos
, iter_pos
, iter_beg
, iter_end
);
2311 Inserts the given c-string at the specified position.
2314 Index where the c-string is to be inserted.
2317 c-string that is to be inserted.
2320 This String after the insert.
2322 \exception std::out_of_range Thrown if \a idx is invalid for this String.
2323 \exception std::length_error Thrown if resulting String would be too large.
2325 String
& insert(size_type idx
, const char* cstr
)
2327 return insert(idx
, cstr
, strlen(cstr
));
2333 Inserts chars from the given char array at the specified position.
2336 Index where the data is to be inserted.
2339 char array containing the chars that are to be inserted.
2342 Length of the char array to be inserted.
2345 This String after the insert.
2347 \exception std::out_of_range Thrown if \a idx is invalid for this String.
2348 \exception std::length_error Thrown if resulting String would be too large, or if \a chars_len is 'npos'
2350 String
& insert(size_type idx
, const char* chars
, size_type chars_len
)
2352 if (d_cplength
< idx
)
2353 throw std::out_of_range("Index is out of range for CEGUI::String");
2355 if (chars_len
== npos
)
2356 throw std::length_error("Length of char array can not be 'npos'");
2358 size_type newsz
= d_cplength
+ chars_len
;
2361 memmove(&ptr()[idx
+ chars_len
], &ptr()[idx
], (d_cplength
- idx
) * sizeof(utf32
));
2363 utf32
* pt
= &ptr()[idx
+ chars_len
- 1];
2366 *pt
-- = static_cast<utf32
>(static_cast<unsigned char>(chars
[chars_len
]));
2374 //////////////////////////////////////////////////////////////////////////
2375 // Erasing characters
2376 //////////////////////////////////////////////////////////////////////////
2379 Removes all data from the String
2392 Removes all data from the String
2395 The empty String (*this)
2405 Erase a single code point from the string
2408 The index of the code point to be removed.
2411 This String after the erase operation
2413 \exception std::out_of_range Thrown if \a idx is invalid for this String.
2415 String
& erase(size_type idx
)
2417 return erase(idx
, 1);
2422 Erase a range of code points
2425 Index of the first code point to be removed.
2428 Maximum number of code points to be removed.
2431 This String after the erase operation.
2433 \exception std::out_of_range Thrown if \a idx is invalid for this String.
2435 String
& erase(size_type idx
, size_type len
= npos
)
2437 if (d_cplength
< idx
)
2438 throw std::out_of_range("Index is out of range foe CEGUI::String");
2441 len
= d_cplength
- idx
;
2443 size_type newsz
= d_cplength
- len
;
2445 memmove(&ptr()[idx
], &ptr()[idx
+ len
], (d_cplength
- idx
- len
) * sizeof(utf32
));
2452 Erase the code point described by the given iterator
2455 Iterator describing the code point to be erased
2458 This String after the erase operation.
2460 String
& erase(iterator pos
)
2462 return erase(safe_iter_dif(pos
, begin()), 1);
2467 Erase a range of code points described by the iterators [beg, end).
2470 Iterator describing the postion of the beginning of the range to erase
2473 Iterator describing the postion of the (exclusive) end of the range to erase
2476 This String after the erase operation.
2478 String
& erase(iterator iter_beg
, iterator iter_end
)
2480 return erase(safe_iter_dif(iter_beg
, begin()), safe_iter_dif(iter_end
, iter_beg
));
2483 //////////////////////////////////////////////////////////////////////////
2485 //////////////////////////////////////////////////////////////////////////
2488 Resizes the String either by inserting default utf32 code points to make it larger, or by truncating to make it smaller
2491 The length, in code points, that the String is to be made.
2496 \exception std::length_error Thrown if the String would be too large.
2498 void resize(size_type num
)
2500 resize(num
, utf32());
2505 Resizes the String either by inserting the given utf32 code point to make it larger, or by truncating to make it smaller
2508 The length, in code points, that the String is to be made.
2511 The utf32 code point that should be used when majing the String larger
2516 \exception std::length_error Thrown if the String would be too large.
2518 void resize(size_type num
, utf32 code_point
)
2520 if (num
< d_cplength
)
2526 append(num
- d_cplength
, code_point
);
2531 //////////////////////////////////////////////////////////////////////////
2532 // Replacing Characters
2533 //////////////////////////////////////////////////////////////////////////
2536 Replace code points in the String with the specified String object
2539 Index of the first code point to be replaced
2542 Maximum number of code points to be replaced (if this is 0, operation is an insert at position \a idx)
2545 The String object that is to replace the specified code points
2548 This String after the replace operation
2550 \exception std::out_of_range Thrown if \a idx is invalid for this String
2551 \exception std::length_error Thrown if the resulting String would be too large.
2553 String
& replace(size_type idx
, size_type len
, const String
& str
)
2555 return replace(idx
, len
, str
, 0, npos
);
2560 Replace the code points in the range [beg, end) with the specified String object
2563 If \a beg == \a end, the operation is a insert at iterator position \a beg
2566 Iterator describing the start of the range to be replaced
2569 Iterator describing the (exclusive) end of the range to be replaced.
2572 The String object that is to replace the specified range of code points
2575 This String after the replace operation
2577 \exception std::length_error Thrown if the resulting String would be too large.
2579 String
& replace(iterator iter_beg
, iterator iter_end
, const String
& str
)
2581 return replace(safe_iter_dif(iter_beg
, begin()), safe_iter_dif(iter_end
, iter_beg
), str
, 0, npos
);
2586 Replace code points in the String with a specified sub-string of a given String object.
2589 Index of the first code point to be replaced
2592 Maximum number of code points to be replaced. If this is 0, the operation is an insert at position \a idx.
2595 String object containing the data that will replace the specified range of code points
2598 Index of the first code point of \a str that is to replace the specified code point range
2601 Maximum number of code points of \a str that are to replace the specified code point range
2604 This String after the replace operation
2606 \exception std::out_of_range Thrown if either \a idx, or \a str_idx are invalid
2607 \exception std::length_error Thrown if the resulting String would have been too large.
2609 String
& replace(size_type idx
, size_type len
, const String
& str
, size_type str_idx
, size_type str_num
)
2611 if ((d_cplength
< idx
) || (str
.d_cplength
< str_idx
))
2612 throw std::out_of_range("Index is out of range for CEGUI::String");
2614 if (((str_idx
+ str_num
) > str
.d_cplength
) || (str_num
== npos
))
2615 str_num
= str
.d_cplength
- str_idx
;
2617 if (((len
+ idx
) > d_cplength
) || (len
== npos
))
2618 len
= d_cplength
- idx
;
2620 size_type newsz
= d_cplength
+ str_num
- len
;
2624 if ((idx
+ len
) < d_cplength
)
2625 memmove(&ptr()[idx
+ str_num
], &ptr()[len
+ idx
], (d_cplength
- idx
- len
) * sizeof(utf32
));
2627 memcpy(&ptr()[idx
], &str
.ptr()[str_idx
], str_num
* sizeof(utf32
));
2636 Replace code points in the String with the specified std::string object
2639 Index of the first code point to be replaced
2642 Maximum number of code points to be replaced (if this is 0, operation is an insert at position \a idx)
2645 The std::string object that is to replace the specified code points
2648 Characters from \a std_str are considered to represent Unicode code points in the range 0x00..0xFF. No translation of
2649 the encountered data is performed.
2652 This String after the replace operation
2654 \exception std::out_of_range Thrown if \a idx is invalid for this String
2655 \exception std::length_error Thrown if the resulting String would be too large.
2657 String
& replace(size_type idx
, size_type len
, const std::string
& std_str
)
2659 return replace(idx
, len
, std_str
, 0, npos
);
2664 Replace the code points in the range [beg, end) with the specified std::string object
2667 If \a beg == \a end, the operation is a insert at iterator position \a beg
2670 Iterator describing the start of the range to be replaced
2673 Iterator describing the (exclusive) end of the range to be replaced.
2676 The std::string object that is to replace the specified range of code points
2679 Characters from \a std_str are considered to represent Unicode code points in the range 0x00..0xFF. No translation of
2680 the encountered data is performed.
2683 This String after the replace operation
2685 \exception std::length_error Thrown if the resulting String would be too large.
2687 String
& replace(iterator iter_beg
, iterator iter_end
, const std::string
& std_str
)
2689 return replace(safe_iter_dif(iter_beg
, begin()), safe_iter_dif(iter_end
, iter_beg
), std_str
, 0, npos
);
2694 Replace code points in the String with a specified sub-string of a given std::string object.
2697 Index of the first code point to be replaced
2700 Maximum number of code points to be replaced. If this is 0, the operation is an insert at position \a idx.
2703 std::string object containing the data that will replace the specified range of code points
2706 Characters from \a std_str are considered to represent Unicode code points in the range 0x00..0xFF. No translation of
2707 the encountered data is performed.
2710 Index of the first code point of \a std_str that is to replace the specified code point range
2713 Maximum number of code points of \a std_str that are to replace the specified code point range
2716 This String after the replace operation
2718 \exception std::out_of_range Thrown if either \a idx, or \a str_idx are invalid
2719 \exception std::length_error Thrown if the resulting String would have been too large.
2721 String
& replace(size_type idx
, size_type len
, const std::string
& std_str
, size_type str_idx
, size_type str_num
)
2723 if (d_cplength
< idx
)
2724 throw std::out_of_range("Index is out of range for CEGUI::String");
2726 if (std_str
.size() < str_idx
)
2727 throw std::out_of_range("Index is out of range for std::string");
2729 if (((str_idx
+ str_num
) > std_str
.size()) || (str_num
== npos
))
2730 str_num
= (size_type
)std_str
.size() - str_idx
;
2732 if (((len
+ idx
) > d_cplength
) || (len
== npos
))
2733 len
= d_cplength
- idx
;
2735 size_type newsz
= d_cplength
+ str_num
- len
;
2739 if ((idx
+ len
) < d_cplength
)
2740 memmove(&ptr()[idx
+ str_num
], &ptr()[len
+ idx
], (d_cplength
- idx
- len
) * sizeof(utf32
));
2742 utf32
* pt
= &ptr()[idx
+ str_num
- 1];
2745 *pt
-- = static_cast<utf32
>(static_cast<unsigned char>(std_str
[str_idx
+ str_num
]));
2755 Replace code points in the String with the specified null-terminated utf8 encoded data.
2758 Index of the first code point to be replaced
2761 Maximum number of code points to be replaced (if this is 0, operation is an insert at position \a idx)
2764 Buffer containing the null-terminated utf8 encoded data that is to replace the specified code points
2767 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
2768 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
2769 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
2773 This String after the replace operation
2775 \exception std::out_of_range Thrown if \a idx is invalid for this String
2776 \exception std::length_error Thrown if the resulting String would be too large.
2778 String
& replace(size_type idx
, size_type len
, const utf8
* utf8_str
)
2780 return replace(idx
, len
, utf8_str
, utf_length(utf8_str
));
2785 Replace the code points in the range [beg, end) with the specified null-terminated utf8 encoded data.
2788 If \a beg == \a end, the operation is a insert at iterator position \a beg
2791 Iterator describing the start of the range to be replaced
2794 Iterator describing the (exclusive) end of the range to be replaced.
2797 Buffer containing the null-terminated utf8 encoded data that is to replace the specified range of code points
2800 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
2801 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
2802 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
2806 This String after the replace operation
2808 \exception std::length_error Thrown if the resulting String would be too large.
2810 String
& replace(iterator iter_beg
, iterator iter_end
, const utf8
* utf8_str
)
2812 return replace(iter_beg
, iter_end
, utf8_str
, utf_length(utf8_str
));
2817 Replace code points in the String with the specified utf8 encoded data.
2820 Index of the first code point to be replaced
2823 Maximum number of code points to be replaced (if this is 0, operation is an insert at position \a idx)
2826 Buffer containing the null-terminated utf8 encoded data that is to replace the specified code points
2829 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
2830 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
2831 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
2835 Length of the utf8 encoded data in utf8 code units (not code points).
2838 This String after the replace operation
2840 \exception std::out_of_range Thrown if \a idx is invalid for this String
2841 \exception std::length_error Thrown if the resulting String would be too large, or if \a str_len was 'npos'.
2843 String
& replace(size_type idx
, size_type len
, const utf8
* utf8_str
, size_type str_len
)
2845 if (d_cplength
< idx
)
2846 throw std::out_of_range("Index is out of range for CEGUI::String");
2848 if (str_len
== npos
)
2849 throw std::length_error("Length for utf8 encoded string can not be 'npos'");
2851 if (((len
+ idx
) > d_cplength
) || (len
== npos
))
2852 len
= d_cplength
- idx
;
2854 size_type encsz
= encoded_size(utf8_str
, str_len
);
2855 size_type newsz
= d_cplength
+ encsz
- len
;
2859 if ((idx
+ len
) < d_cplength
)
2860 memmove(&ptr()[idx
+ encsz
], &ptr()[len
+ idx
], (d_cplength
- idx
- len
) * sizeof(utf32
));
2862 encode(utf8_str
, &ptr()[idx
], encsz
, str_len
);
2870 Replace the code points in the range [beg, end) with the specified null-terminated utf8 encoded data.
2873 If \a beg == \a end, the operation is a insert at iterator position \a beg
2876 Iterator describing the start of the range to be replaced
2879 Iterator describing the (exclusive) end of the range to be replaced.
2882 Buffer containing the null-terminated utf8 encoded data that is to replace the specified range of code points
2885 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
2886 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
2887 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
2891 Length of the utf8 encoded data in utf8 code units (not code points).
2894 This String after the replace operation
2896 \exception std::length_error Thrown if the resulting String would be too large, or if \a str_len was 'npos'.
2898 String
& replace(iterator iter_beg
, iterator iter_end
, const utf8
* utf8_str
, size_type str_len
)
2900 return replace(safe_iter_dif(iter_beg
, begin()), safe_iter_dif(iter_end
, iter_beg
), utf8_str
, str_len
);
2905 Replaces a specified range of code points with occurrences of a given code point
2908 Index of the first code point to be replaced
2911 Maximum number of code points to replace. If this is 0 the operation is an insert
2914 Number of occurrences of \a code_point that are to replace the specified range of code points
2917 Code point that is to be used when replacing the specified range of code points
2920 This String after the replace operation.
2922 \exception std::out_of_range Thrown if \a idx is invalid for this String
2923 \exception std::length_error Thrown if resulting String would have been too long, or if \a num was 'npos'.
2925 String
& replace(size_type idx
, size_type len
, size_type num
, utf32 code_point
)
2927 if (d_cplength
< idx
)
2928 throw std::out_of_range("Index is out of range for CEGUI::String");
2931 throw std::length_error("Code point count can not be 'npos'");
2933 if (((len
+ idx
) > d_cplength
) || (len
== npos
))
2934 len
= d_cplength
- idx
;
2936 size_type newsz
= d_cplength
+ num
- len
;
2940 if ((idx
+ len
) < d_cplength
)
2941 memmove(&ptr()[idx
+ num
], &ptr()[len
+ idx
], (d_cplength
- idx
- len
) * sizeof(utf32
));
2943 utf32
* pt
= &ptr()[idx
+ num
- 1];
2955 Replace the code points in the range [beg, end) with occurrences of a given code point
2958 If \a beg == \a end, the operation is an insert at iterator position \a beg
2961 Iterator describing the start of the range to be replaced
2964 Iterator describing the (exclusive) end of the range to be replaced.
2967 Number of occurrences of \a code_point that are to replace the specified range of code points
2970 Code point that is to be used when replacing the specified range of code points
2973 This String after the replace operation
2975 \exception std::length_error Thrown if resulting String would have been too long, or if \a num was 'npos'.
2977 String
& replace(iterator iter_beg
, iterator iter_end
, size_type num
, utf32 code_point
)
2979 return replace(safe_iter_dif(iter_beg
, begin()), safe_iter_dif(iter_end
, iter_beg
), num
, code_point
);
2985 Replace the code points in the range [beg, end) with code points from the range [newBeg, newEnd).
2988 If \a beg == \a end, the operation is an insert at iterator position \a beg
2991 Iterator describing the start of the range to be replaced
2994 Iterator describing the (exclusive) end of the range to be replaced.
2997 Iterator describing the beginning of the range to insert.
3000 Iterator describing the (exclusive) end of the range to insert.
3003 This String after the insert operation.
3005 \exception std::length_error Thrown if the resulting string would be too long.
3007 String
& replace(iterator iter_beg
, iterator iter_end
, const_iterator iter_newBeg
, const_iterator iter_newEnd
)
3009 if (iter_beg
== iter_end
)
3011 erase(safe_iter_dif(iter_beg
, begin()), safe_iter_dif(iter_end
, iter_beg
));
3015 size_type str_len
= safe_iter_dif(iter_newEnd
, iter_newBeg
);
3016 size_type idx
= safe_iter_dif(iter_beg
, begin());
3017 size_type len
= safe_iter_dif(iter_end
, iter_beg
);
3019 if ((len
+ idx
) > d_cplength
)
3020 len
= d_cplength
- idx
;
3022 size_type newsz
= d_cplength
+ str_len
- len
;
3026 if ((idx
+ len
) < d_cplength
)
3027 memmove(&ptr()[idx
+ str_len
], &ptr()[len
+ idx
], (d_cplength
- idx
- len
) * sizeof(utf32
));
3029 memcpy(&ptr()[idx
], iter_newBeg
.d_ptr
, str_len
* sizeof(utf32
));
3039 Replace code points in the String with the specified c-string.
3042 Index of the first code point to be replaced
3045 Maximum number of code points to be replaced (if this is 0, operation is an insert at position \a idx)
3048 c-string that is to replace the specified code points
3051 This String after the replace operation
3053 \exception std::out_of_range Thrown if \a idx is invalid for this String
3054 \exception std::length_error Thrown if the resulting String would be too large.
3056 String
& replace(size_type idx
, size_type len
, const char* cstr
)
3058 return replace(idx
, len
, cstr
, strlen(cstr
));
3064 Replace the code points in the range [beg, end) with the specified c-string.
3067 If \a beg == \a end, the operation is a insert at iterator position \a beg
3070 Iterator describing the start of the range to be replaced
3073 Iterator describing the (exclusive) end of the range to be replaced.
3076 c-string that is to replace the specified range of code points
3079 This String after the replace operation
3081 \exception std::length_error Thrown if the resulting String would be too large.
3083 String
& replace(iterator iter_beg
, iterator iter_end
, const char* cstr
)
3085 return replace(iter_beg
, iter_end
, cstr
, strlen(cstr
));
3091 Replace code points in the String with chars from the given char array.
3094 Index of the first code point to be replaced
3097 Maximum number of code points to be replaced (if this is 0, operation is an insert at position \a idx)
3100 char array containing the cars that are to replace the specified code points
3103 Number of chars in the char array.
3106 This String after the replace operation
3108 \exception std::out_of_range Thrown if \a idx is invalid for this String
3109 \exception std::length_error Thrown if the resulting String would be too large, or if \a chars_len was 'npos'.
3111 String
& replace(size_type idx
, size_type len
, const char* chars
, size_type chars_len
)
3113 if (d_cplength
< idx
)
3114 throw std::out_of_range("Index is out of range for CEGUI::String");
3116 if (chars_len
== npos
)
3117 throw std::length_error("Length for the char array can not be 'npos'");
3119 if (((len
+ idx
) > d_cplength
) || (len
== npos
))
3120 len
= d_cplength
- idx
;
3122 size_type newsz
= d_cplength
+ chars_len
- len
;
3126 if ((idx
+ len
) < d_cplength
)
3127 memmove(&ptr()[idx
+ chars_len
], &ptr()[len
+ idx
], (d_cplength
- idx
- len
) * sizeof(utf32
));
3129 utf32
* pt
= &ptr()[idx
+ chars_len
- 1];
3132 *pt
-- = static_cast<utf32
>(static_cast<unsigned char>(chars
[chars_len
]));
3141 Replace the code points in the range [beg, end) with chars from the given char array.
3144 If \a beg == \a end, the operation is a insert at iterator position \a beg
3147 Iterator describing the start of the range to be replaced
3150 Iterator describing the (exclusive) end of the range to be replaced.
3153 char array containing the chars that are to replace the specified range of code points
3156 Number of chars in the char array.
3159 This String after the replace operation
3161 \exception std::length_error Thrown if the resulting String would be too large, or if \a chars_len was 'npos'.
3163 String
& replace(iterator iter_beg
, iterator iter_end
, const char* chars
, size_type chars_len
)
3165 return replace(safe_iter_dif(iter_beg
, begin()), safe_iter_dif(iter_end
, iter_beg
), chars
, chars_len
);
3169 //////////////////////////////////////////////////////////////////////////
3170 // Find a code point
3171 //////////////////////////////////////////////////////////////////////////
3174 Search forwards for a given code point
3177 The utf32 code point to search for
3180 Index of the code point where the search is to start.
3183 - Index of the first occurrence of \a code_point travelling forwards from \a idx.
3184 - npos if the code point could not be found
3186 size_type
find(utf32 code_point
, size_type idx
= 0) const
3188 if (idx
< d_cplength
)
3190 const utf32
* pt
= &ptr()[idx
];
3192 while (idx
< d_cplength
)
3194 if (*pt
++ == code_point
)
3207 Search backwards for a given code point
3210 The utf32 code point to search for
3213 Index of the code point where the search is to start.
3216 - Index of the first occurrence of \a code_point travelling backwards from \a idx.
3217 - npos if the code point could not be found
3219 size_type
rfind(utf32 code_point
, size_type idx
= npos
) const
3221 if (idx
>= d_cplength
)
3222 idx
= d_cplength
- 1;
3226 const utf32
* pt
= &ptr()[idx
];
3230 if (*pt
-- == code_point
)
3233 } while (idx
-- != 0);
3240 //////////////////////////////////////////////////////////////////////////
3242 //////////////////////////////////////////////////////////////////////////
3245 Search forwards for a sub-string
3248 String object describing the sub-string to search for
3251 Index of the code point where the search is to start
3254 - Index of the first occurrence of sub-string \a str travelling forwards from \a idx.
3255 - npos if the sub-string could not be found
3257 size_type
find(const String
& str
, size_type idx
= 0) const
3259 if ((str
.d_cplength
== 0) && (idx
< d_cplength
))
3262 if (idx
< d_cplength
)
3264 // loop while search string could fit in to search area
3265 while (d_cplength
- idx
>= str
.d_cplength
)
3267 if (0 == compare(idx
, str
.d_cplength
, str
))
3280 Search backwards for a sub-string
3283 String object describing the sub-string to search for
3286 Index of the code point where the search is to start
3289 - Index of the first occurrence of sub-string \a str travelling backwards from \a idx.
3290 - npos if the sub-string could not be found
3292 size_type
rfind(const String
& str
, size_type idx
= npos
) const
3294 if (str
.d_cplength
== 0)
3295 return (idx
< d_cplength
) ? idx
: d_cplength
;
3297 if (str
.d_cplength
<= d_cplength
)
3299 if (idx
> (d_cplength
- str
.d_cplength
))
3300 idx
= d_cplength
- str
.d_cplength
;
3304 if (0 == compare(idx
, str
.d_cplength
, str
))
3307 } while (idx
-- != 0);
3316 Search forwards for a sub-string
3319 std::string object describing the sub-string to search for
3322 Characters from \a std_str are considered to represent Unicode code points in the range 0x00..0xFF. No translation of
3323 the encountered data is performed.
3326 Index of the code point where the search is to start
3329 - Index of the first occurrence of sub-string \a std_str travelling forwards from \a idx.
3330 - npos if the sub-string could not be found
3332 size_type
find(const std::string
& std_str
, size_type idx
= 0) const
3334 std::string::size_type sze
= std_str
.size();
3336 if ((sze
== 0) && (idx
< d_cplength
))
3339 if (idx
< d_cplength
)
3341 // loop while search string could fit in to search area
3342 while (d_cplength
- idx
>= sze
)
3344 if (0 == compare(idx
, (size_type
)sze
, std_str
))
3357 Search backwards for a sub-string
3360 std::string object describing the sub-string to search for
3363 Characters from \a std_str are considered to represent Unicode code points in the range 0x00..0xFF. No translation of
3364 the encountered data is performed.
3367 Index of the code point where the search is to start
3370 - Index of the first occurrence of sub-string \a std_str travelling backwards from \a idx.
3371 - npos if the sub-string could not be found
3373 size_type
rfind(const std::string
& std_str
, size_type idx
= npos
) const
3375 std::string::size_type sze
= std_str
.size();
3378 return (idx
< d_cplength
) ? idx
: d_cplength
;
3380 if (sze
<= d_cplength
)
3382 if (idx
> (d_cplength
- sze
))
3383 idx
= d_cplength
- sze
;
3387 if (0 == compare(idx
, (size_type
)sze
, std_str
))
3390 } while (idx
-- != 0);
3399 Search forwards for a sub-string
3402 Buffer containing null-terminated utf8 encoded data describing the sub-string to search for
3405 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
3406 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
3407 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
3411 Index of the code point where the search is to start
3414 - Index of the first occurrence of sub-string \a utf8_str travelling forwards from \a idx.
3415 - npos if the sub-string could not be found
3417 \exception std::out_of_range Thrown if \a idx is invalid for this String.
3419 size_type
find(const utf8
* utf8_str
, size_type idx
= 0) const
3421 return find(utf8_str
, idx
, utf_length(utf8_str
));
3426 Search backwards for a sub-string
3429 Buffer containing null-terminated utf8 encoded data describing the sub-string to search for
3432 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
3433 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
3434 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
3438 Index of the code point where the search is to start
3441 - Index of the first occurrence of sub-string \a utf8_str travelling backwards from \a idx.
3442 - npos if the sub-string could not be found
3444 \exception std::out_of_range Thrown if \a idx is invalid for this String.
3446 size_type
rfind(const utf8
* utf8_str
, size_type idx
= npos
) const
3448 return rfind(utf8_str
, idx
, utf_length(utf8_str
));
3453 Search forwards for a sub-string
3456 Buffer containing utf8 encoded data describing the sub-string to search for
3459 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
3460 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
3461 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
3465 Index of the code point where the search is to start
3468 Length of the utf8 encoded sub-string in utf8 code units (not code points)
3471 - Index of the first occurrence of sub-string \a utf8_str travelling forwards from \a idx.
3472 - npos if the sub-string could not be found
3474 \exception std::length_error Thrown if \a str_len is 'npos'
3476 size_type
find(const utf8
* utf8_str
, size_type idx
, size_type str_len
) const
3478 if (str_len
== npos
)
3479 throw std::length_error("Length for utf8 encoded string can not be 'npos'");
3481 size_type sze
= encoded_size(utf8_str
, str_len
);
3483 if ((sze
== 0) && (idx
< d_cplength
))
3486 if (idx
< d_cplength
)
3488 // loop while search string could fit in to search area
3489 while (d_cplength
- idx
>= sze
)
3491 if (0 == compare(idx
, sze
, utf8_str
, sze
))
3504 Search backwards for a sub-string
3507 Buffer containing utf8 encoded data describing the sub-string to search for
3510 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
3511 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
3512 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
3516 Index of the code point where the search is to start
3519 Length of the utf8 encoded sub-string in utf8 code units (not code points)
3522 - Index of the first occurrence of sub-string \a utf8_str travelling backwards from \a idx.
3523 - npos if the sub-string could not be found
3525 \exception std::length_error Thrown if \a str_len is 'npos'
3527 size_type
rfind(const utf8
* utf8_str
, size_type idx
, size_type str_len
) const
3529 if (str_len
== npos
)
3530 throw std::length_error("Length for utf8 encoded string can not be 'npos'");
3532 size_type sze
= encoded_size(utf8_str
, str_len
);
3535 return (idx
< d_cplength
) ? idx
: d_cplength
;
3537 if (sze
<= d_cplength
)
3539 if (idx
> (d_cplength
- sze
))
3540 idx
= d_cplength
- sze
;
3544 if (0 == compare(idx
, sze
, utf8_str
, sze
))
3547 } while (idx
-- != 0);
3557 Search forwards for a sub-string
3560 c-string describing the sub-string to search for
3563 Index of the code point where the search is to start
3566 - Index of the first occurrence of sub-string \a c_str travelling forwards from \a idx.
3567 - npos if the sub-string could not be found
3569 \exception std::out_of_range Thrown if \a idx is invalid for this String.
3571 size_type
find(const char* cstr
, size_type idx
= 0) const
3573 return find(cstr
, idx
, strlen(cstr
));
3579 Search backwards for a sub-string
3582 c-string describing the sub-string to search for
3585 Index of the code point where the search is to start
3588 - Index of the first occurrence of sub-string \a c_str travelling backwards from \a idx.
3589 - npos if the sub-string could not be found
3591 \exception std::out_of_range Thrown if \a idx is invalid for this String.
3593 size_type
rfind(const char* cstr
, size_type idx
= npos
) const
3595 return rfind(cstr
, idx
, strlen(cstr
));
3601 Search forwards for a sub-string
3604 char array describing the sub-string to search for
3607 Index of the code point where the search is to start
3610 Number of chars in the char array.
3613 - Index of the first occurrence of sub-string \a chars travelling forwards from \a idx.
3614 - npos if the sub-string could not be found
3616 \exception std::length_error Thrown if \a chars_len is 'npos'
3618 size_type
find(const char* chars
, size_type idx
, size_type chars_len
) const
3620 if (chars_len
== npos
)
3621 throw std::length_error("Length for char array can not be 'npos'");
3623 if ((chars_len
== 0) && (idx
< d_cplength
))
3626 if (idx
< d_cplength
)
3628 // loop while search string could fit in to search area
3629 while (d_cplength
- idx
>= chars_len
)
3631 if (0 == compare(idx
, chars_len
, chars
, chars_len
))
3645 Search backwards for a sub-string
3648 char array describing the sub-string to search for
3651 Index of the code point where the search is to start
3654 Number of chars in the char array.
3657 - Index of the first occurrence of sub-string \a chars travelling backwards from \a idx.
3658 - npos if the sub-string could not be found
3660 \exception std::length_error Thrown if \a chars_len is 'npos'
3662 size_type
rfind(const char* chars
, size_type idx
, size_type chars_len
) const
3664 if (chars_len
== npos
)
3665 throw std::length_error("Length for char array can not be 'npos'");
3668 return (idx
< d_cplength
) ? idx
: d_cplength
;
3670 if (chars_len
<= d_cplength
)
3672 if (idx
> (d_cplength
- chars_len
))
3673 idx
= d_cplength
- chars_len
;
3677 if (0 == compare(idx
, chars_len
, chars
, chars_len
))
3680 } while (idx
-- != 0);
3688 //////////////////////////////////////////////////////////////////////////
3689 // Find first of different code-points
3690 //////////////////////////////////////////////////////////////////////////
3693 Find the first occurrence of one of a set of code points.
3696 String object describing the set of code points.
3699 Index of the start point for the search
3702 - Index of the first occurrence of any one of the code points in \a str starting from from \a idx.
3703 - npos if none of the code points in \a str were found.
3705 size_type
find_first_of(const String
& str
, size_type idx
= 0) const
3707 if (idx
< d_cplength
)
3709 const utf32
* pt
= &ptr()[idx
];
3713 if (npos
!= str
.find(*pt
++))
3716 } while (++idx
!= d_cplength
);
3725 Find the first code point that is not one of a set of code points.
3728 String object describing the set of code points.
3731 Index of the start point for the search
3734 - Index of the first code point that does not match any one of the code points in \a str starting from from \a idx.
3735 - npos if all code points matched one of the code points in \a str.
3737 size_type
find_first_not_of(const String
& str
, size_type idx
= 0) const
3739 if (idx
< d_cplength
)
3741 const utf32
* pt
= &ptr()[idx
];
3745 if (npos
== str
.find(*pt
++))
3748 } while (++idx
!= d_cplength
);
3758 Find the first occurrence of one of a set of code points.
3761 std::string object describing the set of code points.
3764 The characters of \a std_str are taken to be unencoded data which represent Unicode code points 0x00..0xFF. No translation of
3765 the provided data will occur.
3768 Index of the start point for the search
3771 - Index of the first occurrence of any one of the code points in \a std_str starting from from \a idx.
3772 - npos if none of the code points in \a std_str were found.
3774 size_type
find_first_of(const std::string
& std_str
, size_type idx
= 0) const
3776 if (idx
< d_cplength
)
3778 const utf32
* pt
= &ptr()[idx
];
3782 if (npos
!= find_codepoint(std_str
, *pt
++))
3785 } while (++idx
!= d_cplength
);
3794 Find the first code point that is not one of a set of code points.
3797 std::string object describing the set of code points.
3800 The characters of \a std_str are taken to be unencoded data which represent Unicode code points 0x00..0xFF. No translation of
3801 the provided data will occur.
3804 Index of the start point for the search
3807 - Index of the first code point that does not match any one of the code points in \a std_str starting from from \a idx.
3808 - npos if all code points matched one of the code points in \a std_str.
3810 size_type
find_first_not_of(const std::string
& std_str
, size_type idx
= 0) const
3812 if (idx
< d_cplength
)
3814 const utf32
* pt
= &ptr()[idx
];
3818 if (npos
== find_codepoint(std_str
, *pt
++))
3821 } while (++idx
!= d_cplength
);
3831 Find the first occurrence of one of a set of code points.
3834 Buffer containing null-terminated utf8 encoded data describing the set of code points.
3837 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
3838 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
3839 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
3843 Index of the start point for the search
3846 - Index of the first occurrence of any one of the code points in \a utf8_str starting from from \a idx.
3847 - npos if none of the code points in \a utf8_str were found.
3849 \exception std::out_of_range Thrown if \a idx is invalid for this String.
3851 size_type
find_first_of(const utf8
* utf8_str
, size_type idx
= 0) const
3853 return find_first_of(utf8_str
, idx
, utf_length(utf8_str
));
3858 Find the first code point that is not one of a set of code points.
3861 Buffer containing null-terminated utf8 encoded data describing the set of code points.
3864 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
3865 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
3866 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
3870 Index of the start point for the search
3873 - Index of the first code point that does not match any one of the code points in \a utf8_str starting from from \a idx.
3874 - npos if all code points matched one of the code points in \a utf8_str.
3876 \exception std::out_of_range Thrown if \a idx is invalid for this String.
3878 size_type
find_first_not_of(const utf8
* utf8_str
, size_type idx
= 0) const
3880 return find_first_not_of(utf8_str
, idx
, utf_length(utf8_str
));
3885 Find the first occurrence of one of a set of code points.
3888 Buffer containing utf8 encoded data describing the set of code points.
3891 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
3892 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
3893 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
3897 Index of the start point for the search
3900 Length of the utf8 encoded data in utf8 code units (not code points).
3903 - Index of the first occurrence of any one of the code points in \a utf8_str starting from from \a idx.
3904 - npos if none of the code points in \a utf8_str were found.
3906 \exception std::length_error Thrown if \a str_len was 'npos'.
3908 size_type
find_first_of(const utf8
* utf8_str
, size_type idx
, size_type str_len
) const
3910 if (str_len
== npos
)
3911 throw std::length_error("Length for utf8 encoded string can not be 'npos'");
3913 if (idx
< d_cplength
)
3915 size_type encsze
= encoded_size(utf8_str
, str_len
);
3917 const utf32
* pt
= &ptr()[idx
];
3921 if (npos
!= find_codepoint(utf8_str
, encsze
, *pt
++))
3924 } while (++idx
!= d_cplength
);
3933 Find the first code point that is not one of a set of code points.
3936 Buffer containing utf8 encoded data describing the set of code points.
3939 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
3940 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
3941 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
3945 Index of the start point for the search
3948 Length of the utf8 encoded data in utf8 code units (not code points).
3951 - Index of the first code point that does not match any one of the code points in \a utf8_str starting from from \a idx.
3952 - npos if all code points matched one of the code points in \a utf8_str.
3954 \exception std::length_error Thrown if \a str_len was 'npos'.
3956 size_type
find_first_not_of(const utf8
* utf8_str
, size_type idx
, size_type str_len
) const
3958 if (str_len
== npos
)
3959 throw std::length_error("Length for utf8 encoded string can not be 'npos'");
3961 if (idx
< d_cplength
)
3963 size_type encsze
= encoded_size(utf8_str
, str_len
);
3965 const utf32
* pt
= &ptr()[idx
];
3969 if (npos
== find_codepoint(utf8_str
, encsze
, *pt
++))
3972 } while (++idx
!= d_cplength
);
3982 Search forwards for a given code point
3985 The utf32 code point to search for
3988 Index of the code point where the search is to start.
3991 - Index of the first occurrence of \a code_point starting from from \a idx.
3992 - npos if the code point could not be found
3994 size_type
find_first_of(utf32 code_point
, size_type idx
= 0) const
3996 return find(code_point
, idx
);
4001 Search forwards for the first code point that does not match a given code point
4004 The utf32 code point to search for
4007 Index of the code point where the search is to start.
4010 - Index of the first code point that does not match \a code_point starting from from \a idx.
4011 - npos if all code points matched \a code_point
4013 \exception std::out_of_range Thrown if \a idx is invalid for this String.
4015 size_type
find_first_not_of(utf32 code_point
, size_type idx
= 0) const
4017 if (idx
< d_cplength
)
4021 if ((*this)[idx
] != code_point
)
4024 } while(idx
++ < d_cplength
);
4034 Find the first occurrence of one of a set of chars.
4037 c-string describing the set of chars.
4040 Index of the start point for the search
4043 - Index of the first occurrence of any one of the chars in \a c_str starting from from \a idx.
4044 - npos if none of the chars in \a c_str were found.
4046 \exception std::out_of_range Thrown if \a idx is invalid for this String.
4048 size_type
find_first_of(const char* cstr
, size_type idx
= 0) const
4050 return find_first_of(cstr
, idx
, strlen(cstr
));
4056 Find the first code point that is not one of a set of chars.
4059 c-string describing the set of chars.
4062 Index of the start point for the search
4065 - Index of the first code point that does not match any one of the chars in \a c_str starting from from \a idx.
4066 - npos if all code points matched any of the chars in \a c_str.
4068 \exception std::out_of_range Thrown if \a idx is invalid for this String.
4070 size_type
find_first_not_of(const char* cstr
, size_type idx
= 0) const
4072 return find_first_not_of(cstr
, idx
, strlen(cstr
));
4078 Find the first occurrence of one of a set of chars.
4081 char array containing the set of chars.
4084 Index of the start point for the search
4087 Number of chars in the char array.
4090 - Index of the first occurrence of any one of the chars in \a chars starting from from \a idx.
4091 - npos if none of the chars in \a chars were found.
4093 \exception std::length_error Thrown if \a chars_len was 'npos'.
4095 size_type
find_first_of(const char* chars
, size_type idx
, size_type chars_len
) const
4097 if (chars_len
== npos
)
4098 throw std::length_error("Length for char array can not be 'npos'");
4100 if (idx
< d_cplength
)
4102 const utf32
* pt
= &ptr()[idx
];
4106 if (npos
!= find_codepoint(chars
, chars_len
, *pt
++))
4109 } while (++idx
!= d_cplength
);
4119 Find the first code point that is not one of a set of chars.
4122 char array containing the set of chars.
4125 Index of the start point for the search
4128 Number of chars in the car array.
4131 - Index of the first code point that does not match any one of the chars in \a chars starting from from \a idx.
4132 - npos if all code points matched any of the chars in \a chars.
4134 \exception std::length_error Thrown if \a chars_len was 'npos'.
4136 size_type
find_first_not_of(const char* chars
, size_type idx
, size_type chars_len
) const
4138 if (chars_len
== npos
)
4139 throw std::length_error("Length for char array can not be 'npos'");
4141 if (idx
< d_cplength
)
4143 const utf32
* pt
= &ptr()[idx
];
4147 if (npos
== find_codepoint(chars
, chars_len
, *pt
++))
4150 } while (++idx
!= d_cplength
);
4158 //////////////////////////////////////////////////////////////////////////
4159 // Find last of different code-points
4160 //////////////////////////////////////////////////////////////////////////
4163 Find the last occurrence of one of a set of code points.
4166 String object describing the set of code points.
4169 Index of the start point for the search
4172 - Index of the last occurrence of any one of the code points in \a str starting from \a idx.
4173 - npos if none of the code points in \a str were found.
4175 size_type
find_last_of(const String
& str
, size_type idx
= npos
) const
4179 if (idx
>= d_cplength
)
4180 idx
= d_cplength
- 1;
4182 const utf32
* pt
= &ptr()[idx
];
4186 if (npos
!= str
.find(*pt
--))
4189 } while (idx
-- != 0);
4198 Find the last code point that is not one of a set of code points.
4201 String object describing the set of code points.
4204 Index of the start point for the search
4207 - Index of the last code point that does not match any one of the code points in \a str starting from \a idx.
4208 - npos if all code points matched one of the code points in \a str.
4210 size_type
find_last_not_of(const String
& str
, size_type idx
= npos
) const
4214 if (idx
>= d_cplength
)
4215 idx
= d_cplength
- 1;
4217 const utf32
* pt
= &ptr()[idx
];
4221 if (npos
== str
.find(*pt
--))
4224 } while (idx
-- != 0);
4234 Find the last occurrence of one of a set of code points.
4237 std::string object describing the set of code points.
4240 The characters of \a std_str are taken to be unencoded data which represent Unicode code points 0x00..0xFF. No translation of
4241 the provided data will occur.
4244 Index of the start point for the search
4247 - Index of the last occurrence of any one of the code points in \a std_str starting from \a idx.
4248 - npos if none of the code points in \a std_str were found.
4250 size_type
find_last_of(const std::string
& std_str
, size_type idx
= npos
) const
4254 if (idx
>= d_cplength
)
4255 idx
= d_cplength
- 1;
4257 const utf32
* pt
= &ptr()[idx
];
4261 if (npos
!= find_codepoint(std_str
, *pt
--))
4264 } while (idx
-- != 0);
4273 Find the last code point that is not one of a set of code points.
4276 std::string object describing the set of code points.
4279 The characters of \a std_str are taken to be unencoded data which represent Unicode code points 0x00..0xFF. No translation of
4280 the provided data will occur.
4283 Index of the start point for the search
4286 - Index of the last code point that does not match any one of the code points in \a std_str starting from \a idx.
4287 - npos if all code points matched one of the code points in \a std_str.
4289 size_type
find_last_not_of(const std::string
& std_str
, size_type idx
= npos
) const
4293 if (idx
>= d_cplength
)
4294 idx
= d_cplength
- 1;
4296 const utf32
* pt
= &ptr()[idx
];
4300 if (npos
== find_codepoint(std_str
, *pt
--))
4303 } while (idx
-- != 0);
4313 Find the last occurrence of one of a set of code points.
4316 Buffer containing null-terminated utf8 encoded data describing the set of code points.
4319 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
4320 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
4321 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
4325 Index of the start point for the search
4328 - Index of the last occurrence of any one of the code points in \a utf8_str starting from \a idx.
4329 - npos if none of the code points in \a utf8_str were found.
4331 \exception std::out_of_range Thrown if \a idx is invalid for this String.
4333 size_type
find_last_of(const utf8
* utf8_str
, size_type idx
= npos
) const
4335 return find_last_of(utf8_str
, idx
, utf_length(utf8_str
));
4340 Find the last code point that is not one of a set of code points.
4343 Buffer containing null-terminated utf8 encoded data describing the set of code points.
4346 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
4347 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
4348 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
4352 Index of the start point for the search
4355 - Index of the last code point that does not match any one of the code points in \a utf8_str starting from \a idx.
4356 - npos if all code points matched one of the code points in \a utf8_str.
4358 \exception std::out_of_range Thrown if \a idx is invalid for this String.
4360 size_type
find_last_not_of(const utf8
* utf8_str
, size_type idx
= npos
) const
4362 return find_last_not_of(utf8_str
, idx
, utf_length(utf8_str
));
4367 Find the last occurrence of one of a set of code points.
4370 Buffer containing utf8 encoded data describing the set of code points.
4373 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
4374 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
4375 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
4379 Index of the start point for the search
4382 Length of the utf8 encoded data in utf8 code units (not code points).
4385 - Index of the last occurrence of any one of the code points in \a utf8_str starting from from \a idx.
4386 - npos if none of the code points in \a utf8_str were found.
4388 \exception std::length_error Thrown if \a str_len was 'npos'.
4390 size_type
find_last_of(const utf8
* utf8_str
, size_type idx
, size_type str_len
) const
4392 if (str_len
== npos
)
4393 throw std::length_error("Length for utf8 encoded string can not be 'npos'");
4397 if (idx
>= d_cplength
)
4398 idx
= d_cplength
- 1;
4400 size_type encsze
= encoded_size(utf8_str
, str_len
);
4402 const utf32
* pt
= &ptr()[idx
];
4406 if (npos
!= find_codepoint(utf8_str
, encsze
, *pt
--))
4409 } while (idx
-- != 0);
4418 Find the last code point that is not one of a set of code points.
4421 Buffer containing utf8 encoded data describing the set of code points.
4424 A basic string literal (cast to utf8*) can be passed to this function, provided that the string is
4425 comprised only of code points 0x00..0x7f. The use of extended ASCII characters (with values >0x7f)
4426 would result in incorrect behaviour as the String will attempt to 'decode' the data, with unpredictable
4430 Index of the start point for the search
4433 Length of the utf8 encoded data in utf8 code units (not code points).
4436 - Index of the last code point that does not match any one of the code points in \a utf8_str starting from from \a idx.
4437 - npos if all code points matched one of the code points in \a utf8_str.
4439 \exception std::length_error Thrown if \a str_len was 'npos'.
4441 size_type
find_last_not_of(const utf8
* utf8_str
, size_type idx
, size_type str_len
) const
4443 if (str_len
== npos
)
4444 throw std::length_error("Length for utf8 encoded string can not be 'npos'");
4448 if (idx
>= d_cplength
)
4449 idx
= d_cplength
- 1;
4451 size_type encsze
= encoded_size(utf8_str
, str_len
);
4453 const utf32
* pt
= &ptr()[idx
];
4457 if (npos
== find_codepoint(utf8_str
, encsze
, *pt
--))
4460 } while (idx
-- != 0);
4470 Search for last occurrence of a given code point
4473 The utf32 code point to search for
4476 Index of the code point where the search is to start.
4479 - Index of the last occurrence of \a code_point starting from \a idx.
4480 - npos if the code point could not be found
4482 size_type
find_last_of(utf32 code_point
, size_type idx
= npos
) const
4484 return rfind(code_point
, idx
);
4489 Search for the last code point that does not match a given code point
4492 The utf32 code point to search for
4495 Index of the code point where the search is to start.
4498 - Index of the last code point that does not match \a code_point starting from from \a idx.
4499 - npos if all code points matched \a code_point
4501 size_type
find_last_not_of(utf32 code_point
, size_type idx
= npos
) const
4505 if (idx
>= d_cplength
)
4506 idx
= d_cplength
- 1;
4510 if ((*this)[idx
] != code_point
)
4513 } while(idx
-- != 0);
4523 Find the last occurrence of one of a set of chars.
4526 c-string describing the set of chars.
4529 Index of the start point for the search
4532 - Index of the last occurrence of any one of the chars in \a c_str starting from \a idx.
4533 - npos if none of the chars in \a c_str were found.
4535 \exception std::out_of_range Thrown if \a idx is invalid for this String.
4537 size_type
find_last_of(const char* cstr
, size_type idx
= npos
) const
4539 return find_last_of(cstr
, idx
, strlen(cstr
));
4545 Find the last code point that is not one of a set of chars.
4548 c-string describing the set of chars.
4551 Index of the start point for the search
4554 - Index of the last code point that does not match any one of the chars in \a c_str starting from \a idx.
4555 - npos if all code points matched any of the chars in \a c_str.
4557 \exception std::out_of_range Thrown if \a idx is invalid for this String.
4559 size_type
find_last_not_of(const char* cstr
, size_type idx
= npos
) const
4561 return find_last_not_of(cstr
, idx
, strlen(cstr
));
4567 Find the last occurrence of one of a set of chars.
4570 char array containing the set of chars.
4573 Index of the start point for the search
4576 Number of chars in the char array.
4579 - Index of the last occurrence of any one of the chars in \a chars, starting from from \a idx.
4580 - npos if none of the chars in \a chars were found.
4582 \exception std::length_error Thrown if \a chars_len was 'npos'.
4584 size_type
find_last_of(const char* chars
, size_type idx
, size_type chars_len
) const
4586 if (chars_len
== npos
)
4587 throw std::length_error("Length for char array can not be 'npos'");
4591 if (idx
>= d_cplength
)
4592 idx
= d_cplength
- 1;
4594 const utf32
* pt
= &ptr()[idx
];
4598 if (npos
!= find_codepoint(chars
, chars_len
, *pt
--))
4601 } while (idx
-- != 0);
4611 Find the last code point that is not one of a set of chars.
4614 char array containing the set of chars.
4617 Index of the start point for the search
4620 Number of chars in the char array.
4623 - Index of the last code point that does not match any one of the chars in \a chars, starting from from \a idx.
4624 - npos if all code points matched any of the chars in \a chars.
4626 \exception std::length_error Thrown if \a chars_len was 'npos'.
4628 size_type
find_last_not_of(const char* chars
, size_type idx
, size_type chars_len
) const
4630 if (chars_len
== npos
)
4631 throw std::length_error("Length for char array can not be 'npos'");
4635 if (idx
>= d_cplength
)
4636 idx
= d_cplength
- 1;
4638 const utf32
* pt
= &ptr()[idx
];
4642 if (npos
== find_codepoint(chars
, chars_len
, *pt
--))
4645 } while (idx
-- != 0);
4653 //////////////////////////////////////////////////////////////////////////
4655 //////////////////////////////////////////////////////////////////////////
4658 Returns a substring of this String.
4661 Index of the first code point to use for the sub-string.
4664 Maximum number of code points to use for the sub-string
4667 A String object containing the specified sub-string.
4669 \exception std::out_of_range Thrown if \a idx is invalid for this String.
4671 String
substr(size_type idx
= 0, size_type len
= npos
) const
4673 if (d_cplength
< idx
)
4674 throw std::out_of_range("Index is out of range for this CEGUI::String");
4676 return String(*this, idx
, len
);
4679 //////////////////////////////////////////////////////////////////////////
4680 // Iterator creation
4681 //////////////////////////////////////////////////////////////////////////
4684 Return a forwards iterator that describes the beginning of the String
4687 iterator object that describes the beginning of the String.
4689 iterator
begin(void)
4691 return iterator(ptr());
4696 Return a constant forwards iterator that describes the beginning of the String
4699 const_iterator object that describes the beginning of the String.
4701 const_iterator
begin(void) const
4703 return const_iterator(ptr());
4708 Return a forwards iterator that describes the end of the String
4711 iterator object that describes the end of the String.
4715 return iterator(&ptr()[d_cplength
]);
4720 Return a constant forwards iterator that describes the end of the String
4723 const_iterator object that describes the end of the String.
4725 const_iterator
end(void) const
4727 return const_iterator(&ptr()[d_cplength
]);
4732 Return a reverse iterator that describes the beginning of the String
4735 reverse_iterator object that describes the beginning of the String (so is actually at the end)
4737 reverse_iterator
rbegin(void)
4739 return reverse_iterator(end());
4744 Return a constant reverse iterator that describes the beginning of the String
4747 const_reverse_iterator object that describes the beginning of the String (so is actually at the end)
4749 const_reverse_iterator
rbegin(void) const
4751 return const_reverse_iterator(end());
4756 Return a reverse iterator that describes the end of the String
4759 reverse_iterator object that describes the end of the String (so is actually at the beginning)
4761 reverse_iterator
rend(void)
4763 return reverse_iterator(begin());
4768 Return a constant reverse iterator that describes the end of the String
4771 const_reverse_iterator object that describes the end of the String (so is actually at the beginning)
4773 const_reverse_iterator
rend(void) const
4775 return const_reverse_iterator(begin());
4779 /*************************************************************************
4780 Implementation Functions
4781 *************************************************************************/
4782 // string management
4784 // change size of allocated buffer so it is at least 'new_size'.
4785 // May or may not cause re-allocation and copy of buffer if size is larger
4786 // will never re-allocate to make size smaller. (see trim())
4787 bool grow(size_type new_size
);
4789 // perform re-allocation to remove wasted space.
4792 // set the length of the string, and terminate it, according to the given value (will not re-allocate, use grow() first).
4793 void setlen(size_type len
)
4796 ptr()[len
] = (utf32
)(0);
4799 // initialise string object
4802 d_reserve
= STR_QUICKBUFF_SIZE
;
4804 d_encodedbufflen
= 0;
4805 d_encodeddatlen
= 0;
4810 // return true if the given pointer is inside the string data
4811 bool inside(utf32
* inptr
)
4813 if (inptr
< ptr() || ptr() + d_cplength
<= inptr
)
4819 // compute distance between two iterators, returning a 'safe' value
4820 size_type
safe_iter_dif(const const_iterator
& iter1
, const const_iterator
& iter2
) const
4822 return (iter1
.d_ptr
== 0) ? 0 : (iter1
- iter2
);
4825 // encoding functions
4827 // src_len is in code units, or 0 for null terminated string.
4828 // dest_len is in code units.
4829 // returns number of code units put into dest buffer.
4830 size_type
encode(const utf32
* src
, utf8
* dest
, size_type dest_len
, size_type src_len
= 0) const
4832 // count length for null terminated source...
4835 src_len
= utf_length(src
);
4838 size_type destCapacity
= dest_len
;
4840 // while there is data in the source buffer,
4841 for (uint idx
= 0; idx
< src_len
; ++idx
)
4843 utf32 cp
= src
[idx
];
4845 // check there is enough destination buffer to receive this encoded unit (exit loop & return if not)
4846 if (destCapacity
< encoded_size(cp
))
4856 else if (cp
< 0x0800)
4858 *dest
++ = (utf8
)((cp
>> 6) | 0xC0);
4859 *dest
++ = (utf8
)((cp
& 0x3F) | 0x80);
4862 else if (cp
< 0x10000)
4864 *dest
++ = (utf8
)((cp
>> 12) | 0xE0);
4865 *dest
++ = (utf8
)(((cp
>> 6) & 0x3F) | 0x80);
4866 *dest
++ = (utf8
)((cp
& 0x3F) | 0x80);
4871 *dest
++ = (utf8
)((cp
>> 18) | 0xF0);
4872 *dest
++ = (utf8
)(((cp
>> 12) & 0x3F) | 0x80);
4873 *dest
++ = (utf8
)(((cp
>> 6) & 0x3F) | 0x80);
4874 *dest
++ = (utf8
)((cp
& 0x3F) | 0x80);
4880 return dest_len
- destCapacity
;
4883 size_type
encode(const utf8
* src
, utf32
* dest
, size_type dest_len
, size_type src_len
= 0) const
4885 // count length for null terminated source...
4888 src_len
= utf_length(src
);
4891 size_type destCapacity
= dest_len
;
4893 // while there is data in the source buffer, and space in the dest buffer
4894 for (uint idx
= 0; ((idx
< src_len
) && (destCapacity
> 0));)
4897 utf8 cu
= src
[idx
++];
4905 cp
= ((cu
& 0x1F) << 6);
4906 cp
|= (src
[idx
++] & 0x3F);
4910 cp
= ((cu
& 0x0F) << 12);
4911 cp
|= ((src
[idx
++] & 0x3F) << 6);
4912 cp
|= (src
[idx
++] & 0x3F);
4916 cp
= ((cu
& 0x07) << 18);
4917 cp
|= ((src
[idx
++] & 0x3F) << 12);
4918 cp
|= ((src
[idx
++] & 0x3F) << 6);
4919 cp
|= (src
[idx
++] & 0x3F);
4926 return dest_len
- destCapacity
;
4929 // return the number of utf8 code units required to encode the given utf32 code point
4930 size_type
encoded_size(utf32 code_point
) const
4932 if (code_point
< 0x80)
4934 else if (code_point
< 0x0800)
4936 else if (code_point
< 0x10000)
4942 // return number of code units required to re-encode given null-terminated utf32 data as utf8. return does not include terminating null.
4943 size_type
encoded_size(const utf32
* buf
) const
4945 return encoded_size(buf
, utf_length(buf
));
4948 // return number of code units required to re-encode given utf32 data as utf8. len is number of code units in 'buf'.
4949 size_type
encoded_size(const utf32
* buf
, size_type len
) const
4951 size_type count
= 0;
4955 count
+= encoded_size(*buf
++);
4961 // return number of utf32 code units required to re-encode given utf8 data as utf32. return does not include terminating null.
4962 size_type
encoded_size(const utf8
* buf
) const
4964 return encoded_size(buf
, utf_length(buf
));
4967 // return number of utf32 code units required to re-encode given utf8 data as utf32. len is number of code units in 'buf'.
4968 size_type
encoded_size(const utf8
* buf
, size_type len
) const
4971 size_type count
= 0;
4981 else if (tcp
< 0xE0)
4986 else if (tcp
< 0xF0)
5002 // return number of code units in a null terminated string
5003 size_type
utf_length(const utf8
* utf8_str
) const
5012 // return number of code units in a null terminated string
5013 size_type
utf_length(const utf32
* utf32_str
) const
5016 while (*utf32_str
++)
5022 // build an internal buffer with the string encoded as utf8 (remains valid until string is modified).
5023 utf8
* build_utf8_buff(void) const;
5025 // compare two utf32 buffers
5026 int utf32_comp_utf32(const utf32
* buf1
, const utf32
* buf2
, size_type cp_count
) const
5031 while ((--cp_count
) && (*buf1
== *buf2
))
5034 return *buf1
- *buf2
;
5037 // compare utf32 buffer with char buffer (chars are taken to be code-points in the range 0x00-0xFF)
5038 int utf32_comp_char(const utf32
* buf1
, const char* buf2
, size_type cp_count
) const
5043 while ((--cp_count
) && (*buf1
== static_cast<utf32
>(static_cast<unsigned char>(*buf2
))))
5046 return *buf1
- static_cast<utf32
>(static_cast<unsigned char>(*buf2
));
5049 // compare utf32 buffer with encoded utf8 data
5050 int utf32_comp_utf8(const utf32
* buf1
, const utf8
* buf2
, size_type cp_count
) const
5068 cp
= ((cu
& 0x1F) << 6);
5069 cp
|= (*buf2
++ & 0x3F);
5073 cp
= ((cu
& 0x0F) << 12);
5074 cp
|= ((*buf2
++ & 0x3F) << 6);
5075 cp
|= (*buf2
++ & 0x3F);
5079 cp
= ((cu
& 0x07) << 18);
5080 cp
|= ((*buf2
++ & 0x3F) << 12);
5081 cp
|= ((*buf2
++ & 0x3F) << 6);
5082 cp
|= (*buf2
++ & 0x3F);
5085 } while ((*buf1
++ == cp
) && (--cp_count
));
5087 return (*--buf1
) - cp
;
5090 // return index of first occurrence of 'code_point' in std::string 'str', or npos if none
5091 size_type
find_codepoint(const std::string
& str
, utf32 code_point
) const
5093 size_type idx
= 0, sze
= (size_type
)str
.size();
5097 if (code_point
== static_cast<utf32
>(static_cast<unsigned char>(str
[idx
])))
5106 // return index of first occurrence of 'code_point' in utf8 encoded string 'str', or npos if none. len is in code points.
5107 size_type
find_codepoint(const utf8
* str
, size_type len
, utf32 code_point
) const
5114 while (idx
!= len
) {
5123 cp
= ((cu
& 0x1F) << 6);
5124 cp
|= (*str
++ & 0x3F);
5128 cp
= ((cu
& 0x0F) << 12);
5129 cp
|= ((*str
++ & 0x3F) << 6);
5130 cp
|= (*str
++ & 0x3F);
5134 cp
= ((cu
& 0x07) << 18);
5135 cp
|= ((*str
++ & 0x3F) << 12);
5136 cp
|= ((*str
++ & 0x3F) << 6);
5137 cp
|= (*str
++ & 0x3F);
5140 if (code_point
== cp
)
5150 // return index of first occurrence of 'code_point' in char array 'chars', or npos if none
5151 size_type
find_codepoint(const char* chars
, size_type chars_len
, utf32 code_point
) const
5153 for (size_type idx
= 0; idx
!= chars_len
; ++idx
)
5155 if (code_point
== static_cast<utf32
>(static_cast<unsigned char>(chars
[idx
])))
5165 //////////////////////////////////////////////////////////////////////////
5166 // Comparison operators
5167 //////////////////////////////////////////////////////////////////////////
5170 Return true if String \a str1 is equal to String \a str2
5172 bool CEGUIEXPORT
operator==(const String
& str1
, const String
& str2
);
5176 Return true if String \a str is equal to std::string \a std_str
5178 bool CEGUIEXPORT
operator==(const String
& str
, const std::string
& std_str
);
5182 Return true if String \a str is equal to std::string \a std_str
5184 bool CEGUIEXPORT
operator==(const std::string
& std_str
, const String
& str
);
5188 Return true if String \a str is equal to null-terminated utf8 data \a utf8_str
5190 bool CEGUIEXPORT
operator==(const String
& str
, const utf8
* utf8_str
);
5194 Return true if String \a str is equal to null-terminated utf8 data \a utf8_str
5196 bool CEGUIEXPORT
operator==(const utf8
* utf8_str
, const String
& str
);
5200 Return true if String \a str1 is not equal to String \a str2
5202 bool CEGUIEXPORT
operator!=(const String
& str1
, const String
& str2
);
5206 Return true if String \a str is not equal to std::string \a std_str
5208 bool CEGUIEXPORT
operator!=(const String
& str
, const std::string
& std_str
);
5212 Return true if String \a str is not equal to std::string \a std_str
5214 bool CEGUIEXPORT
operator!=(const std::string
& std_str
, const String
& str
);
5218 Return true if String \a str is not equal to null-terminated utf8 data \a utf8_str
5220 bool CEGUIEXPORT
operator!=(const String
& str
, const utf8
* utf8_str
);
5224 Return true if String \a str is not equal to null-terminated utf8 data \a utf8_str
5226 bool CEGUIEXPORT
operator!=(const utf8
* utf8_str
, const String
& str
);
5230 Return true if String \a str1 is lexicographically less than String \a str2
5232 bool CEGUIEXPORT
operator<(const String
& str1
, const String
& str2
);
5236 Return true if String \a str is lexicographically less than std::string \a std_str
5238 bool CEGUIEXPORT
operator<(const String
& str
, const std::string
& std_str
);
5242 Return true if String \a str is lexicographically less than std::string \a std_str
5244 bool CEGUIEXPORT
operator<(const std::string
& std_str
, const String
& str
);
5248 Return true if String \a str is lexicographically less than null-terminated utf8 data \a utf8_str
5250 bool CEGUIEXPORT
operator<(const String
& str
, const utf8
* utf8_str
);
5254 Return true if String \a str is lexicographically less than null-terminated utf8 data \a utf8_str
5256 bool CEGUIEXPORT
operator<(const utf8
* utf8_str
, const String
& str
);
5260 Return true if String \a str1 is lexicographically greater than String \a str2
5262 bool CEGUIEXPORT
operator>(const String
& str1
, const String
& str2
);
5266 Return true if String \a str is lexicographically greater than std::string \a std_str
5268 bool CEGUIEXPORT
operator>(const String
& str
, const std::string
& std_str
);
5272 Return true if String \a str is lexicographically greater than std::string \a std_str
5274 bool CEGUIEXPORT
operator>(const std::string
& std_str
, const String
& str
);
5278 Return true if String \a str is lexicographically greater than null-terminated utf8 data \a utf8_str
5280 bool CEGUIEXPORT
operator>(const String
& str
, const utf8
* utf8_str
);
5284 Return true if String \a str is lexicographically greater than null-terminated utf8 data \a utf8_str
5286 bool CEGUIEXPORT
operator>(const utf8
* utf8_str
, const String
& str
);
5290 Return true if String \a str1 is lexicographically less than or equal to String \a str2
5292 bool CEGUIEXPORT
operator<=(const String
& str1
, const String
& str2
);
5296 Return true if String \a str is lexicographically less than or equal to std::string \a std_str
5298 bool CEGUIEXPORT
operator<=(const String
& str
, const std::string
& std_str
);
5302 Return true if String \a str is lexicographically less than or equal to std::string \a std_str
5304 bool CEGUIEXPORT
operator<=(const std::string
& std_str
, const String
& str
);
5308 Return true if String \a str is lexicographically less than or equal to null-terminated utf8 data \a utf8_str
5310 bool CEGUIEXPORT
operator<=(const String
& str
, const utf8
* utf8_str
);
5314 Return true if String \a str is lexicographically less than or equal to null-terminated utf8 data \a utf8_str
5316 bool CEGUIEXPORT
operator<=(const utf8
* utf8_str
, const String
& str
);
5320 Return true if String \a str1 is lexicographically greater than or equal to String \a str2
5322 bool CEGUIEXPORT
operator>=(const String
& str1
, const String
& str2
);
5326 Return true if String \a str is lexicographically greater than or equal to std::string \a std_str
5328 bool CEGUIEXPORT
operator>=(const String
& str
, const std::string
& std_str
);
5332 Return true if String \a str is lexicographically greater than or equal to std::string \a std_str
5334 bool CEGUIEXPORT
operator>=(const std::string
& std_str
, const String
& str
);
5338 Return true if String \a str is lexicographically greater than or equal to null-terminated utf8 data \a utf8_str
5340 bool CEGUIEXPORT
operator>=(const String
& str
, const utf8
* utf8_str
);
5344 Return true if String \a str is lexicographically greater than or equal to null-terminated utf8 data \a utf8_str
5346 bool CEGUIEXPORT
operator>=(const utf8
* utf8_str
, const String
& str
);
5350 Return true if String \a str is equal to c-string \a c_str
5352 bool CEGUIEXPORT
operator==(const String
& str
, const char* c_str
);
5356 Return true if c-string \a c_str is equal to String \a str
5358 bool CEGUIEXPORT
operator==(const char* c_str
, const String
& str
);
5362 Return true if String \a str is not equal to c-string \a c_str
5364 bool CEGUIEXPORT
operator!=(const String
& str
, const char* c_str
);
5368 Return true if c-string \a c_str is not equal to String \a str
5370 bool CEGUIEXPORT
operator!=(const char* c_str
, const String
& str
);
5374 Return true if String \a str is lexicographically less than c-string \a c_str
5376 bool CEGUIEXPORT
operator<(const String
& str
, const char* c_str
);
5380 Return true if c-string \a c_str is lexicographically less than String \a str
5382 bool CEGUIEXPORT
operator<(const char* c_str
, const String
& str
);
5386 Return true if String \a str is lexicographically greater than c-string \a c_str
5388 bool CEGUIEXPORT
operator>(const String
& str
, const char* c_str
);
5392 Return true if c-string \a c_str is lexicographically greater than String \a str
5394 bool CEGUIEXPORT
operator>(const char* c_str
, const String
& str
);
5398 Return true if String \a str is lexicographically less than or equal to c-string \a c_str
5400 bool CEGUIEXPORT
operator<=(const String
& str
, const char* c_str
);
5404 Return true if c-string \a c_str is lexicographically less than or equal to String \a str
5406 bool CEGUIEXPORT
operator<=(const char* c_str
, const String
& str
);
5410 Return true if String \a str is lexicographically greater than or equal to c-string \a c_str
5412 bool CEGUIEXPORT
operator>=(const String
& str
, const char* c_str
);
5416 Return true if c-string \a c_str is lexicographically greater than or equal to String \a str
5418 bool CEGUIEXPORT
operator>=(const char* c_str
, const String
& str
);
5420 //////////////////////////////////////////////////////////////////////////
5421 // Concatenation operator functions
5422 //////////////////////////////////////////////////////////////////////////
5425 Return String object that is the concatenation of the given inputs
5428 String object describing first part of the new string
5431 String object describing the second part of the new string
5434 A String object that is the concatenation of \a str1 and \a str2
5436 \exception std::length_error Thrown if the resulting String would be too large.
5438 String CEGUIEXPORT
operator+(const String
& str1
, const String
& str2
);
5442 Return String object that is the concatenation of the given inputs
5445 String object describing first part of the new string
5448 std::string object describing the second part of the new string
5451 A String object that is the concatenation of \a str and \a std_str
5453 \exception std::length_error Thrown if the resulting String would be too large.
5455 String CEGUIEXPORT
operator+(const String
& str
, const std::string
& std_str
);
5459 Return String object that is the concatenation of the given inputs
5462 std::string object describing the first part of the new string
5465 String object describing the second part of the new string
5468 A String object that is the concatenation of \a std_str and \a str
5470 \exception std::length_error Thrown if the resulting String would be too large.
5472 String CEGUIEXPORT
operator+(const std::string
& std_str
, const String
& str
);
5476 Return String object that is the concatenation of the given inputs
5479 String object describing first part of the new string
5482 Buffer containing null-terminated utf8 encoded data describing the second part of the new string
5485 A String object that is the concatenation of \a str and \a utf8_str
5487 \exception std::length_error Thrown if the resulting String would be too large.
5489 String CEGUIEXPORT
operator+(const String
& str
, const utf8
* utf8_str
);
5493 Return String object that is the concatenation of the given inputs
5496 Buffer containing null-terminated utf8 encoded data describing the first part of the new string
5499 String object describing the second part of the new string
5502 A String object that is the concatenation of \a str and \a utf8_str
5504 \exception std::length_error Thrown if the resulting String would be too large.
5506 String CEGUIEXPORT
operator+(const utf8
* utf8_str
, const String
& str
);
5510 Return String object that is the concatenation of the given inputs
5513 String object describing the first part of the new string
5516 utf32 code point describing the second part of the new string
5519 A String object that is the concatenation of \a str and \a code_point
5521 \exception std::length_error Thrown if the resulting String would be too large.
5523 String CEGUIEXPORT
operator+(const String
& str
, utf32 code_point
);
5527 Return String object that is the concatenation of the given inputs
5530 utf32 code point describing the first part of the new string
5533 String object describing the second part of the new string
5536 A String object that is the concatenation of \a code_point and \a str
5538 \exception std::length_error Thrown if the resulting String would be too large.
5540 String CEGUIEXPORT
operator+(utf32 code_point
, const String
& str
);
5544 Return String object that is the concatenation of the given inputs
5547 String object describing first part of the new string
5550 c-string describing the second part of the new string
5553 A String object that is the concatenation of \a str and \a c_str
5555 \exception std::length_error Thrown if the resulting String would be too large.
5557 String CEGUIEXPORT
operator+(const String
& str
, const char* c_str
);
5561 Return String object that is the concatenation of the given inputs
5564 c-string describing the first part of the new string
5567 String object describing the second part of the new string
5570 A String object that is the concatenation of \a c_str and \a str
5572 \exception std::length_error Thrown if the resulting String would be too large.
5574 String CEGUIEXPORT
operator+(const char* c_str
, const String
& str
);
5577 //////////////////////////////////////////////////////////////////////////
5578 // Output (stream) functions
5579 //////////////////////////////////////////////////////////////////////////
5580 CEGUIEXPORT
std::ostream
& operator<<(std::ostream
& s
, const String
& str
);
5583 //////////////////////////////////////////////////////////////////////////
5584 // Modifying operations
5585 //////////////////////////////////////////////////////////////////////////
5588 Swap the contents for two String objects
5591 String object who's contents are to be swapped with \a str2
5594 String object who's contents are to be swapped with \a str1
5599 void CEGUIEXPORT
swap(String
& str1
, String
& str2
);
5602 } // End of CEGUI namespace section
5605 #endif // end of guard _CEGUIString_h_