Mistake on this page? Email us

Public Types

typedef size_t size_type
 

Public Member Functions

 String (const String &)
 
 String (const char *)
 
 String (const char *, size_t)
 
Stringoperator= (const char *)
 
Stringoperator= (const String &)
 
Stringoperator+= (const String &)
 
Stringoperator+= (const char *)
 
Stringoperator+= (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
 
Stringerase (size_type pos, size_type len)
 erase len characters at position pos
 
Stringappend (const char *str, size_type n)
 Append n characters of a string.
 
Stringappend_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
 

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 Public Attributes

static const size_type npos
 

Friends

class ::Test_M2MString
 

Member Function Documentation

static bool m2m::String::convert_ascii_to_int ( const char *  value,
size_t  length,
int64_t &  conversion_result 
)
static

Convert ASCII representation of a base 10 number to int64. This is needed as sscanf("%lld") or atoll() are not universally available.

Parameters
valueoptionally zero terminated string containing a zero or one sign char ('+' or '-') and a number in base 10 chars, ie. "0..9"
lengthchars to convert, must be more or equal than the chars before zero. This is useful for extracting values from non-zero terminated strings.
conversion_resultresult of conversion
Returns
will be set to true if at least one digit is found and a false is returned if: a) no digits found, ie. string is empty b) a non-digit or non-'+' or non-'-' char is found. c) more than one +, - chars are found

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.


The documentation for this class was generated from the following file:
  • mbed-cloud-client/mbed-client/mbed-client/m2mstring.h