more unused stuff
This commit is contained in:
+1
-35
@@ -81,43 +81,9 @@ using namespace std;
|
|||||||
#define NORETURN
|
#define NORETURN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1
|
|
||||||
|
|
||||||
#include "StdString.h"
|
|
||||||
|
|
||||||
/* Use CStdString: */
|
/* Use CStdString: */
|
||||||
|
#include "StdString.h"
|
||||||
#define CString CStdString
|
#define CString CStdString
|
||||||
#else
|
|
||||||
|
|
||||||
/* Wrapper to use getline() on MFC strings. */
|
|
||||||
template<class _E, class _Tr> 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 */
|
#if defined(_MSC_VER) && _MSC_VER < 1300 /* VC6, not VC7 */
|
||||||
|
|
||||||
|
|||||||
+7
-162
@@ -308,7 +308,6 @@ inline const Type& SSMAX(const Type& arg1, const Type& arg2)
|
|||||||
|
|
||||||
typedef const char* PCSTR;
|
typedef const char* PCSTR;
|
||||||
typedef char* PSTR;
|
typedef char* PSTR;
|
||||||
typedef const wchar_t* PCWSTR;
|
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
typedef wchar_t TCHAR;
|
typedef wchar_t TCHAR;
|
||||||
#else
|
#else
|
||||||
@@ -394,7 +393,7 @@ inline const Type& SSMAX(const Type& arg1, const Type& arg2)
|
|||||||
#define TRACE
|
#define TRACE
|
||||||
#endif
|
#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
|
// 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
|
// days, even though it evaluates to the same thing. Therefore, Define a PCSTR
|
||||||
// as an LPCTSTR.
|
// as an LPCTSTR.
|
||||||
@@ -456,9 +455,9 @@ inline const Type& SSMAX(const Type& arg1, const Type& arg2)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// =============================================================================
|
#ifndef SS_ANSI
|
||||||
// UNICODE/MBCS conversion macros. Made to work just like the MFC/ATL ones.
|
#include <malloc.h>
|
||||||
// =============================================================================
|
#endif
|
||||||
|
|
||||||
// First define the conversion helper functions. We define these regardless of
|
// First define the conversion helper functions. We define these regardless of
|
||||||
// any preprocessor macro settings since their names won't collide.
|
// 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
|
// locale header (and thus the codecvt facet) can use good old mbstowcs and
|
||||||
// wcstombs instead by #defining SS_NOLOCALE
|
// 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<wchar_t, char, mbstate_t> 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 <malloc.h> // 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
|
#endif // #ifndef SS_ANSI
|
||||||
|
|
||||||
// StdCodeCvt when there's no conversion to be done
|
// StdCodeCvt when there's no conversion to be done
|
||||||
@@ -684,13 +620,6 @@ inline void ssasn(std::string& sDst, PCSTR pA)
|
|||||||
sDst.assign(pA);
|
sDst.assign(pA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline void ssasn(std::string& sDst, PCWSTR pW)
|
|
||||||
{
|
|
||||||
int nLen = sslen(pW);
|
|
||||||
sDst.resize(nLen * 2 + 1);
|
|
||||||
StdCodeCvt(const_cast<SS_PTRTYPE>(sDst.data()), pW, nLen);
|
|
||||||
sDst.resize(nLen);
|
|
||||||
}
|
|
||||||
inline void ssasn(std::string& sDst, const int nNull)
|
inline void ssasn(std::string& sDst, const int nNull)
|
||||||
{
|
{
|
||||||
UNUSED(nNull);
|
UNUSED(nNull);
|
||||||
@@ -710,15 +639,6 @@ inline void ssadd(std::string& sDst, const std::string& sSrc)
|
|||||||
|
|
||||||
sDst.append(sSrc.c_str());
|
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<SS_PTRTYPE>(sDst.data()+nDstLen), pW, nSrcLen+1);
|
|
||||||
sDst.resize(nEndLen);
|
|
||||||
}
|
|
||||||
inline void ssadd(std::string& sDst, PCSTR pA)
|
inline void ssadd(std::string& sDst, PCSTR pA)
|
||||||
{
|
{
|
||||||
if ( pA )
|
if ( pA )
|
||||||
@@ -799,14 +719,6 @@ inline void ssadd(std::string& sDst, PCSTR pA)
|
|||||||
return _stricmp(pA1, pA2);
|
return _stricmp(pA1, pA2);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
inline long sscmp(PCWSTR pW1, PCWSTR pW2)
|
|
||||||
{
|
|
||||||
return wcscmp(pW1, pW2);
|
|
||||||
}
|
|
||||||
inline long ssicmp(PCWSTR pW1, PCWSTR pW2)
|
|
||||||
{
|
|
||||||
return _wcsicmp(pW1, pW2);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -897,7 +809,6 @@ inline void ssadd(std::string& sDst, PCSTR pA)
|
|||||||
// FUNCTION: sscpy
|
// FUNCTION: sscpy
|
||||||
// inline int sscpy(PSTR pDst, PCSTR pSrc, int nMax=-1);
|
// inline int sscpy(PSTR pDst, PCSTR pSrc, int nMax=-1);
|
||||||
// inline int sscpy(PUSTR 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:
|
// DESCRIPTION:
|
||||||
// This function is very much (but not exactly) like strcpy. These
|
// This function is very much (but not exactly) like strcpy. These
|
||||||
@@ -1031,7 +942,7 @@ class CStdStr : public std::basic_string<CT>
|
|||||||
|
|
||||||
typedef typename std::basic_string<CT> MYBASE; // my base class
|
typedef typename std::basic_string<CT> MYBASE; // my base class
|
||||||
typedef CStdStr<CT> MYTYPE; // myself
|
typedef CStdStr<CT> 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::pointer PMYSTR; // PSTR
|
||||||
typedef typename MYBASE::iterator MYITER; // my iterator type
|
typedef typename MYBASE::iterator MYITER; // my iterator type
|
||||||
typedef typename MYBASE::const_iterator MYCITER; // you get the idea...
|
typedef typename MYBASE::const_iterator MYCITER; // you get the idea...
|
||||||
@@ -1042,9 +953,6 @@ class CStdStr : public std::basic_string<CT>
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// shorthand conversion from PCTSTR to string resource ID
|
|
||||||
#define _TRES(pctstr) (LOWORD((DWORD)(pctstr)))
|
|
||||||
|
|
||||||
// CStdStr inline constructors
|
// CStdStr inline constructors
|
||||||
CStdStr()
|
CStdStr()
|
||||||
{
|
{
|
||||||
@@ -1075,12 +983,6 @@ public:
|
|||||||
*this = pA;
|
*this = pA;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CT *GetString() const { return c_str(); }
|
|
||||||
CStdStr(PCWSTR pW)
|
|
||||||
{
|
|
||||||
*this = pW;
|
|
||||||
}
|
|
||||||
|
|
||||||
CStdStr(MYCITER first, MYCITER last)
|
CStdStr(MYCITER first, MYCITER last)
|
||||||
: MYBASE(first, 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
|
// CStdStr inline assignment operators -- the ssasn function now takes care
|
||||||
// of fixing the MSVC assignment bug (see knowledge base article Q172398).
|
// of fixing the MSVC assignment bug (see knowledge base article Q172398).
|
||||||
MYTYPE& operator=(const MYTYPE& str)
|
MYTYPE& operator=(const MYTYPE& str)
|
||||||
@@ -1111,12 +1015,6 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
MYTYPE& operator=(PCWSTR pW)
|
|
||||||
{
|
|
||||||
ssasn(*this, pW);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef SS_ALLOW_UNSIGNED_CHARS
|
#ifdef SS_ALLOW_UNSIGNED_CHARS
|
||||||
MYTYPE& operator=(PCUSTR pU)
|
MYTYPE& operator=(PCUSTR pU)
|
||||||
{
|
{
|
||||||
@@ -1262,12 +1160,6 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
MYTYPE& operator+=(PCWSTR pW)
|
|
||||||
{
|
|
||||||
ssadd(*this, pW);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
MYTYPE& operator+=(CT t)
|
MYTYPE& operator+=(CT t)
|
||||||
{
|
{
|
||||||
this->append(1, 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& str1, const MYTYPE& str2);
|
||||||
friend MYTYPE operator+ EMP_TEMP(const MYTYPE& str, CT t);
|
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, 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(PCSTR pA, const MYTYPE& str);
|
||||||
friend MYTYPE operator+ EMP_TEMP(PCWSTR pW, const MYTYPE& str);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Case changing functions
|
// Case changing functions
|
||||||
@@ -1793,22 +1683,6 @@ CStdStr<CT> operator+(PCSTR pA, const CStdStr<CT>& str)
|
|||||||
return strRet;
|
return strRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename CT>
|
|
||||||
inline
|
|
||||||
CStdStr<CT> operator+(const CStdStr<CT>& str, PCWSTR pW)
|
|
||||||
{
|
|
||||||
return CStdStr<CT>(str) + CStdStr<CT>(pW);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename CT>
|
|
||||||
inline
|
|
||||||
CStdStr<CT> operator+(PCWSTR pW, const CStdStr<CT>& str)
|
|
||||||
{
|
|
||||||
CStdStr<CT> strRet(pW);
|
|
||||||
strRet.append(str);
|
|
||||||
return strRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1841,20 +1715,6 @@ CStdStr<wchar_t> operator+(const CStdStr<wchar_t>& str, wchar_t t)
|
|||||||
return strRet;
|
return strRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
CStdStr<wchar_t> operator+(const CStdStr<wchar_t>& str, PCWSTR pW)
|
|
||||||
{
|
|
||||||
return CStdStr<wchar_t>(str) + CStdStr<wchar_t>(pW);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
CStdStr<wchar_t> operator+(PCWSTR pA, const CStdStr<wchar_t>& str)
|
|
||||||
{
|
|
||||||
CStdStr<wchar_t> strRet(pA);
|
|
||||||
strRet.append(str);
|
|
||||||
return strRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
CStdStr<wchar_t> operator+(const CStdStr<wchar_t>& str, PCSTR pW)
|
CStdStr<wchar_t> operator+(const CStdStr<wchar_t>& str, PCSTR pW)
|
||||||
{
|
{
|
||||||
@@ -1902,21 +1762,6 @@ CStdStr<char> operator+(PCSTR pA, const CStdStr<char>& str)
|
|||||||
return strRet;
|
return strRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
CStdStr<char> operator+(const CStdStr<char>& str, PCWSTR pW)
|
|
||||||
{
|
|
||||||
return CStdStr<char>(str) + CStdStr<char>(pW);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
CStdStr<char> operator+(PCWSTR pW, const CStdStr<char>& str)
|
|
||||||
{
|
|
||||||
CStdStr<char> strRet(pW);
|
|
||||||
strRet.append(str);
|
|
||||||
return strRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // defined(__SUNPRO_CC_COMPAT) || defined(__SUNPRO_CC)
|
#endif // defined(__SUNPRO_CC_COMPAT) || defined(__SUNPRO_CC)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user