1
0
forked from 0ad/0ad

Altered the automatic CStr8/CStrW conversion -- it seems to work now

This was SVN commit r1131.
This commit is contained in:
Ykkrosh 2004-09-06 11:15:43 +00:00
parent d373e7a559
commit f791e5f665
2 changed files with 13 additions and 11 deletions

View File

@ -9,6 +9,10 @@
#define UNIDOUBLER_HEADER "CStr.cpp" #define UNIDOUBLER_HEADER "CStr.cpp"
#include "UniDoubler.h" #include "UniDoubler.h"
// Only include these function definitions in the first instance of CStr.cpp:
CStrW::CStrW(const CStr8 &asciStr) : m_String(asciStr.m_String.begin(), asciStr.m_String.end()) {}
CStr8::CStr8(const CStrW &wideStr) : m_String(wideStr.m_String.begin(), wideStr.m_String.end()) {}
#else #else
#include "CStr.h" #include "CStr.h"

View File

@ -90,11 +90,16 @@ enum PS_TRIM_MODE {PS_TRIM_LEFT, PS_TRIM_RIGHT, PS_TRIM_BOTH};
#endif #endif
class CStr8;
class CStrW;
// CStr class, the mother of all strings // CStr class, the mother of all strings
class CStr: public ISerializable class CStr: public ISerializable
{ {
#ifdef _UNICODE #ifdef _UNICODE
friend class CStr8; friend class CStr8;
#else
friend class CStrW;
#endif #endif
public: public:
@ -102,18 +107,11 @@ public:
CStr(); // Default constructor CStr(); // Default constructor
CStr(const CStr& Str); // Copy Constructor CStr(const CStr& Str); // Copy Constructor
// Transparent CStrW/8 conversion. Note that CStr8 will provide both // Transparent CStrW/8 conversion.
// definitions since CStrW is defined first - would otherwise result in a
// circular dependency
#ifndef _UNICODE #ifndef _UNICODE
inline CStr8(const CStrW &wideStr): CStr8(const CStrW &wideStr);
m_String(wideStr.m_String.begin(), wideStr.m_String.end()) #else
{} CStrW(const CStr8 &asciiStr);
inline operator CStrW ()
{
return CStrW(std::wstring(m_String.begin(), m_String.end()));
}
#endif #endif
CStr(std::tstring String); // Creates CStr from C++ string CStr(std::tstring String); // Creates CStr from C++ string