WString

From chipKIT
Jump to: navigation, search
WString
Quick Look
Hardware (External hardware)
Core Wstring.h

WString is a String library for Wiring & Arduino

Contents

Detailed Introduction

The String Class in WString provides functions and operators for working with Strings.

Full library usage

String

Constructors

String(const char *cstr = "")

	String(const char *cstr = "");

String(const String &str)

	String(const String &str);

String(char c)

	explicit String(char c);

String(unsigned char, unsigned char base=10)

	explicit String(unsigned char, unsigned char base=10);

String(int, unsigned char base=10)

	explicit String(int, unsigned char base=10);

String(unsigned int, unsigned char base=10)

	explicit String(unsigned int, unsigned char base=10);

String(long, unsigned char base=10)

	
	explicit String(long, unsigned char base=10);

String(unsigned long, unsigned char base=10)

	
	explicit String(unsigned long, unsigned char base=10);

String(float, unsigned char decimalPlaces=6)

	
    explicit String(float, unsigned char decimalPlaces=6);

String(double, unsigned char decimalPlaces=6)

	
    explicit String(double, unsigned char decimalPlaces=6);

Public Functions

Memory Management

reserve(unsigned int size)
	
    unsigned char reserve(unsigned int size);
length(void)
	
    inline unsigned int length(void) const {return len;}

Concatenation

concat(const String &str)
	unsigned char concat(const String &str);
concat(const char *cstr)
	
	unsigned char concat(const char *cstr);
concat(char c)
		
	unsigned char concat(char c);
concat(unsigned char c)
	
	unsigned char concat(unsigned char c);
concat(int num)
		
	unsigned char concat(int num);
concat(unsigned int num)
		
	unsigned char concat(unsigned int num);
concat(long num)
		
	unsigned char concat(long num);
concat(unsigned long num)
	
	unsigned char concat(unsigned long num);
concat(float num)
		
	unsigned char concat(float num);
concat(double num)
		
	unsigned char concat(double num);
operator +=
	
	// if there's not enough memory for the concatenated value, the string
	// will be left unchanged (but this isn't signalled in any way)
	String & operator += (const String &rhs)	{concat(rhs); return (*this);}
	String & operator += (const char *cstr)		{concat(cstr); return (*this);}
	String & operator += (char c)			{concat(c); return (*this);}
	String & operator += (unsigned char num)		{concat(num); return (*this);}
	String & operator += (int num)			{concat(num); return (*this);}
	String & operator += (unsigned int num)		{concat(num); return (*this);}
	String & operator += (long num)			{concat(num); return (*this);}
	String & operator += (unsigned long num)	{concat(num); return (*this);}
operator +
	friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs);
	friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr);
	friend StringSumHelper & operator + (const StringSumHelper &lhs, char c);
	friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num);
	friend StringSumHelper & operator + (const StringSumHelper &lhs, int num);
	friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num);
	friend StringSumHelper & operator + (const StringSumHelper &lhs, long num);
	friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num);
	friend StringSumHelper & operator + (const StringSumHelper &lhs, float num);
	friend StringSumHelper & operator + (const StringSumHelper &lhs, double num);

Comparison

compareTo(const String &s)
	int compareTo(const String &s) const;
equals(const String &s)
	unsigned char equals(const String &s) const;
equals(const char *cstr)
	
	unsigned char equals(const char *cstr) const;
operator ==
	
	unsigned char operator == (const String &rhs) const {return equals(rhs);}
	unsigned char operator == (const char *cstr) const {return equals(cstr);}
operator !=
	
	unsigned char operator != (const String &rhs) const {return !equals(rhs);}
	unsigned char operator != (const char *cstr) const {return !equals(cstr);}
operator <
	
	unsigned char operator <  (const String &rhs) const;
operator >
	
	unsigned char operator >  (const String &rhs) const;
operator <=
	
	unsigned char operator <= (const String &rhs) const;
operator >=
	
	unsigned char operator >= (const String &rhs) const;
equalsIgnoreCase(const String &s)
	
	unsigned char equalsIgnoreCase(const String &s) const;
startsWith( const String &prefix)
	
	unsigned char startsWith( const String &prefix) const;
startsWith(const String &prefix, unsigned int offset)
	
	unsigned char startsWith(const String &prefix, unsigned int offset) const;
endsWith(const String &suffix)
	
	unsigned char endsWith(const String &suffix) const;

Character Access

charAt(unsigned int index)
	char charAt(unsigned int index) const;
setCharAt(unsigned int index, char c)
	void setCharAt(unsigned int index, char c);
operator [] (unsigned int index)
	char operator [] (unsigned int index) const;
	char& operator [] (unsigned int index);
getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0)
	void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0) const;
toCharArray(char *buf, unsigned int bufsize, unsigned int index=0)
	void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const
		{getBytes((unsigned char *)buf, bufsize, index);}

Search

indexOf( char ch )
	int indexOf( char ch ) const;
indexOf( char ch, unsigned int fromIndex )
	int indexOf( char ch, unsigned int fromIndex ) const;
indexOf( const String &str )
	
	int indexOf( const String &str ) const;
indexOf( const String &str, unsigned int fromIndex )
	
	int indexOf( const String &str, unsigned int fromIndex ) const;
lastIndexOf( char ch )
	
	int lastIndexOf( char ch ) const;
lastIndexOf( char ch, unsigned int fromIndex )
	
	int lastIndexOf( char ch, unsigned int fromIndex ) const;
lastIndexOf( const String &str )
	
	int lastIndexOf( const String &str ) const;
lastIndexOf( const String &str, unsigned int fromIndex )
	
	int lastIndexOf( const String &str, unsigned int fromIndex ) const;
substring( unsigned int beginIndex )
	
	String substring( unsigned int beginIndex ) const;
substring( unsigned int beginIndex, unsigned int endIndex )
	
	String substring( unsigned int beginIndex, unsigned int endIndex ) const;

Modification

replace(char find, char replace)
	String & replace(char find, char replace);
replace(const String& find, const String& replace)
	
	String & replace(const String& find, const String& replace);
remove(unsigned int index)
	
	String & remove(unsigned int index);
remove(unsigned int index, unsigned int count)
	
	String & remove(unsigned int index, unsigned int count);
toLowerCase(void)
	
	String & toLowerCase(void);
toUpperCase(void)
	
	String & toUpperCase(void);
trim(void)
	
	String & trim(void);

Conversion

toInt(void)
	
    long toInt(void) const;
toFloat(void)
	
    float toFloat(void) const;

StringSumHelper

StringSumHelper(const String &s)

	StringSumHelper(const String &s) : String(s) {}

StringSumHelper(const char *p)

	StringSumHelper(const char *p) : String(p) {}

StringSumHelper(char c)

	StringSumHelper(char c) : String(c) {}

StringSumHelper(unsigned char num)

	StringSumHelper(unsigned char num) : String(num) {}

StringSumHelper(int num)

	StringSumHelper(int num) : String(num) {}

StringSumHelper(unsigned int num)

	StringSumHelper(unsigned int num) : String(num) {}

StringSumHelper(long num)

	StringSumHelper(long num) : String(num) {}

StringSumHelper(unsigned long num)

	StringSumHelper(unsigned long num) : String(num) {}


External Links