Skip to content

Commit

Permalink
Renaming append() back to concat().
Browse files Browse the repository at this point in the history
  • Loading branch information
damellis committed Mar 11, 2011
1 parent 9139094 commit 7fa866f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
48 changes: 24 additions & 24 deletions hardware/arduino/cores/arduino/WString.cpp
Expand Up @@ -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;
if (length == 0 || !reserve(newlen)) return *this;
Expand All @@ -233,50 +233,50 @@ String & String::append(const char *cstr, unsigned int length)
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;
}

String & String::append(char c)
String & String::concat(char c)
{
char buf[2];
buf[0] = c;
buf[1] = 0;
append(buf, 1);
concat(buf, 1);
return *this;
}

String & String::append(int num)
String & String::concat(int num)
{
char buf[7];
itoa(num, buf, 10);
append(buf, strlen(buf));
concat(buf, strlen(buf));
return *this;
}

String & String::append(unsigned int num)
String & String::concat(unsigned int num)
{
char buf[6];
utoa(num, buf, 10);
append(buf, strlen(buf));
concat(buf, strlen(buf));
return *this;
}

String & String::append(long num)
String & String::concat(long num)
{
char buf[12];
ltoa(num, buf, 10);
append(buf, strlen(buf));
concat(buf, strlen(buf));
return *this;
}

String & String::append(unsigned long num)
String & String::concat(unsigned long num)
{
char buf[11];
ultoa(num, buf, 10);
append(buf, strlen(buf));
concat(buf, strlen(buf));
return *this;
}

Expand All @@ -287,56 +287,56 @@ String & String::append(unsigned long num)
StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
a.append(rhs.buffer, rhs.len);
a.concat(rhs.buffer, rhs.len);
return a;
}

StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
if (cstr) a.append(cstr, strlen(cstr));
if (cstr) a.concat(cstr, strlen(cstr));
return a;
}

StringSumHelper & operator + (const StringSumHelper &lhs, char c)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
a.append(c);
a.concat(c);
return a;
}

StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char c)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
a.append(c);
a.concat(c);
return a;
}

StringSumHelper & operator + (const StringSumHelper &lhs, int num)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
a.append(num);
a.concat(num);
return a;
}

StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
a.append(num);
a.concat(num);
return a;
}

StringSumHelper & operator + (const StringSumHelper &lhs, long num)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
a.append(num);
a.concat(num);
return a;
}

StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num)
{
StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
a.append(num);
a.concat(num);
return a;
}

Expand Down
36 changes: 18 additions & 18 deletions hardware/arduino/cores/arduino/WString.h
Expand Up @@ -72,23 +72,23 @@ class String
#endif
String & operator = (char c);

// append
String & append(const String &str);
String & append(const char *cstr);
String & append(char c);
String & append(unsigned char c) {return append((char)c);}
String & append(int num);
String & append(unsigned int num);
String & append(long num);
String & append(unsigned long num);
String & operator += (const String &rhs) {return append(rhs);}
String & operator += (const char *cstr) {return append(cstr);}
String & operator += (char c) {return append(c);}
String & operator += (unsigned char c) {return append((char)c);}
String & operator += (int num) {return append(num);}
String & operator += (unsigned int num) {return append(num);}
String & operator += (long num) {return append(num);}
String & operator += (unsigned long num) {return append(num);}
// concat
String & concat(const String &str);
String & concat(const char *cstr);
String & concat(char c);
String & concat(unsigned char c) {return concat((char)c);}
String & concat(int num);
String & concat(unsigned int num);
String & concat(long num);
String & concat(unsigned long num);
String & operator += (const String &rhs) {return concat(rhs);}
String & operator += (const char *cstr) {return concat(cstr);}
String & operator += (char c) {return concat(c);}
String & operator += (unsigned char c) {return concat((char)c);}
String & operator += (int num) {return concat(num);}
String & operator += (unsigned int num) {return concat(num);}
String & operator += (long num) {return concat(num);}
String & operator += (unsigned long num) {return concat(num);}

// concatenate
friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs);
Expand Down Expand Up @@ -156,7 +156,7 @@ class String
protected:
void init(void);
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
Expand Down

0 comments on commit 7fa866f

Please sign in to comment.