fixed String bugs
This commit is contained in:
		
							parent
							
								
									b853bb76cf
								
							
						
					
					
						commit
						24ab490804
					
				|  | @ -4,21 +4,6 @@ | ||||||
| #pragma comment(lib, "comsuppw.lib") | #pragma comment(lib, "comsuppw.lib") | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // 将 Unicode 字符串转化为 ANSI 字符串
 |  | ||||||
| static std::string ConvertWide2Ansi(const wchar_t* wstr) |  | ||||||
| { |  | ||||||
| 	std::string str = static_cast<char*>(_bstr_t(wstr)); |  | ||||||
| 	return std::move(str); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // 将 ANSI 字符串转化为 Unicode 字符串
 |  | ||||||
| static std::wstring ConvertAnsi2Wide(const char* cstr) |  | ||||||
| { |  | ||||||
| 	std::wstring str = static_cast<wchar_t*>(_bstr_t(cstr)); |  | ||||||
| 	return std::move(str); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| e2d::String::String() | e2d::String::String() | ||||||
| 	: m_str(L"") | 	: m_str(L"") | ||||||
| { | { | ||||||
|  | @ -30,12 +15,7 @@ e2d::String::String(const wchar_t *str) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::String::String(const char *cstr) | e2d::String::String(const char *cstr) | ||||||
| 	: m_str(ConvertAnsi2Wide(cstr)) | 	: m_str(static_cast<wchar_t*>(_bstr_t(cstr))) | ||||||
| { |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::String::String(const std::string &str) |  | ||||||
| 	: m_str(ConvertAnsi2Wide(str.c_str())) |  | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -49,11 +29,6 @@ e2d::String::String(const e2d::String &str) | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::String::String(const std::wstring &str) |  | ||||||
| 	: m_str(str) |  | ||||||
| { |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::String::~String() | e2d::String::~String() | ||||||
| { | { | ||||||
| 	m_str.clear(); | 	m_str.clear(); | ||||||
|  | @ -67,7 +42,7 @@ e2d::String &e2d::String::operator=(const wchar_t *str) | ||||||
| 
 | 
 | ||||||
| e2d::String & e2d::String::operator=(const char *cstr) | e2d::String & e2d::String::operator=(const char *cstr) | ||||||
| { | { | ||||||
| 	m_str = ConvertAnsi2Wide(cstr); | 	m_str = static_cast<wchar_t*>(_bstr_t(cstr)); | ||||||
| 	return *this; | 	return *this; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -77,18 +52,6 @@ e2d::String & e2d::String::operator=(const String &str) | ||||||
| 	return *this; | 	return *this; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::String & e2d::String::operator=(const std::wstring &str) |  | ||||||
| { |  | ||||||
| 	m_str = str; |  | ||||||
| 	return *this; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::String & e2d::String::operator=(const std::string &str) |  | ||||||
| { |  | ||||||
| 	m_str = ConvertAnsi2Wide(str.c_str()); |  | ||||||
| 	return *this; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| bool e2d::String::operator==(const wchar_t *str) | bool e2d::String::operator==(const wchar_t *str) | ||||||
| { | { | ||||||
| 	if (str) | 	if (str) | ||||||
|  | @ -119,11 +82,6 @@ bool e2d::String::operator ==(const e2d::String &str) | ||||||
| 	return m_str == str.m_str; | 	return m_str == str.m_str; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool e2d::String::operator==(const std::wstring &str) |  | ||||||
| { |  | ||||||
| 	return m_str == str; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| bool e2d::String::operator!=(const wchar_t *str) | bool e2d::String::operator!=(const wchar_t *str) | ||||||
| { | { | ||||||
| 	if (str) | 	if (str) | ||||||
|  | @ -154,11 +112,6 @@ bool e2d::String::operator!=(const e2d::String &str) | ||||||
| 	return m_str != str.m_str; | 	return m_str != str.m_str; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool e2d::String::operator!=(const std::wstring &str) |  | ||||||
| { |  | ||||||
| 	return m_str != str; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| wchar_t &e2d::String::operator[](int index) | wchar_t &e2d::String::operator[](int index) | ||||||
| { | { | ||||||
| 	return m_str[static_cast<size_t>(index)]; | 	return m_str[static_cast<size_t>(index)]; | ||||||
|  | @ -174,7 +127,7 @@ e2d::String e2d::String::operator+(const wchar_t *str) | ||||||
| e2d::String e2d::String::operator+(const char *str) | e2d::String e2d::String::operator+(const char *str) | ||||||
| { | { | ||||||
| 	String temp; | 	String temp; | ||||||
| 	temp.m_str = m_str + ::ConvertAnsi2Wide(str); | 	temp.m_str = m_str + static_cast<wchar_t*>(_bstr_t(str)); | ||||||
| 	return std::move(temp); | 	return std::move(temp); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -185,13 +138,6 @@ e2d::String e2d::String::operator+(const e2d::String &str) | ||||||
| 	return std::move(temp); | 	return std::move(temp); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::String e2d::String::operator+(const std::wstring &str) |  | ||||||
| { |  | ||||||
| 	String temp; |  | ||||||
| 	temp.m_str = m_str + str; |  | ||||||
| 	return std::move(temp); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::String e2d::operator+(const wchar_t *str1, const e2d::String &str2) | e2d::String e2d::operator+(const wchar_t *str1, const e2d::String &str2) | ||||||
| { | { | ||||||
| 	String temp; | 	String temp; | ||||||
|  | @ -202,14 +148,7 @@ e2d::String e2d::operator+(const wchar_t *str1, const e2d::String &str2) | ||||||
| e2d::String e2d::operator+(const char *str1, const String &str2) | e2d::String e2d::operator+(const char *str1, const String &str2) | ||||||
| { | { | ||||||
| 	String temp; | 	String temp; | ||||||
| 	temp.m_str = ::ConvertAnsi2Wide(str1) + str2.m_str; | 	temp.m_str = static_cast<wchar_t*>(_bstr_t(str1)) + str2.m_str; | ||||||
| 	return std::move(temp); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::String e2d::operator+(const std::wstring &str1, const e2d::String &str2) |  | ||||||
| { |  | ||||||
| 	String temp; |  | ||||||
| 	temp.m_str = str1 + str2.m_str; |  | ||||||
| 	return std::move(temp); | 	return std::move(temp); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -221,7 +160,7 @@ e2d::String & e2d::String::operator+=(const wchar_t *str) | ||||||
| 
 | 
 | ||||||
| e2d::String & e2d::String::operator+=(const char *str) | e2d::String & e2d::String::operator+=(const char *str) | ||||||
| { | { | ||||||
| 	m_str += ::ConvertAnsi2Wide(str); | 	m_str += static_cast<wchar_t*>(_bstr_t(str)); | ||||||
| 	return (*this); | 	return (*this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -231,12 +170,6 @@ e2d::String & e2d::String::operator+=(const String &str) | ||||||
| 	return (*this); | 	return (*this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::String & e2d::String::operator+=(const std::wstring &str) |  | ||||||
| { |  | ||||||
| 	m_str += str; |  | ||||||
| 	return (*this); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| bool e2d::String::operator>(const String &str) const | bool e2d::String::operator>(const String &str) const | ||||||
| { | { | ||||||
| 	return m_str > str.m_str; | 	return m_str > str.m_str; | ||||||
|  | @ -292,11 +225,6 @@ e2d::String::operator wchar_t*() const | ||||||
| 	return const_cast<wchar_t*>(m_str.c_str()); | 	return const_cast<wchar_t*>(m_str.c_str()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::String::operator const char*() const |  | ||||||
| { |  | ||||||
| 	return ::ConvertWide2Ansi(m_str.c_str()).c_str(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| bool e2d::String::isEmpty() const | bool e2d::String::isEmpty() const | ||||||
| { | { | ||||||
| 	return m_str.empty(); | 	return m_str.empty(); | ||||||
|  | @ -319,6 +247,17 @@ unsigned int e2d::String::getHashCode() const | ||||||
| 	return hash; | 	return hash; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | std::wstring e2d::String::getWString() const | ||||||
|  | { | ||||||
|  | 	return m_str; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | std::string e2d::String::getCString() const | ||||||
|  | { | ||||||
|  | 	std::string str = static_cast<const char *>(_bstr_t(m_str.c_str())); | ||||||
|  | 	return std::move(str); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| e2d::String e2d::String::toUpper() const | e2d::String e2d::String::toUpper() const | ||||||
| { | { | ||||||
| 	String str(*this); | 	String str(*this); | ||||||
|  | @ -427,13 +366,13 @@ e2d::String & e2d::String::append(wchar_t * str) | ||||||
| 
 | 
 | ||||||
| e2d::String & e2d::String::append(const char * str) | e2d::String & e2d::String::append(const char * str) | ||||||
| { | { | ||||||
| 	m_str += ::ConvertAnsi2Wide(str); | 	m_str += static_cast<wchar_t*>(_bstr_t(str)); | ||||||
| 	return *this; | 	return *this; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::String & e2d::String::append(char * str) | e2d::String & e2d::String::append(char * str) | ||||||
| { | { | ||||||
| 	m_str += ::ConvertAnsi2Wide(str); | 	m_str += static_cast<wchar_t*>(_bstr_t(str)); | ||||||
| 	return *this; | 	return *this; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -443,28 +382,29 @@ e2d::String & e2d::String::append(const e2d::String & str) | ||||||
| 	return (*this); | 	return (*this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::wostream & e2d::operator<<(std::wostream &cout, String &str) | std::wostream & e2d::operator<<(std::wostream &cout, const String &str) | ||||||
| { | { | ||||||
| 	cout << str.m_str; | 	cout << str.m_str; | ||||||
| 	return cout; | 	return cout; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::wistream & e2d::operator>>(std::wistream &cin, e2d::String &str) | std::wistream & e2d::operator>>(std::wistream &cin, String &str) | ||||||
| { | { | ||||||
| 	cin >> str.m_str; | 	cin >> str.m_str; | ||||||
| 	return cin; | 	return cin; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::ostream & e2d::operator<<(std::ostream &cout, String &str) | std::ostream & e2d::operator<<(std::ostream &cout, const String &str) | ||||||
| { | { | ||||||
| 	cout << ::ConvertWide2Ansi(str.m_str.c_str()); | 	std::string cstr = static_cast<char*>(_bstr_t(str.m_str.c_str())); | ||||||
|  | 	cout << cstr; | ||||||
| 	return cout; | 	return cout; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::istream & e2d::operator>>(std::istream &cin, e2d::String &str) | std::istream & e2d::operator>>(std::istream &cin, String &str) | ||||||
| { | { | ||||||
| 	std::string temp; | 	std::string temp; | ||||||
| 	cin >> temp; | 	cin >> temp; | ||||||
| 	str.m_str = ::ConvertAnsi2Wide(temp.c_str()); | 	str.m_str = static_cast<wchar_t*>(_bstr_t(temp.c_str())); | ||||||
| 	return cin; | 	return cin; | ||||||
| } | } | ||||||
|  | @ -49,7 +49,7 @@ e2d::String e2d::Data::getString(const String & key, const String & defaultValue | ||||||
| 	return temp; | 	return temp; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Data::setDefaultFileName(const String & fileName) | void e2d::Data::setDataFilePath(const String & fileName) | ||||||
| { | { | ||||||
| 	if (!fileName.isEmpty()) | 	if (!fileName.isEmpty()) | ||||||
| 	{ | 	{ | ||||||
|  |  | ||||||
|  | @ -39,7 +39,7 @@ e2d::String e2d::Path::getTempPath() | ||||||
| 
 | 
 | ||||||
| 	// 创建临时文件目录
 | 	// 创建临时文件目录
 | ||||||
| 	e2d::String tempFilePath; | 	e2d::String tempFilePath; | ||||||
| 	tempFilePath << path << L"Easy2DGameTemp"; | 	tempFilePath << path << L"Easy2DGameTemp\\"; | ||||||
| 	// 创建文件夹
 | 	// 创建文件夹
 | ||||||
| 	if (!Path::createFolder(tempFilePath)) | 	if (!Path::createFolder(tempFilePath)) | ||||||
| 	{ | 	{ | ||||||
|  | @ -51,13 +51,12 @@ e2d::String e2d::Path::getTempPath() | ||||||
| 	if (!sAppName.isEmpty()) | 	if (!sAppName.isEmpty()) | ||||||
| 	{ | 	{ | ||||||
| 		// 创建文件夹
 | 		// 创建文件夹
 | ||||||
| 		if (!Path::createFolder(tempFilePath + L"\\" + sAppName)) | 		if (!Path::createFolder(tempFilePath + sAppName + L"\\")) | ||||||
| 		{ | 		{ | ||||||
| 			return std::move(tempFilePath); | 			return std::move(tempFilePath); | ||||||
| 		} | 		} | ||||||
| 		tempFilePath << L"\\" << sAppName; | 		tempFilePath << sAppName << L"\\"; | ||||||
| 	} | 	} | ||||||
| 	tempFilePath << L"\\"; |  | ||||||
| 	return std::move(tempFilePath); | 	return std::move(tempFilePath); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										141
									
								
								core/ecommon.h
								
								
								
								
							
							
						
						
									
										141
									
								
								core/ecommon.h
								
								
								
								
							|  | @ -89,9 +89,9 @@ class String | ||||||
| { | { | ||||||
| public: | public: | ||||||
| 	String(); | 	String(); | ||||||
| 	String(const wchar_t *); |  | ||||||
| 	String(const String &); | 	String(const String &); | ||||||
| 	String(const std::wstring &); | 	String(const char *); | ||||||
|  | 	String(const wchar_t *); | ||||||
| 	String(String &&); | 	String(String &&); | ||||||
| 
 | 
 | ||||||
| 	~String(); | 	~String(); | ||||||
|  | @ -105,6 +105,27 @@ public: | ||||||
| 	// »ñÈ¡¸Ã×Ö·û´®µÄÉ¢ÁÐÖµ
 | 	// »ñÈ¡¸Ã×Ö·û´®µÄÉ¢ÁÐÖµ
 | ||||||
| 	unsigned int getHashCode() const; | 	unsigned int getHashCode() const; | ||||||
| 
 | 
 | ||||||
|  | 	// »ñÈ¡ Unicode ×Ö·û´®
 | ||||||
|  | 	std::wstring getWString() const; | ||||||
|  | 
 | ||||||
|  | 	// »ñÈ¡ ANSI ×Ö·û´®
 | ||||||
|  | 	std::string getCString() const; | ||||||
|  | 
 | ||||||
|  | 	// ºó½Ó×Ö·û´®
 | ||||||
|  | 	String& append( | ||||||
|  | 		const String &str | ||||||
|  | 	); | ||||||
|  | 
 | ||||||
|  | 	// ºó½Ó×Ö·û´®
 | ||||||
|  | 	String& append( | ||||||
|  | 		const char * cstr | ||||||
|  | 	); | ||||||
|  | 
 | ||||||
|  | 	// ºó½Ó×Ö·û´®
 | ||||||
|  | 	String& append( | ||||||
|  | 		char * cstr | ||||||
|  | 	); | ||||||
|  | 
 | ||||||
| 	// ºó½Ó×Ö·û´®
 | 	// ºó½Ó×Ö·û´®
 | ||||||
| 	String& append( | 	String& append( | ||||||
| 		const wchar_t *str | 		const wchar_t *str | ||||||
|  | @ -115,20 +136,9 @@ public: | ||||||
| 		wchar_t *str | 		wchar_t *str | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 后接字符串
 |  | ||||||
| 	String& append( |  | ||||||
| 		const String &str |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// ºó½Ó×Ö·û´®
 | 	// ºó½Ó×Ö·û´®
 | ||||||
| 	template<typename T> | 	template<typename T> | ||||||
| 	String& append(const T &value) | 	String& append(const T &value); | ||||||
| 	{ |  | ||||||
| 		std::wostringstream ss; |  | ||||||
| 		ss << value; |  | ||||||
| 		m_str += ss.str(); |  | ||||||
| 		return (*this); |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	// »ñÈ¡²Ã¼ô×Ö·û´®
 | 	// »ñÈ¡²Ã¼ô×Ö·û´®
 | ||||||
| 	String subtract( | 	String subtract( | ||||||
|  | @ -166,76 +176,58 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// ½«ÈÎÒâÀàÐÍת»¯Îª×Ö·û´®
 | 	// ½«ÈÎÒâÀàÐÍת»¯Îª×Ö·û´®
 | ||||||
| 	template<typename T> | 	template<typename T> | ||||||
| 	static String toString(const T value) | 	static String toString(const T value); | ||||||
| 	{ |  | ||||||
| 		std::wostringstream ss; |  | ||||||
| 		ss << value; |  | ||||||
| 		return ss.str(); |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	static String toString(const wchar_t * str) { return std::move(String(str)); } | 	// ¸³ÖµÔËËã·û
 | ||||||
| 	static String toString(const char * str) { return std::move(String(str)); } |  | ||||||
| 
 |  | ||||||
| 	String& operator= (const wchar_t *); |  | ||||||
| 	String& operator= (const String &); | 	String& operator= (const String &); | ||||||
| 	String& operator= (const std::wstring &); | 	String& operator= (const char *); | ||||||
|  | 	String& operator= (const wchar_t *); | ||||||
| 
 | 
 | ||||||
| 	bool operator== (const wchar_t *); | 	// ÔËËã·û
 | ||||||
| 	bool operator== (const String &); |  | ||||||
| 	bool operator== (const std::wstring &); |  | ||||||
| 
 |  | ||||||
| 	bool operator!= (const wchar_t *); |  | ||||||
| 	bool operator!= (const String &); |  | ||||||
| 	bool operator!= (const std::wstring &); |  | ||||||
| 
 |  | ||||||
| 	wchar_t &operator[] (int); |  | ||||||
| 
 |  | ||||||
| 	String operator+ (const wchar_t *); |  | ||||||
| 	String operator+ (const String &); |  | ||||||
| 	String operator+ (const std::wstring &); |  | ||||||
| 
 |  | ||||||
| 	friend String operator+ (const wchar_t*, const String &); |  | ||||||
| 	friend String operator+ (const std::wstring &, const String &); |  | ||||||
| 
 |  | ||||||
| 	String& operator+= (const wchar_t *); |  | ||||||
| 	String& operator+= (const String &); | 	String& operator+= (const String &); | ||||||
| 	String& operator+= (const std::wstring &); | 	String& operator+= (const char *); | ||||||
|  | 	String& operator+= (const wchar_t *); | ||||||
|  | 	String operator+ (const String &); | ||||||
|  | 	String operator+ (const char *); | ||||||
|  | 	String operator+ (const wchar_t *); | ||||||
| 
 | 
 | ||||||
|  | 	// ÓÑÔªÔËËã·û
 | ||||||
|  | 	friend String operator+ (const char *, const String &); | ||||||
|  | 	friend String operator+ (const wchar_t*, const String &); | ||||||
|  | 
 | ||||||
|  | 	// ÀàÐÍת»»²Ù×÷·û
 | ||||||
|  | 	operator const wchar_t* () const; | ||||||
|  | 	operator wchar_t* () const; | ||||||
|  | 
 | ||||||
|  | 	// ±È½ÏÔËËã·û
 | ||||||
|  | 	bool operator== (const String &); | ||||||
|  | 	bool operator== (const char *); | ||||||
|  | 	bool operator== (const wchar_t *); | ||||||
|  | 	bool operator!= (const String &); | ||||||
|  | 	bool operator!= (const char *); | ||||||
|  | 	bool operator!= (const wchar_t *); | ||||||
| 	bool operator> (const String &) const; | 	bool operator> (const String &) const; | ||||||
| 	bool operator>= (const String &) const; | 	bool operator>= (const String &) const; | ||||||
| 	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<< (char *); | ||||||
| 	String& operator<< (const wchar_t *); | 	String& operator<< (const wchar_t *); | ||||||
| 	String& operator<< (wchar_t *); | 	String& operator<< (wchar_t *); | ||||||
| 	template<typename T> | 	template<typename T> | ||||||
| 	String& operator<< (const T value) { return this->append<>(value); } | 	String& operator<< (const T value) { return this->append<>(value); } | ||||||
| 
 | 
 | ||||||
| 	operator const wchar_t* () const; | 	// ÆäËûÔËËã·û
 | ||||||
| 	operator wchar_t* () const; | 	wchar_t &operator[] (int); | ||||||
| 
 | 
 | ||||||
| 	friend std::wostream& operator<< (std::wostream &, String &); | 	friend std::ostream& operator<< (std::ostream &, const String &); | ||||||
| 	friend std::wistream& operator>> (std::wistream &, String &); | 	friend std::wostream& operator<< (std::wostream &, const String &); | ||||||
| 
 | 
 | ||||||
| 	// 为 ANSI 作出的适应
 |  | ||||||
| 	String(const char *); |  | ||||||
| 	String(const std::string &); |  | ||||||
| 	operator const char* () const; |  | ||||||
| 	String& operator= (const char *); |  | ||||||
| 	String& operator= (const std::string &); |  | ||||||
| 	bool operator== (const char *); |  | ||||||
| 	bool operator!= (const char *); |  | ||||||
| 	String operator+ (const char *); |  | ||||||
| 	friend String operator+ (const char *, const String &); |  | ||||||
| 	String& operator+= (const char *); |  | ||||||
| 	String& operator<< (const char *); |  | ||||||
| 	String& operator<< (char *); |  | ||||||
| 	String& append(const char *); |  | ||||||
| 	String& append(char *); |  | ||||||
| 
 |  | ||||||
| 	friend std::ostream& operator<< (std::ostream &, String &); |  | ||||||
| 	friend std::istream& operator>> (std::istream &, String &); | 	friend std::istream& operator>> (std::istream &, String &); | ||||||
|  | 	friend std::wistream& operator>> (std::wistream &, String &); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
| 	std::wstring m_str; | 	std::wstring m_str; | ||||||
|  | @ -741,4 +733,23 @@ protected: | ||||||
| 	VoidFunction m_callback; | 	VoidFunction m_callback; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | // 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> | ||||||
|  | inline e2d::String e2d::String::toString(const T value) | ||||||
|  | { | ||||||
|  | 	std::wostringstream ss; | ||||||
|  | 	ss << value; | ||||||
|  | 	String str = ss.str().c_str(); | ||||||
|  | 	return std::move(str); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  | @ -191,7 +191,7 @@ public: | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 修改数据文件的默认名称
 | 	// 修改数据文件的默认名称
 | ||||||
| 	static void setDefaultFileName( | 	static void setDataFilePath( | ||||||
| 		const String & fileName | 		const String & fileName | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue