Remove String::append function

This commit is contained in:
Nomango 2018-03-12 15:55:41 +08:00
parent 24ab490804
commit 6909067a60
2 changed files with 45 additions and 81 deletions

View File

@ -37,19 +37,19 @@ e2d::String::~String()
e2d::String &e2d::String::operator=(const wchar_t *str) e2d::String &e2d::String::operator=(const wchar_t *str)
{ {
m_str = str; m_str = str;
return *this; return (*this);
} }
e2d::String & e2d::String::operator=(const char *cstr) e2d::String & e2d::String::operator=(const char *cstr)
{ {
m_str = static_cast<wchar_t*>(_bstr_t(cstr)); m_str = static_cast<wchar_t*>(_bstr_t(cstr));
return *this; return (*this);
} }
e2d::String & e2d::String::operator=(const String &str) e2d::String & e2d::String::operator=(const String &str)
{ {
m_str = str.m_str; m_str = str.m_str;
return *this; return (*this);
} }
bool e2d::String::operator==(const wchar_t *str) bool e2d::String::operator==(const wchar_t *str)
@ -192,27 +192,56 @@ bool e2d::String::operator<=(const String &str) const
e2d::String & e2d::String::operator<<(const String &str) e2d::String & e2d::String::operator<<(const String &str)
{ {
return this->append(str); m_str += str.m_str;
return (*this);
} }
e2d::String & e2d::String::operator<<(const wchar_t *str) e2d::String & e2d::String::operator<<(const wchar_t *str)
{ {
return this->append(str); m_str += str;
return (*this);
} }
e2d::String & e2d::String::operator<<(wchar_t *str) e2d::String & e2d::String::operator<<(wchar_t *str)
{ {
return this->append(str); m_str += str;
return (*this);
} }
e2d::String & e2d::String::operator<<(const char * value) e2d::String & e2d::String::operator<<(const char * cstr)
{ {
return this->append(value); m_str += static_cast<wchar_t*>(_bstr_t(cstr));
return (*this);
} }
e2d::String & e2d::String::operator<<(char * value) e2d::String & e2d::String::operator<<(char * cstr)
{ {
return this->append(value); m_str += static_cast<wchar_t*>(_bstr_t(cstr));
return (*this);
}
e2d::String & e2d::String::operator<<(int value)
{
(*this) += String::toString(value);
return (*this);
}
e2d::String & e2d::String::operator<<(unsigned int value)
{
(*this) += String::toString(value);
return (*this);
}
e2d::String & e2d::String::operator<<(float value)
{
(*this) += String::toString(value);
return (*this);
}
e2d::String & e2d::String::operator<<(double value)
{
(*this) += String::toString(value);
return (*this);
} }
e2d::String::operator const wchar_t*() const e2d::String::operator const wchar_t*() const
@ -352,36 +381,6 @@ void e2d::String::clear()
m_str.clear(); m_str.clear();
} }
e2d::String & e2d::String::append(const wchar_t * str)
{
m_str += str;
return *this;
}
e2d::String & e2d::String::append(wchar_t * str)
{
m_str += str;
return *this;
}
e2d::String & e2d::String::append(const char * str)
{
m_str += static_cast<wchar_t*>(_bstr_t(str));
return *this;
}
e2d::String & e2d::String::append(char * str)
{
m_str += static_cast<wchar_t*>(_bstr_t(str));
return *this;
}
e2d::String & e2d::String::append(const e2d::String & str)
{
m_str += str.m_str;
return (*this);
}
std::wostream & e2d::operator<<(std::wostream &cout, const String &str) std::wostream & e2d::operator<<(std::wostream &cout, const String &str)
{ {
cout << str.m_str; cout << str.m_str;

View File

@ -111,35 +111,6 @@ public:
// »ñÈ¡ ANSI ×Ö·û´® // »ñÈ¡ ANSI ×Ö·û´®
std::string getCString() const; std::string getCString() const;
// ºó½Ó×Ö·û´®
String& append(
const String &str
);
// ºó½Ó×Ö·û´®
String& append(
const char * cstr
);
// ºó½Ó×Ö·û´®
String& append(
char * cstr
);
// ºó½Ó×Ö·û´®
String& append(
const wchar_t *str
);
// ºó½Ó×Ö·û´®
String& append(
wchar_t *str
);
// ºó½Ó×Ö·û´®
template<typename T>
String& append(const T &value);
// »ñÈ¡²Ã¼ô×Ö·û´® // »ñÈ¡²Ã¼ô×Ö·û´®
String subtract( String subtract(
int offset, /* Æ«ÒÆÁ¿ */ int offset, /* Æ«ÒÆÁ¿ */
@ -211,14 +182,16 @@ public:
bool operator< (const String &) const; bool operator< (const String &) const;
bool operator<= (const String &) const; bool operator<= (const String &) const;
// << ÔËËã·û // << ÔËËã·û£¨ºó½Ó×Ö·û´®£©
String& operator<< (const String &); String& operator<< (const String &);
String& operator<< (const char *); String& operator<< (const char *);
String& operator<< (char *); String& operator<< (char *);
String& operator<< (const wchar_t *); String& operator<< (const wchar_t *);
String& operator<< (wchar_t *); String& operator<< (wchar_t *);
template<typename T> String& operator<< (int value);
String& operator<< (const T value) { return this->append<>(value); } String& operator<< (unsigned int value);
String& operator<< (float value);
String& operator<< (double value);
// ÆäËûÔËËã·û // ÆäËûÔËËã·û
wchar_t& operator[] (int); wchar_t& operator[] (int);
@ -734,14 +707,6 @@ protected:
}; };
// String ÀàÄ£°åº¯Êý¶¨Òå // String ÀàÄ£°åº¯Êý¶¨Òå
template<typename T>
inline e2d::String & e2d::String::append(const T & value)
{
std::wostringstream ss;
ss << value;
m_str += ss.str();
return (*this);
}
template<typename T> template<typename T>
inline e2d::String e2d::String::toString(const T value) inline e2d::String e2d::String::toString(const T value)