Merge pull request #3121 from tks2shimizu/develop

Add append function for String class.
This commit is contained in:
minggo 2013-07-10 00:58:43 -07:00
commit bbaa938cf7
2 changed files with 28 additions and 0 deletions

View File

@ -129,6 +129,28 @@ int String::compare(const char * pStr) const
return strcmp(getCString(), pStr);
}
void String::append(const std::string& str)
{
_string.append(str);
}
void String::appendWithFormat(const char* format, ...)
{
va_list ap;
va_start(ap, format);
char* pBuf = (char*)malloc(kMaxStringLen);
if (pBuf != NULL)
{
vsnprintf(pBuf, kMaxStringLen, format, ap);
_string.append(pBuf);
free(pBuf);
}
va_end(ap);
}
bool String::isEqual(const Object* pObject)
{
bool bRet = false;

View File

@ -80,6 +80,12 @@ public:
/** compare to a c string */
int compare(const char *) const;
/** append additional characters at the end of its current value */
void append(const std::string& str);
/** append(w/ format) additional characters at the end of its current value */
void appendWithFormat(const char* format, ...);
/* override functions */
virtual bool isEqual(const Object* pObject);