diff --git a/core/Common/String.cpp b/core/Common/String.cpp index a8e59e26..066c5c4a 100644 --- a/core/Common/String.cpp +++ b/core/Common/String.cpp @@ -333,6 +333,20 @@ e2d::String::operator wchar_t*() const return const_cast(_str.c_str()); } +e2d::String::operator const char*() const +{ + static std::string strTmp; + strTmp = static_cast(_bstr_t(_str.c_str())); + return strTmp.c_str(); +} + +e2d::String::operator char*() const +{ + static std::string strTmp; + strTmp = static_cast(_bstr_t(_str.c_str())); + return const_cast(strTmp.c_str()); +} + bool e2d::String::isEmpty() const { return _str.empty(); @@ -450,7 +464,7 @@ void e2d::String::replace(const String & from, const String & to) return; size_t start_pos = 0; - while ((start_pos = _str.find((const wchar_t *)from, start_pos)) != std::string::npos) + while ((start_pos = _str.find((const wchar_t *)from, start_pos)) != std::wstring::npos) { _str.replace(start_pos, from._str.length(), (const wchar_t *)to); start_pos += to._str.length(); diff --git a/core/e2dcommon.h b/core/e2dcommon.h index 643b2d44..900c679f 100644 --- a/core/e2dcommon.h +++ b/core/e2dcommon.h @@ -238,6 +238,8 @@ public: // 类型转换操作符 E2D_OP_EXPLICIT operator const wchar_t* () const; E2D_OP_EXPLICIT operator wchar_t* () const; + E2D_OP_EXPLICIT operator const char* () const; + E2D_OP_EXPLICIT operator char* () const; // 比较运算符 bool operator== (const String &) const;