diff options
author | Cristian Maglie <c.maglie@bug.st> | 2013-06-06 19:53:31 +0200 |
---|---|---|
committer | Cristian Maglie <c.maglie@bug.st> | 2013-06-06 19:54:58 +0200 |
commit | 550b6adcfc4e2dba5678155a883eecdf0840c8e9 (patch) | |
tree | ac7613d448a3c10138bed97909dd4dbf5177d0f2 /cores/arduino/WString.h | |
parent | db286ac0c1305f9f6338acc37da7c24ebdc9243b (diff) | |
parent | c8a79d0d0c999997d2ee9cd5b773b5ff6561e130 (diff) |
Merged various bugfix / improvements to String class.
Merge branch 'master' into ide-1.5.x
Diffstat (limited to 'cores/arduino/WString.h')
-rw-r--r-- | cores/arduino/WString.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cores/arduino/WString.h b/cores/arduino/WString.h index c07e1a9..44a8419 100644 --- a/cores/arduino/WString.h +++ b/cores/arduino/WString.h @@ -69,6 +69,8 @@ public: explicit String(unsigned int, unsigned char base=10); explicit String(long, unsigned char base=10); explicit String(unsigned long, unsigned char base=10); + explicit String(float, int decimalPlaces=6); + explicit String(double, int decimalPlaces=6); ~String(void); // memory management @@ -102,6 +104,8 @@ public: unsigned char concat(unsigned int num); unsigned char concat(long num); unsigned char concat(unsigned long num); + unsigned char concat(float num); + unsigned char concat(double num); unsigned char concat(const __FlashStringHelper * str); // if there's not enough memory for the concatenated value, the string @@ -114,6 +118,8 @@ public: 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);} + String & operator += (float num) {concat(num); return (*this);} + String & operator += (double num) {concat(num); return (*this);} String & operator += (const __FlashStringHelper *str){concat(str); return (*this);} friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs); @@ -124,6 +130,8 @@ public: 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); friend StringSumHelper & operator + (const StringSumHelper &lhs, const __FlashStringHelper *rhs); // comparison (only works w/ Strings and "strings") @@ -169,12 +177,15 @@ public: // modification 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); // parsing/conversion long toInt(void) const; + float toFloat(void) const; protected: char *buffer; // the actual char array @@ -206,6 +217,8 @@ public: StringSumHelper(unsigned int num) : String(num) {} StringSumHelper(long num) : String(num) {} StringSumHelper(unsigned long num) : String(num) {} + StringSumHelper(float num) : String(num) {} + StringSumHelper(double num) : String(num) {} }; #endif // __cplusplus |