C++ bindings for cgul_wstring
More...
#include <cgul_wstring_cxx.h>
Public Member Functions | |
cgul_wstring_cxx () | |
cgul_wstring_cxx (const cgul_wstring_cxx &rhs) | |
cgul_wstring_cxx (const cgul_wchar_t *rhs) | |
virtual | ~cgul_wstring_cxx () |
virtual cgul_wstring_cxx & | operator= (const cgul_wstring_cxx &rhs) |
virtual cgul_wstring_cxx & | operator= (const cgul_wchar_t *rhs) |
virtual cgul_wstring_cxx & | operator+= (const cgul_wstring_cxx &rhs) |
virtual cgul_wstring_cxx & | operator+= (const cgul_wchar_t *rhs) |
virtual cgul_wchar_t & | operator[] (size_t index) |
virtual const cgul_wchar_t & | operator[] (size_t index) const |
virtual | operator cgul_wchar_t * () const |
virtual cgul_wchar_t * | get_value () const |
virtual cgul_wchar_t * | take_value () |
virtual cgul_wchar_t | get_value_at (size_t index) const |
virtual void | set_value (const cgul_wchar_t *value) |
virtual void | clear () |
virtual signed char | to_schar (int base=0) |
virtual unsigned char | to_uchar (int base=0) |
virtual short int | to_short (int base=0) |
virtual unsigned short int | to_ushort (int base=0) |
virtual int | to_int (int base=0) |
virtual unsigned int | to_unsigned (int base=0) |
virtual long int | to_long (int base=0) |
virtual unsigned long int | to_unsigned_long (int base=0) |
virtual double | to_double () |
virtual void | append (const cgul_wchar_t *value) |
virtual void | append_block (const void *block, size_t block_size) |
virtual void | append_char (cgul_wchar_t c) |
virtual void | insert (size_t index, const cgul_wchar_t *value, size_t value_length) |
virtual void | insert_char (size_t index, cgul_wchar_t value) |
virtual void | pad_right (size_t width, cgul_wchar_t pad) |
virtual void | pad_left (size_t width, cgul_wchar_t pad) |
virtual void | trim () |
virtual void | trim_left () |
virtual void | trim_right () |
virtual void | reverse () |
virtual size_t | get_length () const |
virtual size_t | set_length (size_t length) |
virtual void | externally_adjusted () |
virtual void | trim_capacity () |
virtual size_t | get_minimum_capacity () const |
virtual void | set_minimum_capacity (size_t minimum_capacity) |
virtual int | compare (const cgul_wstring_cxx &rhs) |
virtual void | swap (cgul_wstring_cxx &rhs) |
virtual cgul_wstring_t | get_obj () const |
virtual cgul_wstring_t | take_obj () |
virtual void | set_obj (cgul_wstring_t rhs) |
This class provides the C++ bindings for C cgul_wstring
objects. The main purpose of this class is to convert the C-style function calls and exception handling in cgul_wstring
into C++-style function calls and exception handling.
|
inline |
Default constructor that creates a new instance with an empty string.
References cgul_wstring__new().
|
inline |
Copy constructor that creates a new instance by copying the value from rhs
.
[in] | rhs | right-hand side |
References cgul_wstring__new_from_wcstring(), and get_value().
|
inline |
Copy constructor that creates a new instance by copying the value from rhs
.
[in] | rhs | right-hand side |
References cgul_wstring__new_from_wcstring().
|
inlinevirtual |
Destructor.
References cgul_wstring__delete().
|
inlinevirtual |
Assign the value from rhs
to this object and return this object.
[in] | rhs | right-hand side |
References cgul_wstring__set_value(), and get_value().
|
inlinevirtual |
Assign the value from rhs
to this object and return this object.
[in] | rhs | right-hand side |
References cgul_wstring__set_value().
|
inlinevirtual |
Append the value from rhs
to this object and return this object.
[in] | rhs | right-hand side |
References cgul_wstring__append(), and get_value().
|
inlinevirtual |
Append the value from rhs
to this object and return this object.
[in] | rhs | right-hand side |
References cgul_wchar_t, and cgul_wstring__append().
|
inlinevirtual |
Index operator that returns the wide character at index
. If index
is out of bounds, an exception is thrown.
References cgul_exception__new(), cgul_wchar_t, cgul_wstring__get_length(), and cgul_wstring__get_value().
|
inlinevirtual |
Index operator that returns the wide character at index
. If index
is out of bounds, an exception is thrown. This is the overloaded operator[]()
that is necessary for use with const
objects.
References cgul_exception__new(), cgul_wchar_t, cgul_wstring__get_length(), and cgul_wstring__get_value().
|
inlinevirtual |
This method allows instances of this class to be cast to C-style strings.
References cgul_wchar_t, and get_value().
|
inlinevirtual |
This method returns a pointer to the internal C-style string. You are allowed to manually set individual characters in the string. Just remember to call externally_adjusted()
afterward. Compare this method to the take_value()
method.
References cgul_wchar_t, and cgul_wstring__get_value().
Referenced by cgul_wstring_cxx(), operator cgul_wchar_t *(), operator+=(), and operator=().
|
inlinevirtual |
This method lets you take ownership of the underlying C-style string which is returned. Immediately upon taking ownership, the internal state of this class is reset including resetting a new underlying C-style string to be empty. One use of this function is to build up a string using cgul_wstring
that you then pass to cgul_hash
or cgul_rbtree
. Compare this function with get_value()
.
References cgul_wchar_t, and cgul_wstring__take_value().
|
inlinevirtual |
This method returns the character indicated by index
where index
is zero-based. If index
is out of bounds, an exception is thrown.
[in] | index | index into the string |
index
References cgul_wchar_t, and cgul_wstring__get_value_at().
|
inlinevirtual |
Set the value of the underlying c-style string to value. If an error occurs, an exception is thrown.
[in] | value | new value |
References cgul_wstring__set_value().
|
inlinevirtual |
This method is equivalent to calling set_value()
where value
is an empty string.
References cgul_wstring__clear().
|
inlinevirtual |
This method converts the string to a signed char
. Typically, "base" will be set to 0 to allow conversion for decimal, hexadecimal, and octal based on the leading character in the string. The string cannot have any extraneous characters. If it does, the conversion will fail. On success, the converted value is returned; otherwise, 0 is returned and an exception is thrown.
[in] | base | base to use for the conversion |
References cgul_wstring__to_schar().
|
inlinevirtual |
This method converts the string to an unsigned char
. Typically, base
will be set to 0 to allow conversion for decimal, hexadecimal, and octal based on the leading characters in the string. The string cannot have any extraneous characters. If it does, the conversion will fail. On success, the converted value is returned; otherwise, 0 is returned and an exception is thrown.
[in] | base | base to use for the conversion |
References cgul_wstring__to_uchar().
|
inlinevirtual |
This method converts the string to a short
. Typically, "base" will be set to 0 to allow conversion for decimal, hexadecimal, and octal based on the leading character in the string. The string cannot have any extraneous characters. If it does, the conversion will fail. On success, the converted value is returned; otherwise, 0 is returned and an exception is thrown.
[in] | base | base to use for the conversion |
References cgul_wstring__to_short().
|
inlinevirtual |
This method converts the string to an unsigned short
. Typically, base
will be set to 0 to allow conversion for decimal, hexadecimal, and octal based on the leading characters in the string. The string cannot have any extraneous characters. If it does, the conversion will fail. On success, the converted value is returned; otherwise, 0 is returned and an exception is thrown.
[in] | base | base to use for the conversion |
References cgul_wstring__to_ushort().
|
inlinevirtual |
This method converts the string to an int
. Typically, "base" will be set to 0 to allow conversion for decimal, hexadecimal, and octal based on the leading character in the string. The string cannot have any extraneous characters. If it does, the conversion will fail. On success, the converted value is returned; otherwise, 0 is returned and an exception is thrown.
[in] | base | base to use for the conversion |
References cgul_wstring__to_int().
|
inlinevirtual |
This method converts the string to an unsigned
. Typically, base
will be set to 0 to allow conversion for decimal, hexadecimal, and octal based on the leading characters in the string. The string cannot have any extraneous characters. If it does, the conversion will fail. On success, the converted value is returned; otherwise, 0 is returned and an exception is thrown.
[in] | base | base to use for the conversion |
References cgul_wstring__to_unsigned().
|
inlinevirtual |
This method converts the string to a long
. Typically, base
will be set to 0 to allow conversion for decimal, hexadecimal, and octal based on the leading characters in the string. The string cannot have any extraneous characters. If it does, the conversion will fail. On success, the converted value is returned; otherwise, 0 is returned and an exception is thrown.
[in] | base | base to use for the conversion |
References cgul_wstring__to_long().
|
inlinevirtual |
This method converts the string to an unsigned long
. Typically, base
will be set to 0 to allow conversion for decimal, hexadecimal, and octal based on the leading characters in the string. The string cannot have any extraneous characters. If it does, the conversion will fail. On success, the converted value is returned; otherwise, 0 is returned and an exception is thrown.
[in] | base | base to use for the conversion |
References cgul_wstring__to_unsigned_long().
|
inlinevirtual |
This method converts the string to a double
. The string cannot have any extraneous characters. If it does, the conversion will fail. On success, the converted value is returned; otherwise, 0.0 is returned and an exception is thrown.
References cgul_wstring__to_double().
|
inlinevirtual |
Appends value
to the string. If an error occurs, an exception is thrown.
[in] | value | value to append |
References cgul_wstring__append().
|
inlinevirtual |
Append a block of non-CGUL_WCHAR__NUL
characters. The caller should verify that there are no embedded NUL characters in the string. If an error occurs, an exception is thrown.
[in] | block | block to append |
[in] | block_size | size of block to append |
References cgul_wstring__append_block().
|
inlinevirtual |
Append c
to the string.
[in] | c | wide character to append |
References cgul_wstring__append_char().
|
inlinevirtual |
Inserts value
at index
which can range from 0 to the length (inclusive) of this string. If index
is out of bounds or if memory cannot be allocated, an exception is thrown.
[in] | index | index where value is inserted |
[in] | value | value to insert |
[in] | value_length | length of value |
References cgul_wstring__insert().
|
inlinevirtual |
Inserts value
at index
which can range from 0 to the length (inclusive) of this string. If index
is out of bounds or if memory cannot be allocated, an exception is thrown.
[in] | index | index where value is inserted |
[in] | value | value to insert |
References cgul_wstring__insert_char().
|
inlinevirtual |
Pad the current string such that it is at least width
characters wide using the pad
character. The string will be right aligned.
[in] | width | padding width |
[in] | pad | character to use for padding |
References cgul_wstring__pad_right().
|
inlinevirtual |
Pad the current string such that it is at least width
characters wide using the pad
character. The string will be left aligned.
[in] | width | padding width |
[in] | pad | character to use for padding |
References cgul_wstring__pad_left().
|
inlinevirtual |
Trim the string by removing leading and trailing white-space where white-space is definded by cgul_wchar::isspace()
.
References cgul_wstring__trim().
|
inlinevirtual |
Trim the string by removing leading white-space where white-space is definded by cgul_wchar::isspace()
.
References cgul_wstring__trim_left().
|
inlinevirtual |
Trim the string by removing trailing white-space where white-space is definded by cgul_wchar::isspace()
.
References cgul_wstring__trim_right().
|
inlinevirtual |
Reverse the order of the characters in the string.
References cgul_wstring__reverse().
|
inlinevirtual |
This method returns the length of the string.
References cgul_wstring__get_length().
|
inlinevirtual |
This method can be used to set the length of the string. It can only be used to make the string shorter. If it is used in an attempt to make the string longer, an exception is thrown. If the length of the string is successfully changed, the previous length of the string is returned.
[in] | length | new, shorter length of the string |
References cgul_wstring__set_length().
|
inlinevirtual |
If you manually alter the underlying buffer by modifying the cgul_wchar_t*
string returned by get_value()
, you'll need to manually have the class reset its internal state.
References cgul_wstring__externally_adjusted().
|
inlinevirtual |
Trim the string by returning excess capacity to the heap.
References cgul_wstring__trim_capacity().
|
inlinevirtual |
|
inlinevirtual |
Set the minimum capacity. The default value is 128
which means there is always capacity for 127 characters plus one NUL-terminator. Decreasing the capacity will decrease the amount of space used and (typically) also decrease performance. If an error occurs, an exception is thrown.
[in] | minimum_capacity | minimum capacity |
References cgul_wstring__set_minimum_capacity().
|
inlinevirtual |
Perform a case-significant wide-character string comparison of *this
and rhs
. Return -1, 0, or 1 if *this
is less than, equal to, or greater than rhs
respectively.
For simplicity, this function compares strings stricly by the ordinal value of each character which should be sufficient, for example, when inserting entire cgul_wstring_cxx
objects as keys into a cgul_rbtree_cxx
object; however, the comparison results are not likely to be the same as what strcoll()
would return if used on the UTF-8 version of the strings.
cgul_wchar_cxx::wcscmp()
instead if inserting raw cgul_wchar
strings as keys into a cgul_rbtree_cxx
object. [in] | rhs | right-hand side |
*this
is less than, equal to, or greater than rhs
respectively References cgul_wstring__compare().
|
inlinevirtual |
Swap the underlying data for this object and rhs
. For large strings, this should be much faster than trying to do the same thing using set_value()
.
[in] | rhs | right-hand side |
References cgul_wstring__swap().
|
inlinevirtual |
Get the underlying cgul_wstring
object.
Referenced by cgul_unicode_cxx::hcstowcs(), cgul_unicode_cxx::mbstowcs(), cgul_line_wrapper_cxx::wrap_utf32_at_column(), and cgul_line_wrapper_cxx::wrap_utf32_at_width().
|
inlinevirtual |
Take the underlying cgul_wstring
object. This means the underlying object will not be deleted when the wrapper goes out of scope. Also, because you have taken the underlying object, no other methods should be called on this wrapper's instance. Lastly, after taking the underlying object, it is the caller's responsibility to delete the underlying object by calling cgul_wstring__delete()
.
|
inlinevirtual |
Set the new underlying object to rhs
. This causes the old underlying object to be deleted which invalidates any outstanding pointers to or iterators for the old underlying object.
This instance takes ownership of rhs
which means rhs
will be automatically deleted when the C++ wrapper is deleted. To prevent automatic deletion of rhs
, call take_obj()
when the C++ wrapper is no longer needed.
[in] | rhs | right-hand side |
References cgul_wstring__delete().