#include <m2mstring.h>
Public Types | |
typedef size_t | size_type |
Public Member Functions | |
String (const String &) | |
String (const char *) | |
String (const char *, size_t) | |
String & | operator= (const char *) |
String & | operator= (const String &) |
String & | operator+= (const String &) |
String & | operator+= (const char *) |
String & | operator+= (char) |
void | push_back (char) |
bool | operator== (const char *) const |
bool | operator== (const String &) const |
void | clear () |
size_type | size () const |
size without terminating NULL | |
size_type | length () const |
as size() | |
size_type | capacity () const |
bool | empty () const |
const char * | c_str () const |
raw data | |
void | reserve (size_type n) |
void | resize (size_type n) |
void | resize (size_type n, char c) |
void | swap (String &) |
swap contents | |
String | substr (const size_type pos, size_type length) const |
char & | operator[] (const size_type i) |
char | operator[] (const size_type i) const |
char | at (const size_type i) const |
String & | erase (size_type pos, size_type len) |
erase len characters at position pos | |
String & | append (const char *str, size_type n) |
Append n characters of a string. | |
String & | append_raw (const char *, size_type) |
void | append_int (int) |
int | compare (size_type pos, size_type len, const String &str) const |
int | compare (size_type pos, size_type len, const char *str) const |
int | find_last_of (char c) const |
int | find_first_of (char c) const |
Static Public Member Functions | |
static uint8_t * | convert_integer_to_array (int64_t value, uint8_t &size, const uint8_t *array=NULL, const uint32_t array_size=0) |
static int64_t | convert_array_to_integer (const uint8_t *value, const uint32_t size) |
static bool | convert_ascii_to_int (const char *value, size_t length, int64_t &conversion_result) |
static bool | convert_ascii_to_float (const char *value, size_t size, float &conversion_result) |
Static Public Attributes | |
static const size_type | npos |
Friends | |
class | ::Test_M2MString |
A simple C++ string class, used as replacement for std::string.
|
static |
Convert ASCII representation to float.
value | optionally zero terminated string containing a float value |
length | chars to convert, must be more or equal than the chars before zero. |
conversion_result | result of conversion |
|
static |
Convert ASCII representation of a base 10 number to int64. This is needed as sscanf("%lld") or atoll() are not universally available.
value | optionally zero terminated string containing a zero or one sign char ('+' or '-') and a number in base 10 chars, ie. "0..9" |
length | chars to convert, must be more or equal than the chars before zero. This is useful for extracting values from non-zero terminated strings. |
conversion_result | result of conversion |
Note: the handling of a number with digits in front and non-digits at end (eg. "0zero") differs from sscanf(), as sscanf will return what it got converted and a success value even if the string ended with junk.
void m2m::String::reserve | ( | size_type | n | ) |
Reserve internal string memory so that n characters can be put into the string (plus 1 for the NULL char). If there is already enough memory, nothing happens, if not, the memory is realloated to exactly this amount.
void m2m::String::resize | ( | size_type | n | ) |
Resize string. If n is less than the current size, the string is truncated. If n is larger, the memory is reallocated to exactly this amount, and the additional characters are NULL characters.
void m2m::String::resize | ( | size_type | n, |
char | c | ||
) |
Resize string. If n is less than the current size, the string is truncated. If n is larger, the memory is reallocated to exactly this amount, and the additional characters are c characters.