#include <string.h>
Public Methods | |
String (const char *str="") | |
Constructor. More... | |
String (const String &s) | |
Copy constructor. More... | |
~String () | |
Destructor. It unallocates memory used by a private copy of C string. | |
int | length () const |
Length of string. More... | |
operator const char * () const | |
Type-cast. More... | |
String | operator= (const char *s) |
Assignment. More... | |
String | operator= (const String &s) |
Assignment. More... | |
int | operator== (const char *s) const |
Equality. More... | |
int | operator!= (const char *s) const |
Inequality. More... | |
String | operator+= (const char *s) |
Addition assignment. More... | |
String | operator+ (const char *s) |
Addition. More... | |
String | cutRight () |
White spaces removing. More... | |
String | cutLeft () |
White spaces removing. More... | |
Private Attributes | |
char * | _str |
pointer to the beginning of C string. |
This class implements a C string in such a way it looks like primitive type. It is only a stupid implementation without reference counting etc.
Definition at line 46 of file string.h.
|
Constructor. This constructor allocates needed place for new C string and copies the string 'str' to the new just allocated location (makes its own private copy of the string). Constructor can be used as a default constructor when used with no agruments.
Definition at line 37 of file string.cpp. Referenced by operator+(), operator+=(), and operator=().
|
|
Copy constructor. It takes a reference to another String object and makes a copy of it.
Definition at line 44 of file string.cpp. |
|
White spaces removing. This method removes white spaces (regular spaces and tabulators) from the left side of the C string managed by instance of this String class. New cutted value is stored instead of the old one. Note: modified object is returned as a return value, no temporal object. It is because of the modified object can be then easily modified (or used) by other methods without the need of explicit assignment.
Definition at line 100 of file string.cpp. |
|
White spaces removing. This method removes white spaces (regular spaces and tabulators) from the right side of the C string managed by instance of this String class. New cutted value is stored instead of the old one. Note: modified object is returned as a return value, no temporal object. It is because of the modified object can be then easily modified (or used) by other methods without the need of explicit assignment.
Definition at line 81 of file string.cpp. |
|
Length of string. This method returns an actual lenght of a string.
Definition at line 76 of file string.h. Referenced by String(), and Buffer::operator+=().
|
|
Type-cast. This operator type-casts String object to const char*. It can be used eg. when using String object as an argument in calls to standard functions with const char* arguments.
|
|
Inequality. This operator is a negation of == operator.
|
|
Addition. This operator adds the right-side value to the left-side value. New value is returned only, it is not stored somewhere.
|
|
Addition assignment. This operator adds the right-side value to the left-side operand. New value is stored in the left-side operand.
Definition at line 68 of file string.cpp. |
|
Assignment. See the help to operator=() above.
|
|
Assignment. This operator is used to assign a value to String object. There are two versions of this operator, they differ in an argument type. The first one uses const char* argument type, the second one the reference to another String object.
Definition at line 55 of file string.cpp. |
|
Equality. This operator compares String object value with a C string (on the right side of the operator). Because type-cast operator exists, it can be used to compare two String objects, too.
|