C++中的StringBuffer,使用方法与JAVA中类似
class StringBuilder{
public:
StringBuilder(void){
m_buf = "";
}
StringBuilder(CString values){
m_buf = values;
}
~StringBuilder(void){
}
CString ToCString()
{
return m_buf;
}
StringBuilder * Append(CString s)
{
CString value;
value.Format("%s%s",m_buf,s);
m_buf = CString(value);
return this;
}
//支持格式化字符串
StringBuilder *StringBuilder::AppendEx(CString format,...)
{
CString strInput;
va_list argList;
va_start(argList, format);
strInput.FormatV(format, argList);
va_end(argList);
CString value;
value.Format("%s%s",m_buf,strInput);
m_buf = CString(value);
return this;
}
private:
CString m_buf;
};