JsonParserGeneratorRK
|
Wiring String: A class to hold and manipulate a dynamically allocated string. More...
#include <spark_wiring_string.h>
Public Member Functions | |
String (const char *cstr="") | |
Construct a String object from a c-string (null-terminated) More... | |
String (const char *cstr, unsigned int length) | |
Construct a String object from a pointer and length. More... | |
String (const String &str) | |
Construct a String object as a copy of another string. More... | |
String (const Printable &printable) | |
Construct a String object from any Printable object. More... | |
String (char c) | |
Construct a String containing a single character. More... | |
String (unsigned char b, unsigned char base=10) | |
Construct a String from a unsigned char (uint8_t) value, expressed as a number. More... | |
String (int value, unsigned char base=10) | |
Construct a String from a int (32 bit signed integer) value, expressed as a number. More... | |
String (unsigned int value, unsigned char base=10) | |
Construct a String from a unsigned int (32 bit unsigned integer) value, expressed as a number. More... | |
String (long value, unsigned char base=10) | |
Construct a String from a long (32 bit signed integer) value, expressed as a number. More... | |
String (unsigned long value, unsigned char base=10) | |
Construct a String from a unsigned long (32 bit unsigned integer) value, expressed as a number. More... | |
String (float value, int decimalPlaces=6) | |
Construct a String from a float (32 bit single precision floating point) value, expressed as a number. More... | |
String (double value, int decimalPlaces=6) | |
Construct a String from a double (64 bit double precision floating point) value, expressed as a number. More... | |
~String (void) | |
Destructor. Also deletes the underlying dynamically allocated string. | |
unsigned char | reserve (unsigned int size) |
Reserves a buffer of size. More... | |
unsigned int | length (void) const |
Returns the length of the string in bytes. More... | |
String & | operator= (const String &rhs) |
Assigns this string to have a copy of String rhs. More... | |
String & | operator= (const char *cstr) |
Assigns this string to have a copy of c-string (null-terminated) cstr. More... | |
operator const char * () const | |
Returns the contents this String as a c-string (null-terminated) More... | |
unsigned char | concat (const String &str) |
Append (concatenate) a String object to the end of this String, modifying this string in place. More... | |
unsigned char | concat (const char *cstr) |
Append (concatenate) a c-string (null-terminated) to the end of this String, modifying this string in place. More... | |
unsigned char | concat (char c) |
Append (concatenate) a single character to the end of this String, modifying this string in place. More... | |
unsigned char | concat (unsigned char c) |
Append (concatenate) the byte value c to the end of this String as a decimal number 0 - 255, modifying this string in place. More... | |
unsigned char | concat (int num) |
Append (concatenate) the integer value num to the end of this String as a signed decimal number (base 10), modifying this string in place. More... | |
unsigned char | concat (unsigned int num) |
Append (concatenate) the unsigned integer value num to the end of this String as a unsigned decimal number (base 10), modifying this string in place. More... | |
unsigned char | concat (long num) |
Append (concatenate) the long integer value num to the end of this String as a signed decimal number (base 10), modifying this string in place. More... | |
unsigned char | concat (unsigned long num) |
Append (concatenate) the unsigned long value num to the end of this String as a unsigned decimal number (base 10), modifying this string in place. More... | |
unsigned char | concat (float num) |
Append (concatenate) the float n to the end of this String as a decimal number (base 10), modifying this string in place. More... | |
unsigned char | concat (double num) |
Append (concatenate) the double precision float n to the end of this String as a decimal number (base 10), modifying this string in place. More... | |
String & | operator+= (const String &rhs) |
Appends (concatenate) a String object to the end of this String, modifying this string in place. More... | |
String & | operator+= (const char *cstr) |
Appends (concatenate) a c-string (null-terminated) to the end of this String, modifying this string in place. More... | |
String & | operator+= (char c) |
Appends (concatenate) a single character to the end of this String, modifying this string in place. More... | |
String & | operator+= (unsigned char num) |
Append (concatenate) the byte value num to the end of this String as a decimal number 0 - 255, modifying this string in place. More... | |
String & | operator+= (int num) |
Append (concatenate) the integer value num to the end of this String as a signed decimal number (base 10), modifying this string in place. More... | |
String & | operator+= (unsigned int num) |
Append (concatenate) the unsigned integer value num to the end of this String as a unsigned decimal number (base 10), modifying this string in place. More... | |
String & | operator+= (long num) |
Append (concatenate) the long integer value num to the end of this String as a signed decimal number (base 10), modifying this string in place. More... | |
String & | operator+= (unsigned long num) |
Append (concatenate) the unsigned long value num to the end of this String as a unsigned decimal number (base 10), modifying this string in place. More... | |
int | compareTo (const String &s) const |
Compares this string to another string using strcmp (case-sensitive) More... | |
unsigned char | equals (const String &s) const |
Returns true if this string is equal to another string (case-sensitive) More... | |
unsigned char | equals (const char *cstr) const |
Returns true if this string equal to another string (case-sensitive) More... | |
unsigned char | operator== (const String &rhs) const |
Returns true if this string is equal to another string (case-sensitive) More... | |
unsigned char | operator== (const char *cstr) const |
Returns true if this string equal to another string (case-sensitive) More... | |
unsigned char | operator!= (const String &rhs) const |
Returns true if this string is greater than to another string (case-sensitive) More... | |
unsigned char | operator!= (const char *cstr) const |
Returns true if this string not equal to another string (case-sensitive) More... | |
unsigned char | operator< (const String &rhs) const |
Returns true if this string is less than to another string (case-sensitive) More... | |
unsigned char | operator> (const String &rhs) const |
Returns true if this string is greater than to another string (case-sensitive) More... | |
unsigned char | operator<= (const String &rhs) const |
Returns true if this string is less than or equal to another string (case-sensitive) More... | |
unsigned char | operator>= (const String &rhs) const |
Returns true if this string is greater than or equal to another string (case-sensitive) More... | |
unsigned char | equalsIgnoreCase (const String &s) const |
Returns true if this string equals another string (case-insensitive) More... | |
unsigned char | startsWith (const String &prefix) const |
Returns true if this string starts with prefix (case-sensitive) More... | |
unsigned char | startsWith (const String &prefix, unsigned int offset) const |
Returns true if this string contains prefix at specified offset (case-sensitive) More... | |
unsigned char | endsWith (const String &suffix) const |
Returns true if this string ends with suffix (case-sensitive) More... | |
char | charAt (unsigned int index) const |
Gets the character at offset index. More... | |
void | setCharAt (unsigned int index, char c) |
Set the character at offset index. More... | |
char | operator[] (unsigned int index) const |
Gets the character at offset index. More... | |
char & | operator[] (unsigned int index) |
Set the character at offset index. More... | |
void | getBytes (unsigned char *buf, unsigned int bufsize, unsigned int index=0) const |
Copy the data out of this String into another buffer. More... | |
void | toCharArray (char *buf, unsigned int bufsize, unsigned int index=0) const |
Copy the data out of this String into another buffer. More... | |
const char * | c_str () const |
Returns a c-string (null-terminated) More... | |
int | indexOf (char ch) const |
Search this string for a given character. More... | |
int | indexOf (char ch, unsigned int fromIndex) const |
Search this string for a given character starting at an offset. More... | |
int | indexOf (const String &str) const |
Search this string for a given String. More... | |
int | indexOf (const String &str, unsigned int fromIndex) const |
Search this string for a given String starting at an offset. More... | |
int | lastIndexOf (char ch) const |
Search this string for a given character, starting at the end. More... | |
int | lastIndexOf (char ch, unsigned int fromIndex) const |
Search this string for a given character, starting at the fromIndex and going toward the beginning. More... | |
int | lastIndexOf (const String &str) const |
Search this string for a last occurrence of str. More... | |
int | lastIndexOf (const String &str, unsigned int fromIndex) const |
Search this string for a last occurrence of str starting at fromIndex. More... | |
String | substring (unsigned int beginIndex) const |
Returns a String object with a copy of the characters starting at beginIndex through the end of the string. More... | |
String | substring (unsigned int beginIndex, unsigned int endIndex) const |
Returns a String object with a copy of the characters in the specified range. More... | |
String & | replace (char find, char replace) |
Replaces every occurrence of a character in the string with another character, modifying it in place. More... | |
String & | replace (const String &find, const String &replace) |
Replaces every occurrence of a String with another String, modifying it in place. More... | |
String & | remove (unsigned int index) |
Removes characters from the String, modifying it in place. More... | |
String & | remove (unsigned int index, unsigned int count) |
Removes characters from the String, modifying it in place. More... | |
String & | toLowerCase (void) |
Converts this String to lower case, modifying it in place. More... | |
String & | toUpperCase (void) |
Converts this String to upper case, modifying it in place. More... | |
String & | trim (void) |
Removes leading an trailing white spaces from this string, modifying it in place. More... | |
long | toInt (void) const |
Converts this string to a signed integer (32-bit) More... | |
float | toFloat (void) const |
Converts this string to a float (single precision floating point value) More... | |
Static Public Member Functions | |
static String | format (const char *format,...) |
Uses sprintf-style formatting to build a String object [static]. More... | |
Protected Attributes | |
char * | buffer |
The buffer containing the data. It is always null-terminated. | |
unsigned int | capacity |
The capacity of the buffer. The longest string is one byte less than this. | |
unsigned int | len |
The String length (not counting the null terminator). | |
unsigned char | flags |
Unused, for future features. | |
Friends | |
class | StringPrintableHelper |
StringSumHelper & | operator+ (const StringSumHelper &lhs, const String &rhs) |
Append (concatenate) a String to the end of lhs. More... | |
StringSumHelper & | operator+ (const StringSumHelper &lhs, const char *cstr) |
Append (concatenate) a c-string (null-terminated) to the end of lhs. More... | |
StringSumHelper & | operator+ (const StringSumHelper &lhs, char c) |
Append (concatenate) the character c the end of lhs a. More... | |
StringSumHelper & | operator+ (const StringSumHelper &lhs, unsigned char num) |
Append (concatenate) the unsigned char num to the end of lhs as a decimal number (base 10) More... | |
StringSumHelper & | operator+ (const StringSumHelper &lhs, int num) |
Append (concatenate) the signed int num to the end of lhs as a decimal number (base 10) More... | |
StringSumHelper & | operator+ (const StringSumHelper &lhs, unsigned int num) |
Append (concatenate) the unsigned int num to the end of lhs as a decimal number (base 10) More... | |
StringSumHelper & | operator+ (const StringSumHelper &lhs, long num) |
Append (concatenate) the long integer num to the end of lhs as a decimal number (base 10) More... | |
StringSumHelper & | operator+ (const StringSumHelper &lhs, unsigned long num) |
Append (concatenate) the unsigned long integer to the end of lhs as a decimal number (base 10) More... | |
StringSumHelper & | operator+ (const StringSumHelper &lhs, float num) |
Append (concatenate) the float num to the end of lhs as a decimal number (base 10) More... | |
StringSumHelper & | operator+ (const StringSumHelper &lhs, double num) |
Append (concatenate) the double precision float num to the end of lhs as a decimal number (base 10) More... | |
Wiring String: A class to hold and manipulate a dynamically allocated string.
String::String | ( | const char * | cstr = "" | ) |
Construct a String object from a c-string (null-terminated)
cstr | The string to copy, optional. If not specified, starts with an empty string |
String::String | ( | const char * | cstr, |
unsigned int | length | ||
) |
Construct a String object from a pointer and length.
cstr | Pointer to a bytes, typically ASCII or UTF-8. Does not need to be null-terminated. |
length | Length in bytes of the string. |
String::String | ( | const String & | str | ) |
Construct a String object as a copy of another string.
str | The string to copy. Changes made to str in the future won't be reflected in this copy. |
String::String | ( | const Printable & | printable | ) |
Construct a String object from any Printable object.
printable | The Printable object. The toPrint() method will be called on it to print to this String the textual representation of the object. |
For example, IPAddress is printable, so you can pass an IPAddress to this constructor and this string will contain a textual representation of the IPAddress (dotted quad).
|
explicit |
|
explicit |
Construct a String from a unsigned char (uint8_t) value, expressed as a number.
b | The value. |
base | The number base, default is 10 (decimal). Other values include 8 (octal) and 16 (hexadecimal). |
|
explicit |
Construct a String from a int (32 bit signed integer) value, expressed as a number.
value | The value. |
base | The number base, default is 10 (decimal). Other values include 8 (octal) and 16 (hexadecimal). |
|
explicit |
Construct a String from a unsigned int (32 bit unsigned integer) value, expressed as a number.
value | The value. |
base | The number base, default is 10 (decimal). Other values include 8 (octal) and 16 (hexadecimal). |
|
explicit |
Construct a String from a long (32 bit signed integer) value, expressed as a number.
value | The value. |
base | The number base, default is 10 (decimal). Other values include 8 (octal) and 16 (hexadecimal). |
|
explicit |
Construct a String from a unsigned long (32 bit unsigned integer) value, expressed as a number.
value | The value. |
base | The number base, default is 10 (decimal). Other values include 8 (octal) and 16 (hexadecimal). |
|
explicit |
Construct a String from a float (32 bit single precision floating point) value, expressed as a number.
value | The value. |
decimalPlaces | The number of decimal places to show. Default = 6. |
|
explicit |
Construct a String from a double (64 bit double precision floating point) value, expressed as a number.
value | The value. |
decimalPlaces | The number of decimal places to show. Default = 6. |
|
inline |
Returns a c-string (null-terminated)
This allows the String object to be passed to anything that requires a c-string. See also operator const char *.
One place where you need to explicitly use c_str() or cast is when passing a String as a variable argument to sprintf:
If you leave off the c_str() the value won't be printed as string. This also applies to things that use sprintf internally, like Log:
This method returns a pointer to the internal buffer. If the underlying string is reallocated because the string is appended to, this pointer will be invalid.
char String::charAt | ( | unsigned int | index | ) | const |
Gets the character at offset index.
index | The index to set (0 = first character) |
int String::compareTo | ( | const String & | s | ) | const |
Compares this string to another string using strcmp (case-sensitive)
s | the string to compare to |
Uses the C standard library function strcmp which is case-sensitive and does not correctly compare UTF-8 characters.
unsigned char String::concat | ( | const String & | str | ) |
unsigned char String::concat | ( | const char * | cstr | ) |
Append (concatenate) a c-string (null-terminated) to the end of this String, modifying this string in place.
cstr | The string to copy from. It is not modified. |
unsigned char String::concat | ( | char | c | ) |
Append (concatenate) a single character to the end of this String, modifying this string in place.
c | The character to append. |
unsigned char String::concat | ( | unsigned char | c | ) |
Append (concatenate) the byte value c to the end of this String as a decimal number 0 - 255, modifying this string in place.
c | The value to append. |
unsigned char String::concat | ( | int | num | ) |
Append (concatenate) the integer value num to the end of this String as a signed decimal number (base 10), modifying this string in place.
num | The value to append. |
unsigned char String::concat | ( | unsigned int | num | ) |
Append (concatenate) the unsigned integer value num to the end of this String as a unsigned decimal number (base 10), modifying this string in place.
num | The value to append. |
unsigned char String::concat | ( | long | num | ) |
Append (concatenate) the long integer value num to the end of this String as a signed decimal number (base 10), modifying this string in place.
num | The value to append. |
unsigned char String::concat | ( | unsigned long | num | ) |
Append (concatenate) the unsigned long value num to the end of this String as a unsigned decimal number (base 10), modifying this string in place.
num | The value to append. |
unsigned char String::concat | ( | float | num | ) |
Append (concatenate) the float n to the end of this String as a decimal number (base 10), modifying this string in place.
num | The value to append. |
unsigned char String::concat | ( | double | num | ) |
Append (concatenate) the double precision float n to the end of this String as a decimal number (base 10), modifying this string in place.
num | The value to append. |
unsigned char String::endsWith | ( | const String & | suffix | ) | const |
Returns true if this string ends with suffix (case-sensitive)
suffix | the string containing the suffix to test |
Uses the C standard library function strcmp which is case-sensitive and may not work properly with UTF-8 characters.
unsigned char String::equals | ( | const String & | s | ) | const |
Returns true if this string is equal to another string (case-sensitive)
s | the string to compare to |
Uses the C standard library function strcmp which is case-sensitive and does not correctly compare UTF-8 characters.
unsigned char String::equals | ( | const char * | cstr | ) | const |
Returns true if this string equal to another string (case-sensitive)
cstr | the c-string (null-terminated) to compare to |
Uses the C standard library function strcmp which is case-sensitive and does not correctly compare UTF-8 characters.
unsigned char String::equalsIgnoreCase | ( | const String & | s | ) | const |
Returns true if this string equals another string (case-insensitive)
s | the string to compare to |
Uses the C standard library function strcmp which is case-sensitive and does not correctly compare UTF-8 characters.
|
static |
void String::getBytes | ( | unsigned char * | buf, |
unsigned int | bufsize, | ||
unsigned int | index = 0 |
||
) | const |
Copy the data out of this String into another buffer.
buf | The buffer to copy into |
bufsize | The size of the buffer. The buffer will contain a null-terminted string so the maximum string length is bufsize - 1. |
index | The index to start copying from (0 = first character). Optional. Default is from 0, the start of the string. |
If bufsize is smaller than the string the string will be truncated and still null-terminated. If the string is truncated and UTF-8, it may break a multi-byte character sequence in the middle, resulting in invalid UTF-8.
int String::indexOf | ( | char | ch | ) | const |
Search this string for a given character.
ch | The ASCII character to search for |
This uses the C standard library function strchr and is only compatible with ASCII characters. It can return invalid results for UTF-8 strings.
int String::indexOf | ( | char | ch, |
unsigned int | fromIndex | ||
) | const |
Search this string for a given character starting at an offset.
ch | The ASCII character to t search for |
fromIndex | The index to start from (0 = first character) |
This uses the C standard library function strchr and is only compatible with ASCII characters. It can return invalid results for UTF-8 strings.
int String::indexOf | ( | const String & | str | ) | const |
Search this string for a given String.
str | The string to search for |
This uses the C standard library function strstr and is only compatible with ASCII characters. It can return invalid results for UTF-8 strings. It is case-sensitive.
int String::indexOf | ( | const String & | str, |
unsigned int | fromIndex | ||
) | const |
Search this string for a given String starting at an offset.
str | The string to search for |
fromIndex | The index to start from (0 = first character) |
This uses the C standard library function strstr and is only compatible with ASCII characters. It can return invalid results for UTF-8 strings. It is case-sensitive.
int String::lastIndexOf | ( | char | ch | ) | const |
Search this string for a given character, starting at the end.
ch | The ASCII character to search for |
This uses the C standard library function strrchr and is only compatible with ASCII characters. It can return invalid results for UTF-8 strings.
int String::lastIndexOf | ( | char | ch, |
unsigned int | fromIndex | ||
) | const |
Search this string for a given character, starting at the fromIndex and going toward the beginning.
ch | The ASCII character to search for |
fromIndex | The index to start from (0 = first character) |
This uses the C standard library function strrchr and is only compatible with ASCII characters. It can return invalid results for UTF-8 strings.
int String::lastIndexOf | ( | const String & | str | ) | const |
Search this string for a last occurrence of str.
str | The string to search for |
This uses the C standard library function strstr and is only compatible with ASCII characters. It can return invalid results for UTF-8 strings. It is case-sensitive.
int String::lastIndexOf | ( | const String & | str, |
unsigned int | fromIndex | ||
) | const |
Search this string for a last occurrence of str starting at fromIndex.
str | The string to search for |
fromIndex | The index to start from (0 = first character) |
This uses the C standard library function strstr and is only compatible with ASCII characters. It can return invalid results for UTF-8 strings. It is case-sensitive.
|
inline |
Returns the length of the string in bytes.
Note that for UTF-8 strings, this is the number of bytes, not characters.
|
inline |
|
inline |
Returns true if this string is greater than to another string (case-sensitive)
rhs | the string to compare to |
Uses the C standard library function strcmp which is case-sensitive and does not correctly compare UTF-8 characters.
|
inline |
Returns true if this string not equal to another string (case-sensitive)
cstr | the c-string (null-terminated) to compare to |
Uses the C standard library function strcmp which is case-sensitive and does not correctly compare UTF-8 characters.
Appends (concatenate) a String object to the end of this String, modifying this string in place.
rhs | The string to copy from. It is not modified. |
|
inline |
Appends (concatenate) a c-string (null-terminated) to the end of this String, modifying this string in place.
cstr | The string to copy from. It is not modified. |
|
inline |
|
inline |
Append (concatenate) the byte value num to the end of this String as a decimal number 0 - 255, modifying this string in place.
num | The value to append. |
|
inline |
Append (concatenate) the integer value num to the end of this String as a signed decimal number (base 10), modifying this string in place.
num | The value to append. |
|
inline |
Append (concatenate) the unsigned integer value num to the end of this String as a unsigned decimal number (base 10), modifying this string in place.
num | The value to append. |
|
inline |
Append (concatenate) the long integer value num to the end of this String as a signed decimal number (base 10), modifying this string in place.
num | The value to append. |
|
inline |
Append (concatenate) the unsigned long value num to the end of this String as a unsigned decimal number (base 10), modifying this string in place.
num | The value to append. |
unsigned char String::operator< | ( | const String & | rhs | ) | const |
Returns true if this string is less than to another string (case-sensitive)
rhs | the string to compare to |
Uses the C standard library function strcmp which is case-sensitive and does not correctly compare UTF-8 characters.
unsigned char String::operator<= | ( | const String & | rhs | ) | const |
Returns true if this string is less than or equal to another string (case-sensitive)
rhs | the string to compare to |
Uses the C standard library function strcmp which is case-sensitive and does not correctly compare UTF-8 characters.
Assigns this string to have a copy of String rhs.
rhs | The string to copy from. |
String& String::operator= | ( | const char * | cstr | ) |
Assigns this string to have a copy of c-string (null-terminated) cstr.
cstr | The string to copy from. |
|
inline |
Returns true if this string is equal to another string (case-sensitive)
rhs | the string to compare to |
Uses the C standard library function strcmp which is case-sensitive and does not correctly compare UTF-8 characters.
|
inline |
Returns true if this string equal to another string (case-sensitive)
cstr | the c-string (null-terminated) to compare to |
Uses the C standard library function strcmp which is case-sensitive and does not correctly compare UTF-8 characters.
unsigned char String::operator> | ( | const String & | rhs | ) | const |
Returns true if this string is greater than to another string (case-sensitive)
rhs | the string to compare to |
Uses the C standard library function strcmp which is case-sensitive and does not correctly compare UTF-8 characters.
unsigned char String::operator>= | ( | const String & | rhs | ) | const |
Returns true if this string is greater than or equal to another string (case-sensitive)
rhs | the string to compare to |
Uses the C standard library function strcmp which is case-sensitive and does not correctly compare UTF-8 characters.
char String::operator[] | ( | unsigned int | index | ) | const |
Gets the character at offset index.
index | The index to set (0 = first character) |
char& String::operator[] | ( | unsigned int | index | ) |
Set the character at offset index.
index | The index to set (0 = first character) |
If index is greater than the length of the string, a dummy reference is returned instead. This allows operation to execute without error, but also discards the change. In other words, you cannot use this to append to the string, only modify an existing character.
String& String::remove | ( | unsigned int | index | ) |
String& String::remove | ( | unsigned int | index, |
unsigned int | count | ||
) |
Removes characters from the String, modifying it in place.
index | Index to start removing from, inclusive. 0 = first character of the string. |
count | Number of characters to remove. Typically 1 (remove one character) or more. Removes to the end of the string if count is larger than the size of the string. |
String& String::replace | ( | char | find, |
char | replace | ||
) |
Replaces every occurrence of a character in the string with another character, modifying it in place.
find | the character to look for |
replace | the character to replace it with |
unsigned char String::reserve | ( | unsigned int | size | ) |
Reserves a buffer of size.
This can improve the efficiency if you know approximately how big your string will be. Otherwise, the string is made larger in increments, which is much less efficient.
If, for example you reserve 100 bytes in a new empty string, the length will still be 0 until you append characters to it. It just will be able to append 100 bytes until it has to expand the internal dynamically allocated buffer.
void String::setCharAt | ( | unsigned int | index, |
char | c | ||
) |
Set the character at offset index.
index | The index to set (0 = first character) |
c | The value to set the character to. |
If index is greater than the length of the string, nothing is done. In other words, you cannot use this to append to the string, only modify an existing character.
unsigned char String::startsWith | ( | const String & | prefix | ) | const |
Returns true if this string starts with prefix (case-sensitive)
prefix | the string containing the string to test against |
Uses the C standard library function strcmp which is case-sensitive and may not work properly with UTF-8 characters.
unsigned char String::startsWith | ( | const String & | prefix, |
unsigned int | offset | ||
) | const |
Returns true if this string contains prefix at specified offset (case-sensitive)
prefix | the string containing the string to test against |
offset | the offset to check at (0 = first characters) |
Uses the C standard library function strcmp which is case-sensitive and may not work properly with UTF-8 characters.
String String::substring | ( | unsigned int | beginIndex | ) | const |
Returns a String object with a copy of the characters starting at beginIndex through the end of the string.
beginIndex | The index to start copying from, inclusive (0 = first byte, 1 = second byte, ...) |
Note: If the String contains UTF-8 characters, beginIndex and endIndex are in bytes, not characters! It does not prevent splitting a UTF-8 multi-byte sequence.
String String::substring | ( | unsigned int | beginIndex, |
unsigned int | endIndex | ||
) | const |
Returns a String object with a copy of the characters in the specified range.
beginIndex | The index to start copying from, inclusive (0 = first byte, 1 = second byte, ...) |
endIndex | The index to stop at, exclusive. The last character copied is the one before this one. |
Note: If the String contains UTF-8 characters, beginIndex and endIndex are in bytes, not characters! It does not prevent splitting a UTF-8 multi-byte sequence.
|
inline |
Copy the data out of this String into another buffer.
buf | The buffer to copy into |
bufsize | The size of the buffer. The buffer will contain a null-terminted string so the maximum string length is bufsize - 1. |
index | The index to start copying from (0 = first character). Optional. Default is from 0, the start of the string. |
If bufsize is smaller than the string the string will be truncated and still null-terminated. If the string is truncated and UTF-8, it may break a multi-byte character sequence in the middle, resulting in invalid UTF-8.
float String::toFloat | ( | void | ) | const |
Converts this string to a float (single precision floating point value)
long String::toInt | ( | void | ) | const |
Converts this string to a signed integer (32-bit)
String& String::toLowerCase | ( | void | ) |
String& String::toUpperCase | ( | void | ) |
String& String::trim | ( | void | ) |
Removes leading an trailing white spaces from this string, modifying it in place.
Whitespace is determined by the C standard library function isspace().
|
friend |
|
friend |
Append (concatenate) a c-string (null-terminated) to the end of lhs.
lhs | The string to append to. String lhs is not modified. |
cstr | The value to append. |
|
friend |
Append (concatenate) the character c the end of lhs a.
lhs | The string to append to. String lhs is not modified. |
c | The character to append |
|
friend |
Append (concatenate) the unsigned char num to the end of lhs as a decimal number (base 10)
lhs | The string to append to. String lhs is not modified. |
num | The value to append. |
|
friend |
Append (concatenate) the signed int num to the end of lhs as a decimal number (base 10)
lhs | The string to append to. String lhs is not modified. |
num | The value to append. |
|
friend |
Append (concatenate) the unsigned int num to the end of lhs as a decimal number (base 10)
lhs | The string to append to. String lhs is not modified. |
num | The value to append. |
|
friend |
Append (concatenate) the long integer num to the end of lhs as a decimal number (base 10)
lhs | The string to append to. String lhs is not modified. |
num | The value to append. |
|
friend |
Append (concatenate) the unsigned long integer to the end of lhs as a decimal number (base 10)
lhs | The string to append to. String lhs is not modified. |
num | The value to append. |
|
friend |
Append (concatenate) the float num to the end of lhs as a decimal number (base 10)
lhs | The string to append to. String lhs is not modified. |
num | The value to append. |
|
friend |
Append (concatenate) the double precision float num to the end of lhs as a decimal number (base 10)
lhs | The string to append to. String lhs is not modified. |
num | The value to append. |