diff --git a/stepmania/src/StdAfx.h b/stepmania/src/StdAfx.h index 8fca6d5285..73a1786485 100644 --- a/stepmania/src/StdAfx.h +++ b/stepmania/src/StdAfx.h @@ -81,43 +81,9 @@ using namespace std; #define NORETURN #endif -#if 1 - -#include "StdString.h" - /* Use CStdString: */ +#include "StdString.h" #define CString CStdString -#else - -/* Wrapper to use getline() on MFC strings. */ -template inline -basic_istream<_E, _Tr>& getline(basic_istream<_E, _Tr> &I, - CString &X) { - string str; - - basic_istream<_E, _Tr> &ret = getline(I, str); - X = str.c_str(); - return ret; -} - -/* Arg. VC7's CString has GetString(), an equivalent of c_str(). - * VC6 doesn't have that. We need it to transition to std::string - * sanely. So, sneakily add it. This goes away when we finish - * transitioning. */ -#if _MSC_VER < 1300 /* VC6, not VC7 */ -class CStringTemp: public CString { -public: - CStringTemp() {} - CStringTemp(const char *s): CString(s) { } - CStringTemp(const CString &s): CString(s) {} - - const char *GetString() const { return (const char *) *this; } -}; -#define CString CStringTemp - -#endif - -#endif #if defined(_MSC_VER) && _MSC_VER < 1300 /* VC6, not VC7 */ diff --git a/stepmania/src/StdString.h b/stepmania/src/StdString.h index 80c2f2617e..ac4595eeb8 100644 --- a/stepmania/src/StdString.h +++ b/stepmania/src/StdString.h @@ -308,7 +308,6 @@ inline const Type& SSMAX(const Type& arg1, const Type& arg2) typedef const char* PCSTR; typedef char* PSTR; - typedef const wchar_t* PCWSTR; #ifdef UNICODE typedef wchar_t TCHAR; #else @@ -394,7 +393,7 @@ inline const Type& SSMAX(const Type& arg1, const Type& arg2) #define TRACE #endif -// Microsoft defines PCSTR, PCWSTR, etc, but no PCTSTR. I hate to use the +// Microsoft defines PCSTR, etc, but no PCTSTR. I hate to use the // versions with the "L" in front of them because that's a leftover from Win 16 // days, even though it evaluates to the same thing. Therefore, Define a PCSTR // as an LPCTSTR. @@ -456,9 +455,9 @@ inline const Type& SSMAX(const Type& arg1, const Type& arg2) #endif #endif -// ============================================================================= -// UNICODE/MBCS conversion macros. Made to work just like the MFC/ATL ones. -// ============================================================================= +#ifndef SS_ANSI +#include +#endif // First define the conversion helper functions. We define these regardless of // any preprocessor macro settings since their names won't collide. @@ -482,69 +481,6 @@ inline const Type& SSMAX(const Type& arg1, const Type& arg2) // locale header (and thus the codecvt facet) can use good old mbstowcs and // wcstombs instead by #defining SS_NOLOCALE - #ifdef SS_NOLOCALE - - inline PSTR StdCodeCvt(PSTR pA, PCWSTR pW, int nChars) - { - ASSERT(0 != pA); - ASSERT(0 != pW); - pA[0] = '\0'; - int nCvt = wcstombs(pA, pW, nChars); - ASSERT(nCvt >=0); - return pA; - } - inline PUSTR StdCodeCvt(PUSTR pA, PCWSTR pW, int nChars) - { - return (PUSTR)StdCodeCvt((PSTR)pA, pW, nChars); - } - - #else - - typedef std::codecvt SSCodeCvt; - - // StdCodeCvt - made to look like Win32 functions WideCharToMultiByte - // and MultiByteToWideChar but uses locales in SS_ANSI - // builds - inline PSTR StdCodeCvt(PSTR pA, PCWSTR pW, int nChars, - const std::locale& loc=std::locale()) - { - ASSERT(0 != pA); - ASSERT(0 != pW); - pA[0] = '\0'; - PSTR pBadA = 0; - PCWSTR pBadW = 0; - SSCodeCvt::result res = SSCodeCvt::ok; - const SSCodeCvt& conv = SS_USE_FACET(loc, SSCodeCvt); - SSCodeCvt::state_type st= { 0 }; - res = conv.out(st, - pW, pW + nChars, pBadW, - pA, pA + nChars, pBadA); - ASSERT(SSCodeCvt::ok == res); - return pA; - } - inline PUSTR StdCodeCvt(PUSTR pA, PCWSTR pW, int nChars, - const std::locale& loc=std::locale()) - { - return (PUSTR)StdCodeCvt((PSTR)pA, pW, nChars, loc); - } - #endif - -#else // ...or are we doing things assuming win32 and Visual C++? - - #include // needed for _alloca - - inline PSTR StdCodeCvt(PSTR pA, PCWSTR pW, int nChars, UINT acp=CP_ACP) - { - ASSERT(0 != pA); - ASSERT(0 != pW); - pA[0] = '\0'; - WideCharToMultiByte(acp, 0, pW, -1, pA, nChars, 0, 0); - return pA; - } - inline PUSTR StdCodeCvt(PUSTR pA, PCWSTR pW, int nChars, UINT acp=CP_ACP) - { - return (PUSTR)StdCodeCvt((PSTR)pA, pW, nChars, acp); - } #endif // #ifndef SS_ANSI // StdCodeCvt when there's no conversion to be done @@ -684,13 +620,6 @@ inline void ssasn(std::string& sDst, PCSTR pA) sDst.assign(pA); } } -inline void ssasn(std::string& sDst, PCWSTR pW) -{ - int nLen = sslen(pW); - sDst.resize(nLen * 2 + 1); - StdCodeCvt(const_cast(sDst.data()), pW, nLen); - sDst.resize(nLen); -} inline void ssasn(std::string& sDst, const int nNull) { UNUSED(nNull); @@ -710,15 +639,6 @@ inline void ssadd(std::string& sDst, const std::string& sSrc) sDst.append(sSrc.c_str()); } -inline void ssadd(std::string& sDst, PCWSTR pW) -{ - int nSrcLen = sslen(pW); - int nDstLen = sDst.size(); - int nEndLen = nSrcLen + nDstLen; - sDst.resize(nEndLen + 1); - StdCodeCvt(const_cast(sDst.data()+nDstLen), pW, nSrcLen+1); - sDst.resize(nEndLen); -} inline void ssadd(std::string& sDst, PCSTR pA) { if ( pA ) @@ -799,14 +719,6 @@ inline void ssadd(std::string& sDst, PCSTR pA) return _stricmp(pA1, pA2); } #endif - inline long sscmp(PCWSTR pW1, PCWSTR pW2) - { - return wcscmp(pW1, pW2); - } - inline long ssicmp(PCWSTR pW1, PCWSTR pW2) - { - return _wcsicmp(pW1, pW2); - } #endif // ----------------------------------------------------------------------------- @@ -897,7 +809,6 @@ inline void ssadd(std::string& sDst, PCSTR pA) // FUNCTION: sscpy // inline int sscpy(PSTR pDst, PCSTR pSrc, int nMax=-1); // inline int sscpy(PUSTR pDst, PCSTR pSrc, int nMax=-1) -// inline int sscpy(PSTR pDst, PCWSTR pSrc, int nMax=-1); // // DESCRIPTION: // This function is very much (but not exactly) like strcpy. These @@ -1031,7 +942,7 @@ class CStdStr : public std::basic_string typedef typename std::basic_string MYBASE; // my base class typedef CStdStr MYTYPE; // myself - typedef typename MYBASE::const_pointer PCMYSTR; // PCSTR or PCWSTR + typedef typename MYBASE::const_pointer PCMYSTR; // PCSTR typedef typename MYBASE::pointer PMYSTR; // PSTR typedef typename MYBASE::iterator MYITER; // my iterator type typedef typename MYBASE::const_iterator MYCITER; // you get the idea... @@ -1042,9 +953,6 @@ class CStdStr : public std::basic_string public: - // shorthand conversion from PCTSTR to string resource ID - #define _TRES(pctstr) (LOWORD((DWORD)(pctstr))) - // CStdStr inline constructors CStdStr() { @@ -1075,12 +983,6 @@ public: *this = pA; } - const CT *GetString() const { return c_str(); } - CStdStr(PCWSTR pW) - { - *this = pW; - } - CStdStr(MYCITER first, MYCITER last) : MYBASE(first, last) { @@ -1091,6 +993,8 @@ public: { } + const CT *GetString() const { return c_str(); } + // CStdStr inline assignment operators -- the ssasn function now takes care // of fixing the MSVC assignment bug (see knowledge base article Q172398). MYTYPE& operator=(const MYTYPE& str) @@ -1111,12 +1015,6 @@ public: return *this; } - MYTYPE& operator=(PCWSTR pW) - { - ssasn(*this, pW); - return *this; - } - #ifdef SS_ALLOW_UNSIGNED_CHARS MYTYPE& operator=(PCUSTR pU) { @@ -1262,12 +1160,6 @@ public: return *this; } - MYTYPE& operator+=(PCWSTR pW) - { - ssadd(*this, pW); - return *this; - } - MYTYPE& operator+=(CT t) { this->append(1, t); @@ -1286,9 +1178,7 @@ public: friend MYTYPE operator+ EMP_TEMP(const MYTYPE& str1, const MYTYPE& str2); friend MYTYPE operator+ EMP_TEMP(const MYTYPE& str, CT t); friend MYTYPE operator+ EMP_TEMP(const MYTYPE& str, PCSTR sz); - friend MYTYPE operator+ EMP_TEMP(const MYTYPE& str, PCWSTR sz); friend MYTYPE operator+ EMP_TEMP(PCSTR pA, const MYTYPE& str); - friend MYTYPE operator+ EMP_TEMP(PCWSTR pW, const MYTYPE& str); // ------------------------------------------------------------------------- // Case changing functions @@ -1793,22 +1683,6 @@ CStdStr operator+(PCSTR pA, const CStdStr& str) return strRet; } -template -inline -CStdStr operator+(const CStdStr& str, PCWSTR pW) -{ - return CStdStr(str) + CStdStr(pW); -} - -template -inline -CStdStr operator+(PCWSTR pW, const CStdStr& str) -{ - CStdStr strRet(pW); - strRet.append(str); - return strRet; -} - @@ -1841,20 +1715,6 @@ CStdStr operator+(const CStdStr& str, wchar_t t) return strRet; } -inline -CStdStr operator+(const CStdStr& str, PCWSTR pW) -{ - return CStdStr(str) + CStdStr(pW); -} - -inline -CStdStr operator+(PCWSTR pA, const CStdStr& str) -{ - CStdStr strRet(pA); - strRet.append(str); - return strRet; -} - inline CStdStr operator+(const CStdStr& str, PCSTR pW) { @@ -1902,21 +1762,6 @@ CStdStr operator+(PCSTR pA, const CStdStr& str) return strRet; } -inline -CStdStr operator+(const CStdStr& str, PCWSTR pW) -{ - return CStdStr(str) + CStdStr(pW); -} - -inline -CStdStr operator+(PCWSTR pW, const CStdStr& str) -{ - CStdStr strRet(pW); - strRet.append(str); - return strRet; -} - - #endif // defined(__SUNPRO_CC_COMPAT) || defined(__SUNPRO_CC)