1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-20 14:54:31 +01:00

Renaming append() back to concat().

This commit is contained in:
David A. Mellis 2011-03-11 18:04:31 -05:00
parent 9139094c36
commit 7fa866ffea
2 changed files with 42 additions and 42 deletions

View File

@ -216,15 +216,15 @@ String & String::operator = (char c)
} }
/*********************************************/ /*********************************************/
/* Append */ /* concat */
/*********************************************/ /*********************************************/
String & String::append(const String &s) String & String::concat(const String &s)
{ {
return append(s.buffer, s.len); return concat(s.buffer, s.len);
} }
String & String::append(const char *cstr, unsigned int length) String & String::concat(const char *cstr, unsigned int length)
{ {
unsigned int newlen = len + length; unsigned int newlen = len + length;
if (length == 0 || !reserve(newlen)) return *this; if (length == 0 || !reserve(newlen)) return *this;
@ -233,50 +233,50 @@ String & String::append(const char *cstr, unsigned int length)
return *this; return *this;
} }
String & String::append(const char *cstr) String & String::concat(const char *cstr)
{ {
if (cstr) append(cstr, strlen(cstr)); if (cstr) concat(cstr, strlen(cstr));
return *this; return *this;
} }
String & String::append(char c) String & String::concat(char c)
{ {
char buf[2]; char buf[2];
buf[0] = c; buf[0] = c;
buf[1] = 0; buf[1] = 0;
append(buf, 1); concat(buf, 1);
return *this; return *this;
} }
String & String::append(int num) String & String::concat(int num)
{ {
char buf[7]; char buf[7];
itoa(num, buf, 10); itoa(num, buf, 10);
append(buf, strlen(buf)); concat(buf, strlen(buf));
return *this; return *this;
} }
String & String::append(unsigned int num) String & String::concat(unsigned int num)
{ {
char buf[6]; char buf[6];
utoa(num, buf, 10); utoa(num, buf, 10);
append(buf, strlen(buf)); concat(buf, strlen(buf));
return *this; return *this;
} }
String & String::append(long num) String & String::concat(long num)
{ {
char buf[12]; char buf[12];
ltoa(num, buf, 10); ltoa(num, buf, 10);
append(buf, strlen(buf)); concat(buf, strlen(buf));
return *this; return *this;
} }
String & String::append(unsigned long num) String & String::concat(unsigned long num)
{ {
char buf[11]; char buf[11];
ultoa(num, buf, 10); ultoa(num, buf, 10);
append(buf, strlen(buf)); concat(buf, strlen(buf));
return *this; return *this;
} }
@ -287,56 +287,56 @@ String & String::append(unsigned long num)
StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs) StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs)
{ {
StringSumHelper &a = const_cast<StringSumHelper&>(lhs); StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
a.append(rhs.buffer, rhs.len); a.concat(rhs.buffer, rhs.len);
return a; return a;
} }
StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr) StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr)
{ {
StringSumHelper &a = const_cast<StringSumHelper&>(lhs); StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (cstr) a.append(cstr, strlen(cstr)); if (cstr) a.concat(cstr, strlen(cstr));
return a; return a;
} }
StringSumHelper & operator + (const StringSumHelper &lhs, char c) StringSumHelper & operator + (const StringSumHelper &lhs, char c)
{ {
StringSumHelper &a = const_cast<StringSumHelper&>(lhs); StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
a.append(c); a.concat(c);
return a; return a;
} }
StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char c) StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char c)
{ {
StringSumHelper &a = const_cast<StringSumHelper&>(lhs); StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
a.append(c); a.concat(c);
return a; return a;
} }
StringSumHelper & operator + (const StringSumHelper &lhs, int num) StringSumHelper & operator + (const StringSumHelper &lhs, int num)
{ {
StringSumHelper &a = const_cast<StringSumHelper&>(lhs); StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
a.append(num); a.concat(num);
return a; return a;
} }
StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num) StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num)
{ {
StringSumHelper &a = const_cast<StringSumHelper&>(lhs); StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
a.append(num); a.concat(num);
return a; return a;
} }
StringSumHelper & operator + (const StringSumHelper &lhs, long num) StringSumHelper & operator + (const StringSumHelper &lhs, long num)
{ {
StringSumHelper &a = const_cast<StringSumHelper&>(lhs); StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
a.append(num); a.concat(num);
return a; return a;
} }
StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num) StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num)
{ {
StringSumHelper &a = const_cast<StringSumHelper&>(lhs); StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
a.append(num); a.concat(num);
return a; return a;
} }

View File

@ -72,23 +72,23 @@ public:
#endif #endif
String & operator = (char c); String & operator = (char c);
// append // concat
String & append(const String &str); String & concat(const String &str);
String & append(const char *cstr); String & concat(const char *cstr);
String & append(char c); String & concat(char c);
String & append(unsigned char c) {return append((char)c);} String & concat(unsigned char c) {return concat((char)c);}
String & append(int num); String & concat(int num);
String & append(unsigned int num); String & concat(unsigned int num);
String & append(long num); String & concat(long num);
String & append(unsigned long num); String & concat(unsigned long num);
String & operator += (const String &rhs) {return append(rhs);} String & operator += (const String &rhs) {return concat(rhs);}
String & operator += (const char *cstr) {return append(cstr);} String & operator += (const char *cstr) {return concat(cstr);}
String & operator += (char c) {return append(c);} String & operator += (char c) {return concat(c);}
String & operator += (unsigned char c) {return append((char)c);} String & operator += (unsigned char c) {return concat((char)c);}
String & operator += (int num) {return append(num);} String & operator += (int num) {return concat(num);}
String & operator += (unsigned int num) {return append(num);} String & operator += (unsigned int num) {return concat(num);}
String & operator += (long num) {return append(num);} String & operator += (long num) {return concat(num);}
String & operator += (unsigned long num) {return append(num);} String & operator += (unsigned long num) {return concat(num);}
// concatenate // concatenate
friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs); friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs);
@ -156,7 +156,7 @@ protected:
protected: protected:
void init(void); void init(void);
unsigned char changeBuffer(unsigned int maxStrLen); unsigned char changeBuffer(unsigned int maxStrLen);
String & append(const char *cstr, unsigned int length); String & concat(const char *cstr, unsigned int length);
}; };
class StringSumHelper : public String class StringSumHelper : public String