A copy-on-write utf8 string class that operates by reference count. More...
#include <unicode.h>
Protected Member Functions | |
void | add (unicode_t unicode) |
Add (append) unicode to a utf8 encoded string. | |
ucs4_t | at (int position) |
Return unicode character found at a specific codepoint in the string. | |
unsigned | ccount (ucs4_t character) |
Count occurrences of a unicode character in string. | |
strsize_t | count (void) |
Count codepoints in current string. | |
char * | find (ucs4_t character, strsize_t start=0) |
Find first occurrence of character in string. | |
UString | get (strsize_t codepoint, strsize_t size=0) |
Get a new string object as a substring of the current object. | |
size_t | get (unicode_t unicode, size_t size) |
Extract a unicode byte sequence from utf8 object. | |
char * | operator() (int offset) |
Reference a string in the object by codepoint offset. | |
size_t | operator() (unicode_t unicode, size_t size) |
Extract a unicode byte sequence from utf8 object. | |
UString | operator() (int codepoint, strsize_t size) |
Get a new substring through object expression. | |
ucs4_t | operator[] (int position) |
Reference a unicode character in string object by array offset. | |
char * | rfind (ucs4_t character, strsize_t end=npos) |
Find last occurrence of character in string. | |
void | set (unicode_t unicode) |
Set a utf8 encoded string based on unicode data. | |
UString (strsize_t size) | |
Create an empty string with a buffer pre-allocated to a specified size. | |
UString (unicode_t text) | |
Create a utf8 aware string for a null terminated unicode string. | |
UString (unicode_t *text, unicode_t *end) | |
Create a string for a substring. | |
UString (char *text, strsize_t size) | |
Create a string from null terminated text up to a maximum specified size. | |
UString () | |
Create a new empty utf8 aware string object. | |
UString (UString &existing) | |
Construct a copy of a string object. | |
virtual | ~UString () |
Destroy string. |
A copy-on-write utf8 string class that operates by reference count.
This is derived from the classic uCommon String class by adding operations that are utf8 encoding aware.
Definition at line 183 of file unicode.h.
ucc::UString::UString | ( | strsize_t | size | ) | [protected] |
Create an empty string with a buffer pre-allocated to a specified size.
size | of buffer to allocate. |
ucc::UString::UString | ( | unicode_t | text | ) | [protected] |
Create a utf8 aware string for a null terminated unicode string.
text | of ucs4 encoded data. |
ucc::UString::UString | ( | char * | text, | |
strsize_t | size | |||
) | [protected] |
Create a string from null terminated text up to a maximum specified size.
text | to use for string. | |
size | limit of new string. |
Create a string for a substring.
The end of the substring is a pointer within the substring itself.
text | to use for string. | |
end | of text in substring. |
ucc::UString::UString | ( | UString & | existing | ) | [protected] |
Construct a copy of a string object.
Our copy inherits the same reference counted instance of cstring as in the original.
existing | string to copy from. |
virtual ucc::UString::~UString | ( | ) | [protected, virtual] |
Destroy string.
De-reference cstring. If last reference to cstring, then also remove cstring from heap.
void ucc::UString::add | ( | unicode_t | unicode | ) | [protected] |
Add (append) unicode to a utf8 encoded string.
unicode | text to add. |
ucs4_t ucc::UString::at | ( | int | position | ) | [protected] |
Return unicode character found at a specific codepoint in the string.
position | of codepoint in string, negative values computed from end. |
Reimplemented from ucc::string.
unsigned ucc::UString::ccount | ( | ucs4_t | character | ) | [protected] |
Count occurrences of a unicode character in string.
character | code to search for. |
strsize_t ucc::UString::count | ( | void | ) | [inline, protected] |
Find first occurrence of character in string.
character | code to search for. | |
start | offset in string in codepoints. |
size_t ucc::UString::get | ( | unicode_t | unicode, | |
size_t | size | |||
) | [protected] |
Extract a unicode byte sequence from utf8 object.
unicode | data buffer. | |
size | of data buffer. |
Get a new string object as a substring of the current object.
codepoint | offset of substring. | |
size | of substring in codepoints or 0 if to end. |
Reimplemented from ucc::string.
Get a new substring through object expression.
codepoint | offset of substring. | |
size | of substring or 0 if to end. |
Reimplemented from ucc::string.
char* ucc::UString::operator() | ( | int | offset | ) | [protected] |
Reference a string in the object by codepoint offset.
Positive offsets are from the start of the string, negative from the end.
offset | to string position. |
Reimplemented from ucc::string.
size_t ucc::UString::operator() | ( | unicode_t | unicode, | |
size_t | size | |||
) | [inline, protected] |
ucs4_t ucc::UString::operator[] | ( | int | position | ) | [inline, protected] |
Reference a unicode character in string object by array offset.
position | of codepoint offset to character. |
Reimplemented from ucc::string.
Find last occurrence of character in string.
character | code to search for. | |
end | offset to start from in codepoints. |
void ucc::UString::set | ( | unicode_t | unicode | ) | [protected] |
Set a utf8 encoded string based on unicode data.
unicode | text to set. |