A copy-on-write utf8 string class that operates by reference count.
More...
#include <unicode.h>
Protected Member Functions |
void | add (const unicode_t unicode) |
| Add (append) unicode to a utf8 encoded string.
|
ucs4_t | at (int position) const |
| Return unicode character found at a specific codepoint in the string.
|
unsigned | ccount (ucs4_t character) const |
| Count occurences of a unicode character in string.
|
strsize_t | count (void) const |
| Count codepoints in current string.
|
const char * | find (ucs4_t character, strsize_t start=0) const |
| Find first occurance of character in string.
|
UString | get (strsize_t codepoint, strsize_t size=0) const |
| Get a new string object as a substring of the current object.
|
size_t | get (unicode_t unicode, size_t size) const |
| Extract a unicode byte sequence from utf8 object.
|
const char * | operator() (int offset) const |
| Reference a string in the object by codepoint offset.
|
size_t | operator() (unicode_t unicode, size_t size) const |
| Extract a unicode byte sequence from utf8 object.
|
UString | operator() (int codepoint, strsize_t size) const |
| Get a new substring through object expression.
|
ucs4_t | operator[] (int position) const |
| Reference a unicode character in string object by array offset.
|
const char * | rfind (ucs4_t character, strsize_t end=npos) const |
| Find last occurance of character in string.
|
void | set (const 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 (const unicode_t text) |
| Create a utf8 aware string for a null terminated unicode string.
|
| UString (const unicode_t *text, const unicode_t *end) |
| Create a string for a substring.
|
| UString (const 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 (const UString &existing) |
| Construct a copy of a string object.
|
virtual | ~UString () |
| Destroy string.
|
Detailed Description
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.
- Author:
- David Sugar <dyfet@gnutelephony.org>
Definition at line 184 of file unicode.h.
Constructor & Destructor Documentation
ucc::UString::UString |
( |
strsize_t |
size |
) |
[protected] |
Create an empty string with a buffer pre-allocated to a specified size.
- Parameters:
-
| size | of buffer to allocate. |
ucc::UString::UString |
( |
const unicode_t |
text |
) |
[protected] |
Create a utf8 aware string for a null terminated unicode string.
- Parameters:
-
| text | of ucs4 encoded data. |
ucc::UString::UString |
( |
const char * |
text, |
|
|
strsize_t |
size | |
|
) |
| | [protected] |
Create a string from null terminated text up to a maximum specified size.
- Parameters:
-
| 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.
- Parameters:
-
| text | to use for string. |
| end | of text in substring. |
ucc::UString::UString |
( |
const UString & |
existing |
) |
[protected] |
Construct a copy of a string object.
Our copy inherets the same reference counted instance of cstring as in the original.
- Parameters:
-
| 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.
Member Function Documentation
void ucc::UString::add |
( |
const unicode_t |
unicode |
) |
[protected] |
Add (append) unicode to a utf8 encoded string.
- Parameters:
-
ucs4_t ucc::UString::at |
( |
int |
position |
) |
const [protected] |
Return unicode character found at a specific codepoint in the string.
- Parameters:
-
| position | of codepoint in string, negative values computed from end. |
- Returns:
- character code at specified position in string.
unsigned ucc::UString::ccount |
( |
ucs4_t |
character |
) |
const [protected] |
Count occurences of a unicode character in string.
- Parameters:
-
| character | code to search for. |
- Returns:
- count of occurences.
strsize_t ucc::UString::count |
( |
void |
|
) |
const [inline, protected] |
Count codepoints in current string.
- Returns:
- count of codepoints.
Definition at line 307 of file unicode.h.
const char* ucc::UString::find |
( |
ucs4_t |
character, |
|
|
strsize_t |
start = 0 | |
|
) |
| | const [protected] |
Find first occurance of character in string.
- Parameters:
-
| character | code to search for. |
| start | offset in string in codepoints. |
- Returns:
- pointer to first instance or NULL if not found.
size_t ucc::UString::get |
( |
unicode_t |
unicode, |
|
|
size_t |
size | |
|
) |
| | const [inline, protected] |
Extract a unicode byte sequence from utf8 object.
- Parameters:
-
| unicode | data buffer. |
| size | of data buffer. |
- Returns:
- codepoints copied.
Definition at line 247 of file unicode.h.
Get a new string object as a substring of the current object.
- Parameters:
-
| codepoint | offset of substring. |
| size | of substring in codepoints or 0 if to end. |
- Returns:
- string object holding substring.
UString ucc::UString::operator() |
( |
int |
codepoint, |
|
|
strsize_t |
size | |
|
) |
| | const [protected] |
Get a new substring through object expression.
- Parameters:
-
| codepoint | offset of substring. |
| size | of substring or 0 if to end. |
- Returns:
- string object holding substring.
const char* ucc::UString::operator() |
( |
int |
offset |
) |
const [protected] |
Reference a string in the object by codepoint offset.
Positive offsets are from the start of the string, negative from the end.
- Parameters:
-
| offset | to string position. |
- Returns:
- pointer to string data or NULL if invalid offset.
size_t ucc::UString::operator() |
( |
unicode_t |
unicode, |
|
|
size_t |
size | |
|
) |
| | const [inline, protected] |
Extract a unicode byte sequence from utf8 object.
- Parameters:
-
| unicode | data buffer. |
| size | of data buffer. |
- Returns:
- codepoints copied.
Definition at line 275 of file unicode.h.
ucs4_t ucc::UString::operator[] |
( |
int |
position |
) |
const [inline, protected] |
Reference a unicode character in string object by array offset.
- Parameters:
-
| position | of codepoint offset to character. |
- Returns:
- character value at offset.
Definition at line 300 of file unicode.h.
Find last occurance of character in string.
- Parameters:
-
| character | code to search for. |
| end | offset to start from in codepoints. |
- Returns:
- pointer to last instance or NULL if not found.
void ucc::UString::set |
( |
const unicode_t |
unicode |
) |
[protected] |
Set a utf8 encoded string based on unicode data.
- Parameters:
-
The documentation for this class was generated from the following file: