class String
MyCpp::Referenced
MyCpp::Object
MyCpp::String

String data type.

Internally all strings are "null-terminated", i.e. the last byte of each string is zero.

Null strings and empty strings are not the same. Null strings are those for which the isNullString method returns true. Empty strings are non-null strings containing zero characters. This is useful for distinction between empty string values and undefined values.

Both null strings and empty strings are represented as a single byte containing zero. It is guaranteed that none of this class's methods will ever return a NULL pointer.

Methods
String&
operator = (String &str)
Makes a copy of a string contained in a given String object.
String&
operator = (const char *str)
Makes a copy of a given string.
operator const
char () const
Returns a pointer to the string contained in this String object.
const bool
operator == (const char *str)
Performs symbol-by-symbol comparison between the string contained in this String object and a given string.
const bool
operator > (const char *str)
Performs an alphabetic comparison between the string contained in this String object and a given string.
const bool
operator == (const String &s)
Performs symbol-by-symbol comparison between the string contained in this String object and a string contained in a given String object.
const bool
operator > (const String &s)
Performs symbol-by-symbol comparison between the string contained in this String object and a string contained in a given String object.
const char*
getData () const
Returns a pointer to the string contained in this String object.
void
setStatic (const char *str)
Assigns a given string to this String object without copying the string.
void
setOwn (const char *str, FreeCallback freeCallback = dynamicFreeCallback)
Assigns a given string to this String object without copying the string, but with granting "the ownership" of the string to the String object.
void
set (const char *str, unsigned len = 0)
Assigns a given string to this String object by creating a copy of the string.
static Ref<String>
staticString (const char *str)
Creates a new String object and assigns a given string to it as a static string.
static Ref<String>
ownString (const char *str, FreeCallback freeCallback = dynamicFreeCallback)
Creates a new String object and assignes a given string to it by granting "the ownership".
static Ref<String>
forFormat (const char *fmt, ...)
Creates a new String object and initializes it with a string formed according to the specified format.
static Ref<String>
nullString ()
Returns a reference to the "null" string.
bool
isNullString ()
Determines whether this string is a "null" string or not.
String ()
The defaultl constructor.
String (String &str)
The copying constructor.
String (const char *str)
The constructor. Assigns a given string to the constructed String object.
operator =

Makes a copy of a string contained in a given String object.

String& operator = (String &str)
operator =

Makes a copy of a given string.

String& operator = (const char *str)
char

Returns a pointer to the string contained in this String object.

operator const char* () const
operator ==

Performs symbol-by-symbol comparison between the string contained in this String object and a given string.

const bool operator == (const char *str)
operator >

Performs an alphabetic comparison between the string contained in this String object and a given string.

const bool operator > (const char *str)
operator ==

Performs symbol-by-symbol comparison between the string contained in this String object and a string contained in a given String object.

const bool operator == (const String &s)
operator >

Performs symbol-by-symbol comparison between the string contained in this String object and a string contained in a given String object.

const bool operator > (const String &s)
getData

Returns a pointer to the string contained in this String object.

const char* getData () const
setStatic

Assigns a given string to this String object without copying the string.

The string must persist during lifetime of this String object until another string is asigned to it.

void setStatic (const char *str)
str :  The string to be assigned to this String object, or NULL.
setOwn

Assigns a given string to this String object without copying the string, but with granting "the ownership" of the string to the String object.

void setOwn (const char *str,
             FreeCallback freeCallback = dynamicFreeCallback)
str :  The string to be assigned to this String object, or NULL.
freeCallback :  The callback to be called when the string is no longer used by this String object.
set

Assigns a given string to this String object by creating a copy of the string.

void set (const char *str,
          unsigned len = 0)
str :  The string to be assigned to this String object, or NULL.
len :  The length of the string. 0 means that the string is zero-terminated.
staticString

Creates a new String object and assigns a given string to it as a static string.

See setStatic method description for details.

static Ref<String> staticString (const char *str)
str :  The string to be assigned to the newly created String object.
ownString

Creates a new String object and assignes a given string to it by granting "the ownership".

See setOwn method desecription for details.

static Ref<String>
ownString (const char *str,
           FreeCallback freeCallback = dynamicFreeCallback)
str :  The string to be assigned to the newly created String object.
freeCallback :  The callback to be called when the string is no longer used by the newly created String object.
forFormat

Creates a new String object and initializes it with a string formed according to the specified format.

The format is (almost) identical to that of the printf function. See "man printf" for details.

static Ref<String> forFormat (const char *fmt, ...)
fmt :  The format string.
nullString

Returns a reference to the "null" string.

The null string is a global String object that represents a string with no associated string data. Its purpose is to differentiate null strings from empty strings.

static Ref<String> nullString ()
isNullString

Determines whether this string is a "null" string or not.

bool isNullString ()
String

The defaultl constructor.

String ()
String

The copying constructor.

String (String &str)
String

The constructor. Assigns a given string to the constructed String object.

A copy of the specified string is created. See set method description for details.

String (const char *str)
str :  The string to be assigned to the constructed String object.