mirror of https://github.com/axmolengine/axmol.git
Merge pull request #3121 from tks2shimizu/develop
Add append function for String class.
This commit is contained in:
commit
bbaa938cf7
|
@ -129,6 +129,28 @@ int String::compare(const char * pStr) const
|
||||||
return strcmp(getCString(), pStr);
|
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 String::isEqual(const Object* pObject)
|
||||||
{
|
{
|
||||||
bool bRet = false;
|
bool bRet = false;
|
||||||
|
|
|
@ -80,6 +80,12 @@ public:
|
||||||
/** compare to a c string */
|
/** compare to a c string */
|
||||||
int compare(const char *) const;
|
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 */
|
/* override functions */
|
||||||
virtual bool isEqual(const Object* pObject);
|
virtual bool isEqual(const Object* pObject);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue