UCommon
Protected Member Functions
ucommon::UString Class Reference

A copy-on-write utf8 string class that operates by reference count. More...

#include <unicode.h>

Inheritance diagram for ucommon::UString:
Inheritance graph
[legend]
Collaboration diagram for ucommon::UString:
Collaboration graph
[legend]

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.
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.
char * operator() (int offset)
 Reference a string in the object by codepoint offset.
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 ()
 Create a new empty utf8 aware string object.
 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 (char *text, strsize_t size)
 Create a string from null terminated text up to a maximum specified size.
 UString (unicode_t *text, unicode_t *end)
 Create a string for a substring.
 UString (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.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 193 of file unicode.h.


Constructor & Destructor Documentation

ucommon::UString::UString ( strsize_t  size) [protected]

Create an empty string with a buffer pre-allocated to a specified size.

Parameters:
sizeof buffer to allocate.
ucommon::UString::UString ( unicode_t  text) [protected]

Create a utf8 aware string for a null terminated unicode string.

Parameters:
textof ucs4 encoded data.
ucommon::UString::UString ( char *  text,
strsize_t  size 
) [protected]

Create a string from null terminated text up to a maximum specified size.

Parameters:
textto use for string.
sizelimit of new string.
ucommon::UString::UString ( unicode_t text,
unicode_t end 
) [protected]

Create a string for a substring.

The end of the substring is a pointer within the substring itself.

Parameters:
textto use for string.
endof text in substring.
ucommon::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.

Parameters:
existingstring to copy from.
virtual ucommon::UString::~UString ( ) [protected, virtual]

Destroy string.

De-reference cstring. If last reference to cstring, then also remove cstring from heap.


Member Function Documentation

void ucommon::UString::add ( unicode_t  unicode) [protected]

Add (append) unicode to a utf8 encoded string.

Parameters:
unicodetext to add.
ucs4_t ucommon::UString::at ( int  position) [protected]

Return unicode character found at a specific codepoint in the string.

Parameters:
positionof codepoint in string, negative values computed from end.
Returns:
character code at specified position in string.

Reimplemented from ucommon::string.

unsigned ucommon::UString::ccount ( ucs4_t  character) [protected]

Count occurrences of a unicode character in string.

Parameters:
charactercode to search for.
Returns:
count of occurrences.
strsize_t ucommon::UString::count ( void  ) [inline, protected]

Count codepoints in current string.

Returns:
count of codepoints.

Reimplemented from ucommon::string.

Definition at line 315 of file unicode.h.

char* ucommon::UString::find ( ucs4_t  character,
strsize_t  start = 0 
) [protected]

Find first occurrence of character in string.

Parameters:
charactercode to search for.
startoffset in string in codepoints.
Returns:
pointer to first instance or NULL if not found.
UString ucommon::UString::get ( strsize_t  codepoint,
strsize_t  size = 0 
) [protected]

Get a new string object as a substring of the current object.

Parameters:
codepointoffset of substring.
sizeof substring in codepoints or 0 if to end.
Returns:
string object holding substring.

Reimplemented from ucommon::string.

size_t ucommon::UString::get ( unicode_t  unicode,
size_t  size 
) [protected]

Extract a unicode byte sequence from utf8 object.

Parameters:
unicodedata buffer.
sizeof data buffer.
Returns:
codepoints copied.
size_t ucommon::UString::operator() ( unicode_t  unicode,
size_t  size 
) [inline, protected]

Extract a unicode byte sequence from utf8 object.

Parameters:
unicodedata buffer.
sizeof data buffer.
Returns:
codepoints copied.

Definition at line 283 of file unicode.h.

Here is the call graph for this function:

UString ucommon::UString::operator() ( int  codepoint,
strsize_t  size 
) [protected]

Get a new substring through object expression.

Parameters:
codepointoffset of substring.
sizeof substring or 0 if to end.
Returns:
string object holding substring.

Reimplemented from ucommon::string.

char* ucommon::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.

Parameters:
offsetto string position.
Returns:
pointer to string data or NULL if invalid offset.

Reimplemented from ucommon::string.

ucs4_t ucommon::UString::operator[] ( int  position) [inline, protected]

Reference a unicode character in string object by array offset.

Parameters:
positionof codepoint offset to character.
Returns:
character value at offset.

Reimplemented from ucommon::string.

Definition at line 308 of file unicode.h.

char* ucommon::UString::rfind ( ucs4_t  character,
strsize_t  end = npos 
) [protected]

Find last occurrence of character in string.

Parameters:
charactercode to search for.
endoffset to start from in codepoints.
Returns:
pointer to last instance or NULL if not found.
void ucommon::UString::set ( unicode_t  unicode) [protected]

Set a utf8 encoded string based on unicode data.

Parameters:
unicodetext to set.

The documentation for this class was generated from the following file: