Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
String Class Reference

The string class. More...

#include <WString.h>

Inheritance diagram for String:
CStringArray StringSumHelper

Public Member Functions

STRING_IRAM_ATTR String (const char *cstr=nullptr)
 
STRING_IRAM_ATTR String (const char *cstr, unsigned int length)
 
STRING_IRAM_ATTR String (const String &str)
 
 String (flash_string_t pstr, int length=-1)
 
 String (const FlashString &fstr)
 
STRING_IRAM_ATTR String (String &&rval)
 
STRING_IRAM_ATTR String (StringSumHelper &&rval)
 
 String (char c)
 
 String (unsigned char, unsigned char base=10)
 
 String (int, unsigned char base=10)
 
 String (unsigned int, unsigned char base=10)
 
 String (long, unsigned char base=10)
 
 String (unsigned long, unsigned char base=10)
 
 String (float, unsigned char decimalPlaces=2)
 
 String (double, unsigned char decimalPlaces=2)
 
void setString (const char *cstr, int length=-1)
 
void setString (flash_string_t pstr, int length=-1)
 
bool reserve (unsigned int size)
 
bool setLength (unsigned int length)
 set the string length accordingly, expanding if necessary More...
 
unsigned int length (void) const
 
String &STRING_IRAM_ATTR operator= (const String &rhs)
 
String &STRING_IRAM_ATTR operator= (const char *cstr)
 
Stringoperator= (String &&rval)
 
Stringoperator= (StringSumHelper &&rval)
 
bool concat (const String &str)
 
bool concat (const char *cstr)
 
bool STRING_IRAM_ATTR concat (const char *cstr, unsigned int length)
 
bool concat (char c)
 
bool concat (unsigned char c)
 
bool concat (int num)
 
bool concat (unsigned int num)
 
bool concat (long num)
 
bool concat (unsigned long num)
 
bool concat (float num)
 
bool concat (double num)
 
Stringoperator+= (const String &rhs)
 
Stringoperator+= (const char *cstr)
 
Stringoperator+= (char c)
 
Stringoperator+= (unsigned char num)
 
Stringoperator+= (int num)
 
Stringoperator+= (unsigned int num)
 
Stringoperator+= (long num)
 
Stringoperator+= (unsigned long num)
 
Stringoperator+= (float num)
 
Stringoperator+= (double num)
 
 operator StringIfHelperType () const
 
int STRING_IRAM_ATTR compareTo (const String &s) const
 
bool STRING_IRAM_ATTR equals (const String &s) const
 
bool STRING_IRAM_ATTR equals (const char *cstr) const
 
bool equals (const FlashString &fstr) const
 
bool STRING_IRAM_ATTR operator== (const String &rhs) const
 
bool STRING_IRAM_ATTR operator== (const char *cstr) const
 
bool STRING_IRAM_ATTR operator== (const FlashString &fstr) const
 
bool STRING_IRAM_ATTR operator!= (const String &rhs) const
 
bool STRING_IRAM_ATTR operator!= (const char *cstr) const
 
bool operator< (const String &rhs) const
 
bool operator> (const String &rhs) const
 
bool operator<= (const String &rhs) const
 
bool operator>= (const String &rhs) const
 
bool equalsIgnoreCase (const char *cstr) const
 
bool equalsIgnoreCase (const String &s2) const
 
bool equalsIgnoreCase (const FlashString &fstr) const
 
bool startsWith (const String &prefix) const
 
bool startsWith (const String &prefix, unsigned int offset) const
 
bool endsWith (const String &suffix) const
 
char STRING_IRAM_ATTR charAt (unsigned int index) const
 
void STRING_IRAM_ATTR setCharAt (unsigned int index, char c)
 
char STRING_IRAM_ATTR operator[] (unsigned int index) const
 
char &STRING_IRAM_ATTR operator[] (unsigned int index)
 
unsigned int getBytes (unsigned char *buf, unsigned int bufsize, unsigned int index=0) const
 read contents of string into a buffer More...
 
void toCharArray (char *buf, unsigned int bufsize, unsigned int index=0) const
 
const char * c_str () const
 
char * begin ()
 
char * end ()
 
const char * begin () const
 
const char * end () const
 
int STRING_IRAM_ATTR indexOf (char ch) const
 
int indexOf (char ch, unsigned int fromIndex) const
 
int STRING_IRAM_ATTR indexOf (const String &str) const
 
int indexOf (const String &s2, unsigned int fromIndex) const
 
int lastIndexOf (char ch) const
 
int lastIndexOf (char ch, unsigned int fromIndex) const
 
int lastIndexOf (const String &s2) const
 
int lastIndexOf (const String &s2, unsigned int fromIndex) const
 
String substring (unsigned int beginIndex) const
 
String substring (unsigned int beginIndex, unsigned int endIndex) const
 
void replace (char find, char replace)
 
void replace (const String &find, const String &replace)
 
void remove (unsigned int index)
 
void remove (unsigned int index, unsigned int count)
 
void toLowerCase (void)
 
void toUpperCase (void)
 
void trim (void)
 
long toInt (void) const
 
float toFloat (void) const
 

Static Public Attributes

static const String nullstr
 A null string evaluates to false. More...
 
static const String empty
 An empty string evaluates to true. More...
 

Protected Member Functions

void STRING_IRAM_ATTR invalidate (void)
 
bool STRING_IRAM_ATTR changeBuffer (unsigned int maxStrLen)
 
Stringcopy (const char *cstr, unsigned int length)
 
Stringcopy (flash_string_t pstr, unsigned int length)
 
void move (String &rhs)
 

Protected Attributes

char * buffer = nullptr
 
uint16_t capacity = 0
 
uint16_t len = 0
 

Friends

StringSumHelperoperator+ (const StringSumHelper &lhs, const String &rhs)
 
StringSumHelperoperator+ (const StringSumHelper &lhs, const char *cstr)
 
StringSumHelperoperator+ (const StringSumHelper &lhs, char c)
 
StringSumHelperoperator+ (const StringSumHelper &lhs, unsigned char num)
 
StringSumHelperoperator+ (const StringSumHelper &lhs, int num)
 
StringSumHelperoperator+ (const StringSumHelper &lhs, unsigned int num)
 
StringSumHelperoperator+ (const StringSumHelper &lhs, long num)
 
StringSumHelperoperator+ (const StringSumHelper &lhs, unsigned long num)
 
StringSumHelperoperator+ (const StringSumHelper &lhs, float num)
 
StringSumHelperoperator+ (const StringSumHelper &lhs, double num)
 

Detailed Description

The string class.

Note that a string object's default constructor creates an empty string. This is not the same as a null string. A null string evaluates to false An empty string evaluates to true

Member Function Documentation

unsigned int String::getBytes ( unsigned char *  buf,
unsigned int  bufsize,
unsigned int  index = 0 
) const

read contents of string into a buffer

Parameters
bufbuffer to write data
bufsizesize of buffer in bytes
indexoffset to start
Return values
unsignednumber of bytes copied, excluding nul terminator
Note
Returned data always nul terminated so buffer size needs to take this into account
bool String::setLength ( unsigned int  length)

set the string length accordingly, expanding if necessary

Parameters
lengthrequired for string (nul terminator additional)
Return values
trueon success, false on failure
Note
extra characters are undefined

Member Data Documentation

const String String::empty
static

An empty string evaluates to true.

const String String::nullstr
static

A null string evaluates to false.