Decouple <cstddef>

This commit is contained in:
Martin Natano
2023-04-20 11:21:29 +02:00
parent 093675cdc3
commit 78fb2e9fc3
171 changed files with 2012 additions and 1786 deletions
+37 -36
View File
@@ -97,17 +97,18 @@ typedef char* PSTR;
#include <malloc.h> // _alloca
#endif
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
/* In RageUtil: */
void MakeUpper( char *p, size_t iLen );
void MakeLower( char *p, size_t iLen );
void MakeUpper( wchar_t *p, size_t iLen );
void MakeLower( wchar_t *p, size_t iLen );
void MakeUpper( char *p, std::size_t iLen );
void MakeLower( char *p, std::size_t iLen );
void MakeUpper( wchar_t *p, std::size_t iLen );
void MakeLower( wchar_t *p, std::size_t iLen );
/**
* @brief Inline functions on which CStdString relies on.
@@ -121,13 +122,13 @@ void MakeLower( wchar_t *p, size_t iLen );
* Therefore, to keep the CStdStr declaration simple, we have these inline
* functions. The template calls them often. Since they are inline (and NOT
* exported when this is built as a DLL), they will probably be resolved away
* to nothing.
* to nothing.
*
* Without these functions, the CStdStr<> template would probably have to broken
* out into two, almost identical classes. Either that or it would be a huge,
* convoluted mess, with tons of "if" statements all over the place checking the
* size of template parameter CT.
*
*
* In several cases, you will see two versions of each function. One version is
* the more portable, standard way of doing things, while the other is the
* non-standard, but often significantly faster Visual C++ way.
@@ -159,7 +160,7 @@ inline char sstolower(char ch) { return (ch >= 'A' && ch <= 'Z')? char(ch + 'a'
// ssasn: assignment functions -- assign "sSrc" to "sDst"
// -----------------------------------------------------------------------------
typedef std::string::size_type SS_SIZETYPE; // just for shorthand, really
typedef std::string::pointer SS_PTRTYPE;
typedef std::string::pointer SS_PTRTYPE;
/**
* @brief Assign one string to another.
@@ -219,7 +220,7 @@ inline void ssadd(std::string& sDst, PCSTR pA)
}
else
{
sDst.append(pA);
sDst.append(pA);
}
}
@@ -238,7 +239,7 @@ inline int ssicmp(const CT* pA1, const CT* pA2)
CT f;
CT l;
do
do
{
f = sstolower(*(pA1++));
l = sstolower(*(pA2++));
@@ -252,32 +253,32 @@ inline int ssicmp(const CT* pA1, const CT* pA2)
// -----------------------------------------------------------------------------
#if 0
template<typename CT>
inline void sslwr(CT* pT, size_t nLen)
inline void sslwr(CT* pT, std::size_t nLen)
{
for ( CT* p = pT; static_cast<size_t>(p - pT) < nLen; ++p)
for ( CT* p = pT; static_cast<std::size_t>(p - pT) < nLen; ++p)
*p = (CT)sstolower(*p);
}
template<typename CT>
inline void ssupr(CT* pT, size_t nLen)
inline void ssupr(CT* pT, std::size_t nLen)
{
for ( CT* p = pT; static_cast<size_t>(p - pT) < nLen; ++p)
for ( CT* p = pT; static_cast<std::size_t>(p - pT) < nLen; ++p)
*p = (CT)sstoupper(*p);
}
#endif
inline void sslwr(char *pT, size_t nLen)
inline void sslwr(char *pT, std::size_t nLen)
{
MakeLower( pT, nLen );
}
inline void ssupr(char *pT, size_t nLen)
inline void ssupr(char *pT, std::size_t nLen)
{
MakeUpper( pT, nLen );
}
inline void sslwr(wchar_t *pT, size_t nLen)
inline void sslwr(wchar_t *pT, std::size_t nLen)
{
MakeLower( pT, nLen );
}
inline void ssupr(wchar_t *pT, size_t nLen)
inline void ssupr(wchar_t *pT, std::size_t nLen)
{
MakeUpper( pT, nLen );
}
@@ -299,7 +300,7 @@ inline void ssupr(wchar_t *pT, size_t nLen)
// easy to use as the MFC RString class.
//
// Note that although this is a template, it makes the assumption that the
// template argument (CT, the character type) is either char or wchar_t.
// template argument (CT, the character type) is either char or wchar_t.
// =============================================================================
//#define CStdStr _SS // avoid compiler warning 4786
@@ -325,8 +326,8 @@ CStdStr<CT> operator+(const CStdStr<CT>& str1, const CStdStr<CT>& str2)
* @param str the original string.
* @param t the string to be added.
* @return the longer string.
*/
template<typename CT>
*/
template<typename CT>
inline
CStdStr<CT> operator+(const CStdStr<CT>& str, CT t)
{
@@ -354,7 +355,7 @@ CStdStr<CT> operator+(const CStdStr<CT>& str, PCSTR pA)
* @param pA the original string.
* @param str the string to be added.
* @return the longer string.
*/
*/
template<typename CT>
inline
CStdStr<CT> operator+(PCSTR pA, const CStdStr<CT>& str)
@@ -374,16 +375,16 @@ class CStdStr : public std::basic_string<CT>
typedef typename std::basic_string<CT> MYBASE; // my base class
typedef CStdStr<CT> MYTYPE; // myself
typedef typename MYBASE::const_pointer PCMYSTR; // PCSTR
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...
typedef typename MYBASE::reverse_iterator MYRITER;
typedef typename MYBASE::size_type MYSIZE;
typedef typename MYBASE::value_type MYVAL;
typedef typename MYBASE::size_type MYSIZE;
typedef typename MYBASE::value_type MYVAL;
typedef typename MYBASE::allocator_type MYALLOC;
typedef typename MYBASE::traits_type MYTRAITS;
public:
// CStdStr inline constructors
@@ -420,8 +421,8 @@ public:
// CStdStr inline assignment operators
MYTYPE& operator=(const MYTYPE& str)
{
ssasn(*this, str);
{
ssasn(*this, str);
return *this;
}
@@ -455,7 +456,7 @@ public:
MYTYPE& operator+=(const std::string& str)
{
ssadd(*this, str);
return *this;
return *this;
}
MYTYPE& operator+=(PCSTR pA)
@@ -516,7 +517,7 @@ public:
this->resize(static_cast<MYSIZE>(nNewLen > -1 ? nNewLen : MYTRAITS::length(this->c_str())));
}
// -------------------------------------------------------------------------
// RString Facade Functions:
@@ -539,7 +540,7 @@ public:
// Range check the count.
nCount = std::max(0, std::min(nCount, static_cast<int>(this->size())));
return this->substr(0, static_cast<MYSIZE>(nCount));
return this->substr(0, static_cast<MYSIZE>(nCount));
}
int Replace(CT chOld, CT chNew)
@@ -610,15 +611,15 @@ public:
CT& operator[](long unsigned int nIdx){
return MYBASE::operator[](static_cast<MYSIZE>(nIdx));
}
const CT& operator[](long unsigned int nIdx) const {
return MYBASE::operator[](static_cast<MYSIZE>(nIdx));
}
CT& operator[](long long unsigned int nIdx){
return MYBASE::operator[](static_cast<MYSIZE>(nIdx));
}
const CT& operator[](long long unsigned int nIdx) const {
return MYBASE::operator[](static_cast<MYSIZE>(nIdx));
}
@@ -667,7 +668,7 @@ struct StdStringEqualsNoCase
{ return ssicmp(sLeft.c_str(), sRight.c_str()) == 0; }
};
// These std::swap specializations come courtesy of Mike Crusader.
// These std::swap specializations come courtesy of Mike Crusader.
//namespace std
//{