Robox Library for Cpp: tools module 1.0.0
RLibCpp utilities toolset
|
Class for handling strings. More...
#include <string.h>
Classes | |
class | Vector |
Class to handle with lists of String. More... | |
Public Member Functions | |
String () | |
Default constructor. | |
String (const String &src) | |
Copy constructor. | |
String (const char *src) | |
Constructor from null termineted char array. | |
String (char src) | |
Constructor from a character. | |
virtual | ~String () |
Virtual destructor. | |
String & | operator= (const String &src) |
Assigment operator overload. | |
bool | operator== (const String &src) const |
Comparison operator overload. | |
bool | operator== (const char *src) const |
Comparison operator. | |
bool | operator!= (const String &src) const |
Comparison operator overload. | |
bool | operator!= (const char *src) const |
Comparison operator. | |
String | operator+ (const String &other) const |
Concatenation operator overload. | |
String | append (const char other) |
Appends the charcter to the string. | |
String | append (const String &other) |
Appends the string other to the string. | |
bool | operator< (const String &src) const |
Check if lesser than the specifed string. | |
bool | operator<= (const String &src) const |
Check if lesser or equal than the specifed string. | |
bool | operator> (const String &src) const |
Check if greater than the specifed string. | |
bool | operator>= (const String &src) const |
Check if greater or equal than the specifed string. | |
String | subString (size_t pos=0, size_t len=SIZE_MAX) const |
Returns a newly constructed string object with its value initialized to a copy of a substring of this object. The substring is the portion of the object that starts at character position pos and spans len characters(or until the end of the string, whichever comes first). | |
bool | endsWith (const String &src, bool caseSensitive=true) const |
Test if the string ends with the src string. | |
bool | startsWith (const String &src, bool caseSensitive=true) const |
Test if the string starts with the src string. | |
String | toLower () const |
Get a copy of the string converted to lower case. | |
String | toUpper () const |
Get a copy of the string converted to upper case. | |
const char * | value () const |
Get the string zero terminated content. | |
void | setValue (const char *value) |
Set the string cpntent. | |
size_t | length () const |
The number of characters in the string. | |
operator const char * () const | |
Get the string zero terminated content. | |
size_t | rawDataSize () const |
The string raw data size in bytes. | |
int | indexOf (char val, size_t startPos=0, bool caseSensitive=true) const |
Returns the index of the first occurency of the specified character ( val ) | |
int | indexOf (const String &val, size_t startPos=0, bool caseSensitive=true) const |
Returns the index of the first occurency of the specified string ( val ) | |
int | lastIndexOf (char val, size_t startPos=0, bool caseSensitive=true) const |
Returns the last index of the first occurency of the specified character ( val ) | |
int | lastIndexOf (const String &val, size_t startPos=0, bool caseSensitive=true) const |
Returns the last index of the first occurency of the specified string ( val ) | |
void | replace (const String &oldValue, const String &newValue, bool caseSensitive=true) |
Replaces all the occurency of oldValue with newValue | |
void | replace (char oldValue, char newValue, bool caseSensitive=true) |
Replaces all the occurency of oldValue with newValue | |
bool | isEmpty () const |
Test if the string is empty. | |
Vector | split (char sep, bool keepEmpty=true, bool caseSensitive=true) const |
Splits the string by the specified character into a Vector of String. | |
Vector | split (const String &sep, bool keepEmpty=true, bool caseSensitive=true) const |
Splits the string by the specified string into a Vector of String. | |
String | trimmedLeft () const |
Returns a copy of the string that has whitespace removed from the start. | |
String | trimmedRight () const |
Returns a copy of the string that has whitespace removed from the end. | |
String | trimmed () const |
Returns a copy of the string that has whitespace removed from the start and the end. | |
String & | sprintf (const String cformat,...) |
Builds a formatted string from the format string cformat and an arbitrary list of arguments. | |
String | at (size_t pos) const |
Get a reference to the character at position pos in the string. | |
Protected Member Functions | |
void | init () |
Class initialization. | |
Class for handling strings.
String | ( | ) |
Default constructor.
String | ( | const char * | src | ) |
Constructor from null termineted char array.
src | The source char array |
String | ( | char | src | ) |
Constructor from a character.
src | The source char |
|
virtual |
Virtual destructor.
String append | ( | const char | other | ) |
Appends the charcter to the string.
other | The character to add |
Appends the string other to the string.
other | The string to add |
String at | ( | size_t | pos | ) | const |
Get a reference to the character at position pos in the string.
pos | Value with the position of a character within the string. |
If pos is equal to the string length, the function returns a reference to the null character that follows the last character in the string (which should not be modified)
bool endsWith | ( | const String & | src, |
bool | caseSensitive = true ) const |
Test if the string ends with the src string.
src | The string to compare with |
caseSensitive | If setted the comparisono is case sensitive |
int indexOf | ( | char | val, |
size_t | startPos = 0, | ||
bool | caseSensitive = true ) const |
Returns the index of the first occurency of the specified character ( val )
val | The character to search |
startPos | The starting search position |
caseSensitive | If setted the search is case sensitive |
int indexOf | ( | const String & | val, |
size_t | startPos = 0, | ||
bool | caseSensitive = true ) const |
Returns the index of the first occurency of the specified string ( val )
val | The string to search |
startPos | The starting search position |
caseSensitive | If setted the search is case sensitive |
|
protected |
Class initialization.
bool isEmpty | ( | ) | const |
Test if the string is empty.
int lastIndexOf | ( | char | val, |
size_t | startPos = 0, | ||
bool | caseSensitive = true ) const |
Returns the last index of the first occurency of the specified character ( val )
val | The character to search |
startPos | The starting search position |
caseSensitive | If setted the search is case sensitive |
int lastIndexOf | ( | const String & | val, |
size_t | startPos = 0, | ||
bool | caseSensitive = true ) const |
Returns the last index of the first occurency of the specified string ( val )
val | The string to search |
startPos | The starting search position |
caseSensitive | If setted the search is case sensitive |
size_t length | ( | ) | const |
The number of characters in the string.
operator const char * | ( | ) | const |
Get the string zero terminated content.
bool operator!= | ( | const char * | src | ) | const |
Comparison operator.
src | The source object |
bool operator!= | ( | const String & | src | ) | const |
Comparison operator overload.
src | The source object |
Concatenation operator overload.
other | The ohter object to add |
bool operator< | ( | const String & | src | ) | const |
Check if lesser than the specifed string.
src | The source object |
bool operator<= | ( | const String & | src | ) | const |
Check if lesser or equal than the specifed string.
src | The source object |
Assigment operator overload.
src | The source object |
bool operator== | ( | const char * | src | ) | const |
Comparison operator.
src | The source object |
bool operator== | ( | const String & | src | ) | const |
Comparison operator overload.
src | The source object |
bool operator> | ( | const String & | src | ) | const |
Check if greater than the specifed string.
src | The source object |
bool operator>= | ( | const String & | src | ) | const |
Check if greater or equal than the specifed string.
src | The source object |
size_t rawDataSize | ( | ) | const |
The string raw data size in bytes.
void replace | ( | char | oldValue, |
char | newValue, | ||
bool | caseSensitive = true ) |
Replaces all the occurency of oldValue with newValue
oldValue | The value to be substituted |
newValue | The new value |
caseSensitive | If setted the search is case sensitive |
Replaces all the occurency of oldValue with newValue
oldValue | The value to be substituted |
newValue | The new value |
caseSensitive | If setted the search is case sensitive |
void setValue | ( | const char * | value | ) |
Set the string cpntent.
value | Pointer to the zero terminated string content |
Vector split | ( | char | sep, |
bool | keepEmpty = true, | ||
bool | caseSensitive = true ) const |
Builds a formatted string from the format string cformat and an arbitrary list of arguments.
cformat | The format string |
bool startsWith | ( | const String & | src, |
bool | caseSensitive = true ) const |
Test if the string starts with the src string.
src | The string to compare with |
caseSensitive | If setted the comparisono is case sensitive |
String subString | ( | size_t | pos = 0, |
size_t | len = SIZE_MAX ) const |
Returns a newly constructed string object with its value initialized to a copy of a substring of this object. The substring is the portion of the object that starts at character position pos and spans len characters(or until the end of the string, whichever comes first).
pos | Position of the first character to be copied as a substring |
len | Number of characters to include in the substring (if the string is shorter, as many characters as possible are used). |
String toLower | ( | ) | const |
Get a copy of the string converted to lower case.
This method doesn't affect this object
String toUpper | ( | ) | const |
Get a copy of the string converted to upper case.
This method doesn't affect this object
String trimmed | ( | ) | const |
Returns a copy of the string that has whitespace removed from the start and the end.
This method doesn't affect this object
String trimmedLeft | ( | ) | const |
Returns a copy of the string that has whitespace removed from the start.
This method doesn't affect this object
String trimmedRight | ( | ) | const |
Returns a copy of the string that has whitespace removed from the end.
This method doesn't affect this object
const char * value | ( | ) | const |
Get the string zero terminated content.