aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino/WString.h
diff options
context:
space:
mode:
authorDavid A. Mellis <d.mellis@arduino.cc>2011-03-31 10:56:14 -0400
committerDavid A. Mellis <d.mellis@arduino.cc>2011-03-31 10:56:14 -0400
commit1cac0f3eb738119f53b8fdd07bcd6d1158235476 (patch)
tree2ec1e17972d1b596ae927c1bb149141379010097 /cores/arduino/WString.h
parentffe7bc53c1862866bf38e01174bd35d20632608c (diff)
Restoring concatenation of built-in types with String.
Diffstat (limited to 'cores/arduino/WString.h')
-rw-r--r--cores/arduino/WString.h33
1 files changed, 28 insertions, 5 deletions
diff --git a/cores/arduino/WString.h b/cores/arduino/WString.h
index 673e51b..a601aca 100644
--- a/cores/arduino/WString.h
+++ b/cores/arduino/WString.h
@@ -87,25 +87,42 @@ public:
String & operator = (StringSumHelper &&rval);
#endif
- // concat
+ // concatenate (works w/ built-in types)
+
// returns true on success, false on failure (in which case, the string
// is left unchanged). if the argument is null or invalid, the
// concatenation is considered unsucessful.
unsigned char concat(const String &str);
unsigned char concat(const char *cstr);
+ unsigned char concat(char c);
+ unsigned char concat(unsigned char c);
+ unsigned char concat(int num);
+ unsigned char concat(unsigned int num);
+ unsigned char concat(long num);
+ unsigned char concat(unsigned long num);
// 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);}
- // concatenate
friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs);
friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr);
-
- // comparison
+ 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);
+
+ // comparison (only works w/ Strings and "strings")
operator StringIfHelperType() const { return buffer ? &String::StringIfHelper : 0; }
-
int compareTo(const String &s) const;
unsigned char equals(const String &s) const;
unsigned char equals(const char *cstr) const;
@@ -176,6 +193,12 @@ class StringSumHelper : public String
public:
StringSumHelper(const String &s) : String(s) {}
StringSumHelper(const char *p) : String(p) {}
+ StringSumHelper(char c) : String(c) {}
+ StringSumHelper(unsigned char num) : String(num) {}
+ StringSumHelper(int num) : String(num) {}
+ StringSumHelper(unsigned int num) : String(num) {}
+ StringSumHelper(long num) : String(num) {}
+ StringSumHelper(unsigned long num) : String(num) {}
};
#endif // __cplusplus