![]() |
Iridescence 1.00
Embedded Graphic Framework
|
DsString is a class representing a character string. More...
#include <ds_string.h>
Public Member Functions | |
DsString (size_t max_length=31) | |
Creates a DsString object with space for storing a string of specified length. | |
DsString (const char *str, size_t max_length=DsString::npos) | |
Creates a DsString object with space for storing the specified string or a specified length. Copies the string in the newly created DsString object. | |
DsString (const DsString &src) | |
Copy constructor. | |
DsString (DsString &&src) | |
Move constructor. | |
~DsString () | |
Destructor. | |
DsString & | operator= (const DsString &rhs) |
Assignment operator from another DsString. | |
DsString & | operator= (DsString &&rhs) |
Move operator. | |
DsString & | operator= (const char *rhs) |
Assignment operator from a C string. | |
DsString & | operator+= (const char *rhs) |
Addition operator - appends a string to the current DsString object. | |
DsString | operator+ (const DsString &rhs) |
Addition operator - appends a DsString to the current DsString object. | |
void | append (char c, size_t count) |
Appends a character a number of times to the current DsString object. | |
void | append (const char *str) |
Appends a C string to the current DsString object. | |
void | append (const char *str, size_t count) |
Appends a C string a number of times. | |
void | append (char c) |
Appends a single character to the current DsString object. | |
void | append (const DsString &str) |
Appends a DsString object to the current DsString object. | |
void | insert (size_t pos, char c, size_t count) |
Inserts a character a number of times at a specified position in the current DsString object. | |
void | insert (size_t pos, char c) |
Inserts a single character at a specified position in the current DsString object. | |
void | insert (size_t pos, const char *str) |
Inserts a C string at a specified position in the current DsString object. | |
void | erase (size_t pos, size_t count) |
Erases characters from the specified position. | |
void | erase_first (size_t count) |
Erases characters from the beginning of the string. | |
void | erase_last (size_t count) |
Erases characters from the end of the string. | |
void | clear (void) |
Clears the entire string. | |
void | substr (char *substr, size_t pos, size_t count) const |
Extracts a substring of the current string. | |
const char * | c_str (void) const |
Returns the pointer to the underlaying C string. | |
operator const char * () const | |
Conversion operator to a pointer to the underlaying C string. | |
size_t | length (void) const |
Returns the length of the string. | |
size_t | maxLength (void) const |
Returns the maximum string length this DsString can hold. | |
bool | empty (void) const |
Is the string empty? | |
char | front (void) |
Returns the first character of the string. | |
char | back (void) |
Returns the last character of the string. | |
bool | operator== (const char *rhs) const |
Comparison operator. | |
bool | operator!= (const char *rhs) const |
Comparison operator. | |
bool | operator>= (const char *rhs) const |
Comparison operator. | |
bool | operator<= (const char *rhs) const |
Comparison operator. | |
bool | operator> (const char *rhs) const |
Comparison operator. | |
bool | operator< (const char *rhs) const |
Comparison operator. | |
size_t | format (const char *format,...) |
Initializes the string using printf() style. | |
size_t | format (const char *format, va_list args) |
Initializes the string using vprintf() style. | |
size_t | find (char c, size_t pos=0) |
Searches for a character starting at a specific position. | |
size_t | find (const char *substr, size_t pos=0) |
Searches for a substring starting at a specific position. | |
Static Public Attributes | |
static const size_t | npos = -1 |
Constant representing an invalid position/size value. | |
DsString is a class representing a character string.
Internally the string is represented as a C character array (C string). Once a DsString object is created with storage space of specific size, it cannot be changed or reallocated.
DsString::DsString | ( | size_t | max_length = 31 | ) |
Creates a DsString object with space for storing a string of specified length.
max_length | Maximum sting length (in characters) to allocate space for. Default is 31 characters. The internal storage space size will be the next multiple of 8 bytes higher than the requested space. An extra character is needed to store the C string NULL termiantion character. |
DsString::DsString | ( | const char * | str, |
size_t | max_length = DsString::npos |
||
) |
Creates a DsString object with space for storing the specified string or a specified length. Copies the string in the newly created DsString object.
str | Source string |
max_length | Maximum sting length (in characters) to allocate space for. The default is to allocate just enough space for storing the supplied string. The internal storage space size will be the next multiple of 8 bytes higher than the requested space. An extra character is needed to store the C string NULL termiantion character. |
|
inline |
Appends a single character to the current DsString object.
c | Character to append |
void DsString::append | ( | char | c, |
size_t | count | ||
) |
Appends a character a number of times to the current DsString object.
c | Character to append |
count | Number of times to append the character |
void DsString::append | ( | const char * | str | ) |
Appends a C string to the current DsString object.
str | String to append |
count | Number of times to append the character |
void DsString::append | ( | const char * | str, |
size_t | count | ||
) |
Appends a C string a number of times.
str | String to append |
|
inline |
|
inline |
Returns the last character of the string.
|
inline |
Returns the pointer to the underlaying C string.
|
inline |
Is the string empty?
void DsString::erase | ( | size_t | pos, |
size_t | count | ||
) |
Erases characters from the specified position.
pos | Position to erase characters from |
count | Number of characters to erase |
|
inline |
Erases characters from the beginning of the string.
count | Number of characters to erase |
|
inline |
Erases characters from the end of the string.
count | Number of characters to erase |
size_t DsString::find | ( | char | c, |
size_t | pos = 0 |
||
) |
Searches for a character starting at a specific position.
c | Character to search for |
pos | Position to start searching at. The default is the beginning of the string. |
size_t DsString::find | ( | const char * | substr, |
size_t | pos = 0 |
||
) |
Searches for a substring starting at a specific position.
substr | Substring to search for |
pos | Position to start searching at. The default is the beginning of the string. |
size_t DsString::format | ( | const char * | format, |
va_list | args | ||
) |
Initializes the string using vprintf() style.
format | vprintf() style string |
args | Variable argument list |
size_t DsString::format | ( | const char * | format, |
... | |||
) |
Initializes the string using printf() style.
format | printf() style string |
|
inline |
Returns the first character of the string.
|
inline |
Inserts a single character at a specified position in the current DsString object.
pos | Position to insert at. 0 means insert at the beginning. |
c | Character to insert |
void DsString::insert | ( | size_t | pos, |
char | c, | ||
size_t | count | ||
) |
Inserts a character a number of times at a specified position in the current DsString object.
pos | Position to insert at. 0 means insert at the beginning. |
c | Character to insert |
count | Number of times to insert the character |
void DsString::insert | ( | size_t | pos, |
const char * | str | ||
) |
Inserts a C string at a specified position in the current DsString object.
pos | Position to insert at. 0 means insert at the beginning. |
str | C string to insert |
|
inline |
Returns the length of the string.
|
inline |
Returns the maximum string length this DsString can hold.
|
inline |
Conversion operator to a pointer to the underlaying C string.
DsString & DsString::operator+= | ( | const char * | rhs | ) |
Addition operator - appends a string to the current DsString object.
rhs | String to append |
void DsString::substr | ( | char * | substr, |
size_t | pos, | ||
size_t | count | ||
) | const |
Extracts a substring of the current string.
substr | C string to extract the substring to |
pos | Position of the substring in the current string |
count | Length of the substring to extract |