A copy-on-write string class that operates by reference count. More...
#include <string.h>
Data Structures | |
class | cstring |
This is an internal class which contains the actual string data along with some control fields. More... | |
Public Member Functions | |
int | __isoc99_scanf (char *format,...) |
Scan input items from a string object. | |
int | __isoc99_vscanf (char *format, va_list args) |
Scan input items from a string object. | |
void | add (char character) |
Append a single character to our string buffer. | |
void | add (char *text) |
Append null terminated text to our string buffer. | |
void | add (StringFormat &format) |
Append formatted object to our string buffer. | |
char | at (int position) |
Return character found at a specific position in the string. | |
char * | begin (void) |
Get pointer to first character in string for iteration. | |
char * | c_mem (void) |
Get memory text buffer of string object. | |
char * | c_str (void) |
Get character text buffer of string object. | |
strsize_t | ccount (char *list) |
Count number of occurrances of characters in string. | |
void | chop (char *list) |
Chop trailing characters from the string. | |
char * | chr (char character) |
Find pointer in string where specified character appears. | |
void | clear (void) |
Clear string by setting to empty. | |
void | clear (strsize_t offset, strsize_t size=0) |
Clear a field of a filled string with filler. | |
strsize_t | count (void) |
Count all characters in the string (strlen). | |
void | cut (strsize_t offset, strsize_t size=0) |
Cut (remove) text from string. | |
char * | end (void) |
Get pointer to last character in string for iteration. | |
char | fill (void) |
Get filler character used for field array strings. | |
char * | find (char *list, strsize_t offset=0) |
Find a character in the string. | |
char * | first (char *list) |
Find first occurance of a character in the string. | |
bool | full (void) |
Test if the string's allocated space is all used up. | |
string | get (strsize_t offset, strsize_t size=0) |
Get a new string object as a substring of the current object. | |
char * | last (char *list) |
Find last occurance of a character in the string. | |
strsize_t | len (void) |
Get length of string. | |
void | lower (void) |
Convert string to lower case. | |
strsize_t | offset (char *pointer) |
Find offset of a pointer into our string buffer. | |
operator bool () | |
Test if string has data. | |
operator char * () | |
Casting reference to raw text string. | |
bool | operator! () |
Test if string is empty. | |
bool | operator!= (char *text) |
Compare our object with null terminated text. | |
string & | operator& (StringFormat &format) |
Concatenate formatted string object to our object. | |
string & | operator& (char *text) |
Concatenate null terminated text to our object. | |
char * | operator() (int offset) |
Reference a string in the object by relative offset. | |
string | operator() (int offset, strsize_t size) |
Get a new substring through object expression. | |
char * | operator* () |
Reference raw text buffer by pointer operator. | |
string & | operator+ (StringFormat &format) |
Concatenate string formatted object to our object. | |
string & | operator+ (char *text) |
Concatenate null terminated text to our object. | |
string & | operator++ (void) |
Delete first character from string. | |
string & | operator+= (strsize_t number) |
Delete a specified number of characters from start of string. | |
string & | operator-- (void) |
Delete last character from string. | |
string & | operator-= (strsize_t number) |
Delete a specified number of characters from end of string. | |
bool | operator< (char *text) |
Compare our object with null terminated text. | |
bool | operator<= (char *text) |
Compare our object with null terminated text. | |
string & | operator= (char *text) |
Assign text to our existing buffer. | |
string & | operator= (StringFormat &format) |
Assign our string from a string formatting object. | |
string & | operator= (string &object) |
Assign our string with the cstring of another object. | |
bool | operator== (char *text) |
Compare our object with null terminated text. | |
bool | operator> (char *text) |
Compare our object with null terminated text. | |
bool | operator>= (char *text) |
Compare our object with null terminated text. | |
char | operator[] (int offset) |
Reference a single character in string object by array offset. | |
string & | operator^= (char *text) |
Create new cow instance and assign value from null terminated text. | |
string & | operator^= (StringFormat &format) |
Create new cow instance and assign value from formatted string object. | |
string & | operator^= (string &object) |
Create new cow instance and assign value from another string object. | |
strsize_t | printf (char *format,...) |
Print items into a string object. | |
char * | rchr (char character) |
Find pointer in string where specified character last appears. | |
virtual bool | resize (strsize_t size) |
Resize and re-allocate string memory. | |
char * | rfind (char *list, strsize_t offset=npos) |
Find last occurance of character in the string. | |
void | rset (char *text, char overflow, strsize_t offset, strsize_t size=0) |
Set a text field within our string object offset from the end of buffer. | |
char * | rskip (char *list, strsize_t offset=npos) |
Skip trailing characters in the string. | |
void | rsplit (strsize_t offset) |
Split the string at a specific offset. | |
void | rsplit (char *pointer) |
Split the string by a pointer position. | |
void | set (char *text, char overflow, strsize_t offset, strsize_t size=0) |
Set a text field within our string object. | |
void | set (strsize_t offset, char *text, strsize_t size=0) |
Set a portion of the string object at a specified offset to a text string. | |
void | set (StringFormat &format) |
Set string object to text of a formatted object. | |
void | set (char *text) |
Set string object to text of a null terminated string. | |
strsize_t | size (void) |
Get the size of currently allocated space for string. | |
char * | skip (char *list, strsize_t offset=0) |
Skip lead characters in the string. | |
void | split (strsize_t offset) |
Split the string at a specific offset. | |
void | split (char *pointer) |
Split the string by a pointer position. | |
string (string &existing) | |
Construct a copy of a string object. | |
string (char *text, char *end) | |
Create a string for a substring. | |
string (char *text, strsize_t size) | |
Create a string from null terminated text up to a maximum specified size. | |
string (char *text) | |
Create a string from null terminated text. | |
string (strsize_t size, char *format,...) | |
Create a string by printf-like formating into a pre-allocated space of a specified size. | |
string (strsize_t size, char fill) | |
Create a filled string with a buffer pre-allocated to a specified size. | |
string (strsize_t size) | |
Create an empty string with a buffer pre-allocated to a specified size. | |
string (StringFormat &format) | |
Create a string from a formatting object. | |
string () | |
Create a new empty string object. | |
void | strip (char *list) |
Strip lead and trailing characters from the string. | |
void | trim (char *list) |
Trim lead characters from the string. | |
bool | unquote (char *quote) |
Unquote a quoted string. | |
void | upper (void) |
Convert string to upper case. | |
strsize_t | vprintf (char *format, va_list args) |
Print items into a string object. | |
virtual | ~string () |
Destroy string. | |
Static Public Member Functions | |
static int | __isoc99_scanf (string &object, char *format,...) |
Scan input items from a string object. | |
static int | __isoc99_vscanf (string &object, char *format, va_list args) |
Scan input items from a string object. | |
static char * | add (char *buffer, size_t size, char *text, size_t max) |
Safely append a null terminated string into an existing string in memory. | |
static char * | add (char *buffer, size_t size, char *text) |
Safely append a null terminated string into an existing string in memory. | |
static int | case_compare (char *text1, char *text2, size_t size) |
Safe case insensitive string comparison function. | |
static int | case_compare (char *text1, char *text2) |
Safe case insensitive string comparison function. | |
static bool | case_equal (char *text1, char *text2, size_t size) |
Simple case insenstive equal test for strings. | |
static bool | case_equal (char *text1, char *text2) |
Simple case insensitive equal test for strings. | |
static unsigned | ccount (string &object, char *list) |
Count number of occurrances of characters in string object. | |
static unsigned | ccount (char *text, char *list) |
Count instances of characters in a list in a text buffer. | |
static void | chop (string &object, char *list) |
Chop trailing characters from the string. | |
static char * | chop (char *text, char *list) |
Strip trailing characters from the text string. | |
static void | clear (string &object) |
Clear a string object. | |
static int | compare (char *text1, char *text2, size_t size) |
Safe string comparison function. | |
static int | compare (char *text1, char *text2) |
Safe string comparison function. | |
static size_t | count (string &object) |
Count all characters in the string object (strlen). | |
static size_t | count (char *text) |
Safe version of strlen function. | |
static char * | dup (char *text) |
Duplicate null terminated text into the heap. | |
static bool | equal (char *text1, char *text2, size_t size) |
Simple equal test for strings. | |
static bool | equal (char *text1, char *text2) |
Simple equal test for strings. | |
static char * | fill (char *text, size_t size, char character) |
Fill a section of memory with a fixed text character. | |
static char * | find (string &object, char *list) |
Find a character in the string. | |
static char * | find (char *text, char *list) |
Find the first occurance of a character in a text buffer. | |
static char * | find (char *text, char *key, char *optional) |
Find position of substring within a string. | |
static char * | first (string &object, char *list) |
Get pointer to first character past character requested. | |
static char * | first (char *text, char *list) |
Get pointer to first character past character requested. | |
static void | fix (string &object) |
Fix and reset string object filler. | |
static bool | getline (FILE *file, string &object) |
Read a line of text input from a file into the object. | |
static bool | getline (Socket &socket, string &object) |
Read a line of text input from a socket into the object. | |
static unsigned | hexdump (unsigned char *binary, char *string, char *format) |
Dump hex data to a string buffer. | |
static unsigned | hexpack (unsigned char *hex, char *string, char *format) |
Pack hex data from a string buffer. | |
static unsigned | hexsize (char *format) |
static char * | ifind (char *text, char *key, char *optional) |
Find position of case insensitive substring within a string. | |
static char * | last (string &object, char *list) |
Get pointer to last character past character requested. | |
static char * | last (char *text, char *list) |
Get pointer to last character before character requested. | |
static strsize_t | len (string &object) |
Count all characters in the string object (strlen). | |
static void | lower (string &object) |
Convert string object to lower case. | |
static void | lower (char *text) |
Convert null terminated text to lower case. | |
static char * | mem (string &object) |
Get memory text buffer of string object. | |
static strsize_t | printf (string &object, char *format,...) |
Print formatted items into a string object. | |
static bool | putline (FILE *file, string &object) |
Write string as a line of text data to a file. | |
static bool | putline (Socket &socket, string &object) |
Write string as a line of text data to a socket. | |
static int | read (FILE *file, string &object) |
Read arbitrary binary data from a file into a string object. | |
static int | read (Socket &socket, string &object) |
Read arbitrary binary data from socket into a string object. | |
static char * | rfind (string &object, char *list) |
Find last character in the string. | |
static char * | rfind (char *text, char *list) |
Find the last occurance of a character in a text buffer. | |
static char * | rset (char *buffer, size_t size, char *text) |
Set a field in a null terminated string relative to the end of text. | |
static char * | rskip (char *text, char *list) |
Skip before trailing characters in a null terminated string. | |
static char * | set (char *buffer, size_t size, char *text, size_t max) |
Safely set a null terminated string buffer in memory. | |
static char * | set (char *buffer, size_t size, char *text) |
Safely set a null terminated string buffer in memory. | |
static strsize_t | size (string &object) |
Get the size of currently allocated space for string. | |
static char * | skip (char *text, char *list) |
Skip after lead characters in a null terminated string. | |
static void | strip (string &object, char *list) |
Strip lead and trailing characters from the string. | |
static char * | strip (char *text, char *list) |
Skip lead and remove trailing characters from a text string. | |
static void | swap (string &object1, string &object2) |
Swap the cstring references between two strings. | |
static double | tod (char *text, char **pointer=((void *) 0)) |
Convert text to a double value. | |
static double | tod (string &object, char **pointer=((void *) 0)) |
Convert string to a double value. | |
static char * | token (string &object, char **last, char *list, char *quote=((void *) 0), char *end=((void *) 0)) |
A thread-safe token parsing routine for strings objects. | |
static char * | token (char *text, char **last, char *list, char *quote=((void *) 0), char *end=((void *) 0)) |
A thread-safe token parsing routine for null terminated strings. | |
static long | tol (char *text, char **pointer=((void *) 0)) |
Convert text to a long value. | |
static long | tol (string &object, char **pointer=((void *) 0)) |
Convert string to a long value. | |
static void | trim (string &object, char *list) |
Trim lead characters from the string. | |
static char * | trim (char *text, char *list) |
Return start of string after characters to trim from beginning. | |
static bool | unquote (string &object, char *quote) |
Unquote a quoted string. | |
static char * | unquote (char *text, char *quote) |
Unquote a quoted null terminated string. | |
static void | upper (string &object) |
Convert string object to upper case. | |
static void | upper (char *text) |
Convert null terminated text to upper case. | |
static strsize_t | vprintf (string &object, char *format, va_list args) |
Print items into a string object. | |
static int | write (FILE *file, string &object) |
Write the string object to a file. | |
static int | write (Socket &socket, string &object) |
Write the string object to a socket. | |
Static Public Attributes | |
static strsize_t | npos |
A constant for an invalid position value. | |
Protected Member Functions | |
virtual cstring * | c_copy (void) |
Return cstring to use in copy constructors. | |
virtual int | compare (char *string) |
Compare the values of two string. | |
virtual void | cow (strsize_t size=0) |
Copy on write operation for cstring. | |
cstring * | create (strsize_t size, char fill=0) |
Factory create a cstring object of specified size. | |
bool | equal (char *string) |
Test if two string values are equal. | |
strsize_t | getStringSize (void) |
virtual void | release (void) |
Decrease retention of our reference counted cstring. | |
virtual void | retain (void) |
Increase retention of our reference counted cstring. | |
Protected Attributes | |
cstring * | str |
cstring instance our object references. | |
Friends | |
class | StringFormat |
A copy-on-write string class that operates by reference count.
This string class anchors a counted object that is managed as a copy-on-write instance of the string data. This means that multiple instances of the string class can refer to the same string in memory if it has not been modifed, which reduces heap allocation. The string class offers functions to manipulate both the string object, and generic safe string functions to manipulate ordinary null terminated character arrays directly in memory.
Definition at line 77 of file string.h.
ucc::string::string | ( | StringFormat & | format | ) |
Create a string from a formatting object.
format | object to use in creating string. |
ucc::string::string | ( | strsize_t | size | ) |
Create an empty string with a buffer pre-allocated to a specified size.
size | of buffer to allocate. |
ucc::string::string | ( | strsize_t | size, | |
char | fill | |||
) |
Create a filled string with a buffer pre-allocated to a specified size.
size | of buffer to allocate. | |
fill | character to use. |
ucc::string::string | ( | strsize_t | size, | |
char * | format, | |||
... | ||||
) |
Create a string by printf-like formating into a pre-allocated space of a specified size.
size | of buffer to allocate. | |
format | control for string. |
ucc::string::string | ( | char * | text | ) |
Create a string from null terminated text.
text | to use for string. |
ucc::string::string | ( | char * | text, | |
strsize_t | size | |||
) |
Create a string from null terminated text up to a maximum specified size.
text | to use for string. | |
size | limit of new string. |
ucc::string::string | ( | char * | text, | |
char * | end | |||
) |
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::string::string | ( | string & | existing | ) |
Construct a copy of a string object.
Our copy inherets the same reference counted instance of cstring as in the original.
existing | string to copy from. |
virtual ucc::string::~string | ( | ) | [virtual] |
Destroy string.
De-reference cstring. If last reference to cstring, then also remove cstring from heap.
static int ucc::string::__isoc99_scanf | ( | string & | object, | |
char * | format, | |||
... | ||||
) | [static] |
Scan input items from a string object.
object | to scan from. | |
format | string of input to scan. |
int ucc::string::__isoc99_scanf | ( | char * | format, | |
... | ||||
) |
Scan input items from a string object.
format | string of input to scan. |
static int ucc::string::__isoc99_vscanf | ( | string & | object, | |
char * | format, | |||
va_list | args | |||
) | [inline, static] |
int ucc::string::__isoc99_vscanf | ( | char * | format, | |
va_list | args | |||
) |
Scan input items from a string object.
format | string of input to scan. | |
args | list to scan into. |
static char* ucc::string::add | ( | char * | buffer, | |
size_t | size, | |||
char * | text, | |||
size_t | max | |||
) | [static] |
Safely append a null terminated string into an existing string in memory.
If the resulting string is too large to fit into the buffer, it is truncated to the size.
buffer | to set. | |
size | of buffer. Includes null byte at end of string. | |
text | to set in buffer. | |
max | size of text to append. |
static char* ucc::string::add | ( | char * | buffer, | |
size_t | size, | |||
char * | text | |||
) | [static] |
Safely append a null terminated string into an existing string in memory.
If the resulting string is too large to fit into the buffer, it is truncated to the size.
buffer | to set. | |
size | of buffer. Includes null byte at end of string. | |
text | to set in buffer. |
void ucc::string::add | ( | char | character | ) |
Append a single character to our string buffer.
character | to append. |
void ucc::string::add | ( | char * | text | ) |
Append null terminated text to our string buffer.
text | to append. |
void ucc::string::add | ( | StringFormat & | format | ) |
Append formatted object to our string buffer.
format | object to append. |
char ucc::string::at | ( | int | position | ) |
Return character found at a specific position in the string.
position | in string, negative values computed from end. |
Reimplemented in ucc::UString.
char* ucc::string::begin | ( | void | ) |
Get pointer to first character in string for iteration.
virtual cstring* ucc::string::c_copy | ( | void | ) | [protected, virtual] |
Return cstring to use in copy constructors.
Is virtual for memstring.
Reimplemented in ucc::memstring.
char* ucc::string::c_mem | ( | void | ) |
Get memory text buffer of string object.
char* ucc::string::c_str | ( | void | ) |
Get character text buffer of string object.
static int ucc::string::case_compare | ( | char * | text1, | |
char * | text2, | |||
size_t | size | |||
) | [static] |
Safe case insensitive string comparison function.
text1 | to compare. | |
text2 | to compare. | |
size | limit of strings to compare. |
static int ucc::string::case_compare | ( | char * | text1, | |
char * | text2 | |||
) | [static] |
Safe case insensitive string comparison function.
text1 | to compare. | |
text2 | to compare. |
static bool ucc::string::case_equal | ( | char * | text1, | |
char * | text2, | |||
size_t | size | |||
) | [static] |
Simple case insenstive equal test for strings.
text1 | to test. | |
text2 | to test. | |
size | limit of strings to compare. |
static bool ucc::string::case_equal | ( | char * | text1, | |
char * | text2 | |||
) | [static] |
Simple case insensitive equal test for strings.
text1 | to test. | |
text2 | to test. |
static unsigned ucc::string::ccount | ( | string & | object, | |
char * | list | |||
) | [inline, static] |
static unsigned ucc::string::ccount | ( | char * | text, | |
char * | list | |||
) | [static] |
Count instances of characters in a list in a text buffer.
text | buffer to examine. | |
list | of characters to count in buffer. |
strsize_t ucc::string::ccount | ( | char * | list | ) |
Count number of occurrances of characters in string.
list | of characters to find. |
static void ucc::string::chop | ( | string & | object, | |
char * | list | |||
) | [inline, static] |
static char* ucc::string::chop | ( | char * | text, | |
char * | list | |||
) | [static] |
Strip trailing characters from the text string.
This function will modify memory.
text | buffer to examine. | |
list | of characters to chop from trailing end of string. |
void ucc::string::chop | ( | char * | list | ) |
Chop trailing characters from the string.
list | of characters to remove. |
char* ucc::string::chr | ( | char | character | ) |
Find pointer in string where specified character appears.
character | to find. |
static void ucc::string::clear | ( | string & | object | ) | [inline, static] |
Clear a field of a filled string with filler.
offset | to start of field to clear. | |
size | of field to fill or 0 to fill to end of string. |
static int ucc::string::compare | ( | char * | text1, | |
char * | text2, | |||
size_t | size | |||
) | [static] |
Safe string comparison function.
text1 | to compare. | |
text2 | to compare. | |
size | limit of strings to compare. |
static int ucc::string::compare | ( | char * | text1, | |
char * | text2 | |||
) | [static] |
Safe string comparison function.
text1 | to compare. | |
text2 | to compare. |
virtual int ucc::string::compare | ( | char * | string | ) | [protected, virtual] |
Compare the values of two string.
This is a virtual so that it can be overriden for example if we want to create strings which ignore case, or which have special ordering rules.
string | to compare with. |
static size_t ucc::string::count | ( | string & | object | ) | [inline, static] |
static size_t ucc::string::count | ( | char * | text | ) | [static] |
Safe version of strlen function.
Accepts NULL as 0 length strings.
text | string. |
strsize_t ucc::string::count | ( | void | ) |
Count all characters in the string (strlen).
Reimplemented in ucc::UString.
virtual void ucc::string::cow | ( | strsize_t | size = 0 |
) | [protected, virtual] |
Copy on write operation for cstring.
This always creates a new unique copy for write/modify operations and is a virtual for memstring to disable.
size | to add to allocated space when creating new cstring. |
Factory create a cstring object of specified size.
size | of allocated space for string buffer. | |
fill | character to use or 0 if null. |
Reimplemented in ucc::memstring.
Cut (remove) text from string.
offset | to start of text field to remove. | |
size | of text field to remove or 0 to remove to end of string. |
static char* ucc::string::dup | ( | char * | text | ) | [static] |
Duplicate null terminated text into the heap.
text | to duplicate. |
char* ucc::string::end | ( | void | ) |
Get pointer to last character in string for iteration.
static bool ucc::string::equal | ( | char * | text1, | |
char * | text2, | |||
size_t | size | |||
) | [static] |
Simple equal test for strings.
text1 | to test. | |
text2 | to test. | |
size | limit of strings to compare. |
static bool ucc::string::equal | ( | char * | text1, | |
char * | text2 | |||
) | [static] |
Simple equal test for strings.
text1 | to test. | |
text2 | to test. |
bool ucc::string::equal | ( | char * | string | ) | [protected] |
Test if two string values are equal.
string | to compare with. |
static char* ucc::string::fill | ( | char * | text, | |
size_t | size, | |||
char | character | |||
) | [static] |
Fill a section of memory with a fixed text character.
Adds a null byte at the end.
text | buffer to fill. | |
size | of text buffer with null terminated byte. | |
character | to fill with. |
char ucc::string::fill | ( | void | ) |
Get filler character used for field array strings.
static char* ucc::string::find | ( | string & | object, | |
char * | list | |||
) | [inline, static] |
static char* ucc::string::find | ( | char * | text, | |
char * | list | |||
) | [static] |
Find the first occurance of a character in a text buffer.
text | buffer to examine. | |
list | of characters to search for. |
static char* ucc::string::find | ( | char * | text, | |
char * | key, | |||
char * | optional | |||
) | [static] |
Find position of substring within a string.
text | to search in. | |
key | string to locate. | |
optional | separator chars if formatted as list of keys. |
char* ucc::string::find | ( | char * | list, | |
strsize_t | offset = 0 | |||
) |
Find a character in the string.
list | of characters to search for. | |
offset | to start of search. |
static char* ucc::string::first | ( | string & | object, | |
char * | list | |||
) | [inline, static] |
static char* ucc::string::first | ( | char * | text, | |
char * | list | |||
) | [static] |
Get pointer to first character past character requested.
text | buffer to examine. | |
list | of characters. |
char* ucc::string::first | ( | char * | list | ) |
Find first occurance of a character in the string.
list | of characters to search for. |
static void ucc::string::fix | ( | string & | object | ) | [static] |
Fix and reset string object filler.
object | to fix. |
bool ucc::string::full | ( | void | ) |
Test if the string's allocated space is all used up.
Get a new string object as a substring of the current object.
offset | of substring. | |
size | of substring or 0 if to end. |
Reimplemented in ucc::UString.
static bool ucc::string::getline | ( | FILE * | file, | |
string & | object | |||
) | [static] |
Read a line of text input from a file into the object.
The maximum number of bytes that may be read is based on the currently allocated size of the object.
file | to read from. | |
object | to save read data. |
Read a line of text input from a socket into the object.
The maximum number of bytes that may be read is based on the currently allocated size of the object.
socket | to read from. | |
object | to save read data. |
static unsigned ucc::string::hexdump | ( | unsigned char * | binary, | |
char * | string, | |||
char * | format | |||
) | [static] |
Dump hex data to a string buffer.
binary | memory to dump. | |
string | to save into. | |
format | string to convert with. |
static unsigned ucc::string::hexpack | ( | unsigned char * | hex, | |
char * | string, | |||
char * | format | |||
) | [static] |
Pack hex data from a string buffer.
binary | memory to pack. | |
string | to save into. | |
format | string to convert with. |
static char* ucc::string::ifind | ( | char * | text, | |
char * | key, | |||
char * | optional | |||
) | [static] |
Find position of case insensitive substring within a string.
text | to search in. | |
key | string to locate. | |
optional | separator chars if formatted as list of keys. |
static char* ucc::string::last | ( | string & | object, | |
char * | list | |||
) | [inline, static] |
static char* ucc::string::last | ( | char * | text, | |
char * | list | |||
) | [static] |
Get pointer to last character before character requested.
text | buffer to examine. | |
list | of characters. |
char* ucc::string::last | ( | char * | list | ) |
Find last occurance of a character in the string.
list | of characters to search for. |
strsize_t ucc::string::len | ( | void | ) |
Get length of string.
static void ucc::string::lower | ( | string & | object | ) | [inline, static] |
static void ucc::string::lower | ( | char * | text | ) | [static] |
Convert null terminated text to lower case.
text | to convert. |
static char* ucc::string::mem | ( | string & | object | ) | [inline, static] |
strsize_t ucc::string::offset | ( | char * | pointer | ) |
Find offset of a pointer into our string buffer.
This can be used to find the offset position of a pointer returned by find, for example. This is used when one needs to convert a member function that returns a pointer to call a member function that operates by a offset value. If the pointer is outside the range of the string then npos is returned.
pointer | into our object's string buffer. |
ucc::string::operator bool | ( | ) |
Test if string has data.
ucc::string::operator char * | ( | ) | [inline] |
bool ucc::string::operator! | ( | ) |
Test if string is empty.
bool ucc::string::operator!= | ( | char * | text | ) |
Compare our object with null terminated text.
Compare method is used.
text | to compare with. |
string& ucc::string::operator& | ( | StringFormat & | format | ) |
Concatenate formatted string object to our object.
This directly appends the text to the string buffer and does not resize the object if the existing cstring allocation space is fully used.
format | object to concatenate. |
string& ucc::string::operator& | ( | char * | text | ) |
Concatenate null terminated text to our object.
This directly appends the text to the string buffer and does not resize the object if the existing cstring allocation space is fully used.
text | to concatenate. |
char* ucc::string::operator() | ( | int | offset | ) |
Reference a string in the object by relative offset.
Positive offsets are from the start of the string, negative from the end.
offset | to string position. |
Reimplemented in ucc::UString.
Get a new substring through object expression.
offset | of substring. | |
size | of substring or 0 if to end. |
Reimplemented in ucc::UString.
char* ucc::string::operator* | ( | ) | [inline] |
string& ucc::string::operator+ | ( | StringFormat & | format | ) |
Concatenate string formatted object to our object.
This creates a new copy-on-write instance to hold the concatenated string.
format | object to concatenate. |
string& ucc::string::operator+ | ( | char * | text | ) |
Concatenate null terminated text to our object.
This creates a new copy-on-write instance to hold the concatenated string.
text | to concatenate. |
Delete a specified number of characters from start of string.
number | of characters to delete. |
Delete a specified number of characters from end of string.
number | of characters to delete. |
bool ucc::string::operator< | ( | char * | text | ) |
Compare our object with null terminated text.
Compare method is used.
text | to compare with. |
bool ucc::string::operator<= | ( | char * | text | ) |
Compare our object with null terminated text.
Compare method is used.
text | to compare with. |
string& ucc::string::operator= | ( | char * | text | ) |
Assign text to our existing buffer.
This performs a set method.
text | to assign from. |
Reimplemented in ucc::memstring, and ucc::stringbuf< S >.
string& ucc::string::operator= | ( | StringFormat & | format | ) |
Assign our string from a string formatting object.
format | object to assign from. |
Assign our string with the cstring of another object.
If we had an active string reference, it is released. The object now has a duplicate reference to the cstring of the other object.
object | to assign from. |
Reimplemented in ucc::memstring, and ucc::stringbuf< S >.
bool ucc::string::operator== | ( | char * | text | ) |
Compare our object with null terminated text.
text | to compare with. |
bool ucc::string::operator> | ( | char * | text | ) |
Compare our object with null terminated text.
Compare method is used.
text | to compare with. |
bool ucc::string::operator>= | ( | char * | text | ) |
Compare our object with null terminated text.
Compare method is used.
text | to compare with. |
char ucc::string::operator[] | ( | int | offset | ) |
Reference a single character in string object by array offset.
offset | to character. |
Reimplemented in ucc::UString.
string& ucc::string::operator^= | ( | char * | text | ) |
Create new cow instance and assign value from null terminated text.
text | to assign from. |
string& ucc::string::operator^= | ( | StringFormat & | format | ) |
Create new cow instance and assign value from formatted string object.
format | object to assign from. |
Create new cow instance and assign value from another string object.
object | to assign from. |
Print formatted items into a string object.
object | to print into. | |
format | string to print with. |
strsize_t ucc::string::printf | ( | char * | format, | |
... | ||||
) |
Print items into a string object.
format | string of print format. |
static bool ucc::string::putline | ( | FILE * | file, | |
string & | object | |||
) | [static] |
Write string as a line of text data to a file.
A newline will be appended to the end.
file | to print to. | |
object | to get text line to put into file. |
Write string as a line of text data to a socket.
A newline will be appended to the end.
socket | to print to. | |
object | to get text line from. |
char* ucc::string::rchr | ( | char | character | ) |
Find pointer in string where specified character last appears.
character | to find. |
static int ucc::string::read | ( | FILE * | file, | |
string & | object | |||
) | [static] |
Read arbitrary binary data from a file into a string object.
The total number of bytes that may be read is based on the allocated size of the object.
file | to read from. | |
object | to save read data. |
Read arbitrary binary data from socket into a string object.
The total number of bytes that may be read is based on the allocated size of the object.
socket | to read from. | |
object | to save read data. |
virtual void ucc::string::release | ( | void | ) | [protected, virtual] |
Decrease retention of our reference counted cstring.
May be overriden for memstring which has fixed cstring object.
Reimplemented from ucc::Object.
virtual bool ucc::string::resize | ( | strsize_t | size | ) | [virtual] |
Resize and re-allocate string memory.
size | to allocate for string. |
virtual void ucc::string::retain | ( | void | ) | [protected, virtual] |
Increase retention of our reference counted cstring.
May be overriden for memstring which has fixed cstring object.
Reimplemented from ucc::Object.
static char* ucc::string::rfind | ( | string & | object, | |
char * | list | |||
) | [inline, static] |
static char* ucc::string::rfind | ( | char * | text, | |
char * | list | |||
) | [static] |
Find the last occurance of a character in a text buffer.
text | buffer to examine. | |
list | of characters to search for. |
Find last occurance of character in the string.
list | of characters to search for. | |
offset | to start of search. Default is end of string. |
static char* ucc::string::rset | ( | char * | buffer, | |
size_t | size, | |||
char * | text | |||
) | [static] |
Set a field in a null terminated string relative to the end of text.
buffer | to modify. | |
size | of field to set. | |
text | to replace end of string with. |
Set a text field within our string object offset from the end of buffer.
text | to set. | |
overflow | character to use as filler if text is too short. | |
offset | from end of object string buffer to set text at. | |
size | of part of buffer to set with text and overflow. |
static char* ucc::string::rskip | ( | char * | text, | |
char * | list | |||
) | [static] |
Skip before trailing characters in a null terminated string.
text | pointer to start at. | |
list | of characters to skip when found. |
Skip trailing characters in the string.
This searches the string in reverse order.
list | of characters to skip when found. | |
offset | to start of scan. Default is end of string. |
void ucc::string::rsplit | ( | strsize_t | offset | ) |
Split the string at a specific offset.
Everything before the offset is removed.
offset | to split position in string. |
void ucc::string::rsplit | ( | char * | pointer | ) |
Split the string by a pointer position.
Everything before the pointer is removed.
pointer | to split position in string. |
static char* ucc::string::set | ( | char * | buffer, | |
size_t | size, | |||
char * | text, | |||
size_t | max | |||
) | [static] |
Safely set a null terminated string buffer in memory.
If the text is too large to fit into the buffer, it is truncated to the size.
buffer | to set. | |
size | of buffer. Includes null byte at end of string. | |
text | to set in buffer. | |
max | size of text to set. |
static char* ucc::string::set | ( | char * | buffer, | |
size_t | size, | |||
char * | text | |||
) | [static] |
Safely set a null terminated string buffer in memory.
If the text is too large to fit into the buffer, it is truncated to the size.
buffer | to set. | |
size | of buffer. Includes null byte at end of string. | |
text | to set in buffer. |
Set a text field within our string object.
text | to set. | |
overflow | character to use as filler if text is too short. | |
offset | in object string buffer to set text at. | |
size | of part of buffer to set with text and overflow. |
Set a portion of the string object at a specified offset to a text string.
offset | in object string buffer. | |
text | to set at offset. | |
size | of text area to set or 0 until end of text. |
void ucc::string::set | ( | StringFormat & | format | ) |
Set string object to text of a formatted object.
format | object to use. |
void ucc::string::set | ( | char * | text | ) |
Set string object to text of a null terminated string.
text | string to set. |
strsize_t ucc::string::size | ( | void | ) |
Get the size of currently allocated space for string.
static char* ucc::string::skip | ( | char * | text, | |
char * | list | |||
) | [static] |
Skip after lead characters in a null terminated string.
text | pointer to start at. | |
list | of characters to skip when found. |
char* ucc::string::skip | ( | char * | list, | |
strsize_t | offset = 0 | |||
) |
Skip lead characters in the string.
list | of characters to skip when found. | |
offset | to start of scan. |
void ucc::string::split | ( | strsize_t | offset | ) |
Split the string at a specific offset.
Everything after the offset is removed.
offset | to split position in string. |
void ucc::string::split | ( | char * | pointer | ) |
Split the string by a pointer position.
Everything after the pointer is removed.
pointer | to split position in string. |
static void ucc::string::strip | ( | string & | object, | |
char * | list | |||
) | [inline, static] |
static char* ucc::string::strip | ( | char * | text, | |
char * | list | |||
) | [static] |
Skip lead and remove trailing characters from a text string.
This function will modify memory.
text | buffer to examine. | |
list | of characters to trim and chop. |
void ucc::string::strip | ( | char * | list | ) |
Strip lead and trailing characters from the string.
list | of characters to remove. |
Swap the cstring references between two strings.
object1 | to swap. | |
object2 | to swap. |
static double ucc::string::tod | ( | char * | text, | |
char ** | pointer = ((void *)0) | |||
) | [inline, static] |
static double ucc::string::tod | ( | string & | object, | |
char ** | pointer = ((void *)0) | |||
) | [inline, static] |
static char* ucc::string::token | ( | string & | object, | |
char ** | last, | |||
char * | list, | |||
char * | quote = ((void *)0) , |
|||
char * | end = ((void *)0) | |||
) | [inline, static] |
A thread-safe token parsing routine for strings objects.
This is related to strtok, but with safety checks for NULL values and a number of enhancements including support for quoted text that may contain token seperators within quotes. The object is modified as it is parsed.
object | to examine for tokens. | |
last | token position or set to NULL for start of string. | |
list | of characters to use as token seperators. | |
quote | pairs of characters for quoted text or NULL if not used. | |
end | of line marker characters or NULL if not used. |
Definition at line 1230 of file string.h.
static char* ucc::string::token | ( | char * | text, | |
char ** | last, | |||
char * | list, | |||
char * | quote = ((void *) 0) , |
|||
char * | end = ((void *) 0) | |||
) | [static] |
A thread-safe token parsing routine for null terminated strings.
This is related to strtok, but with safety checks for NULL values and a number of enhancements including support for quoted text that may contain token seperators within quotes. The text string is modified as it is parsed.
text | string to examine for tokens. | |
last | token position or set to NULL for start of string. | |
list | of characters to use as token seperators. | |
quote | pairs of characters for quoted text or NULL if not used. | |
end | of line marker characters or NULL if not used. |
static long ucc::string::tol | ( | char * | text, | |
char ** | pointer = ((void *)0) | |||
) | [inline, static] |
static long ucc::string::tol | ( | string & | object, | |
char ** | pointer = ((void *)0) | |||
) | [inline, static] |
static void ucc::string::trim | ( | string & | object, | |
char * | list | |||
) | [inline, static] |
static char* ucc::string::trim | ( | char * | text, | |
char * | list | |||
) | [static] |
Return start of string after characters to trim from beginning.
This function does not modify memory.
text | buffer to examine. | |
list | of characters to skip from start. |
void ucc::string::trim | ( | char * | list | ) |
Trim lead characters from the string.
list | of characters to remove. |
static bool ucc::string::unquote | ( | string & | object, | |
char * | quote | |||
) | [inline, static] |
static char* ucc::string::unquote | ( | char * | text, | |
char * | quote | |||
) | [static] |
Unquote a quoted null terminated string.
Returns updated string position and replaces trailing quote with null byte if quoted.
text | to examine. | |
quote | pairs of character for open and close quote. |
bool ucc::string::unquote | ( | char * | quote | ) |
Unquote a quoted string.
Removes lead and trailing quote marks.
quote | pairs of characters for open and close quote. |
static void ucc::string::upper | ( | string & | object | ) | [inline, static] |
static void ucc::string::upper | ( | char * | text | ) | [static] |
Convert null terminated text to upper case.
text | to convert. |
strsize_t ucc::string::vprintf | ( | char * | format, | |
va_list | args | |||
) |
Print items into a string object.
format | string of print format. | |
args | list to print. |
static int ucc::string::write | ( | FILE * | file, | |
string & | object | |||
) | [static] |
Write the string object to a file.
file | to write to. | |
object | to get data from. |
Write the string object to a socket.
socket | to write to. | |
object | to get data from. |
cstring* ucc::string::str [protected] |