GetBuf -> GetBuffer, RelBuf -> ReleaseBuffer, cleanup

This commit is contained in:
Glenn Maynard
2006-09-18 21:48:23 +00:00
parent 8310c83f1a
commit bca66d4e27
+4 -41
View File
@@ -605,39 +605,18 @@ public:
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Case changing functions // Case changing functions
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// -------------------------------------------------------------------------
MYTYPE& MakeUpper() MYTYPE& MakeUpper()
{ {
// Strictly speaking, this would be about the most portable way
// std::transform(begin(),
// end(),
// begin(),
// std::bind2nd(SSToUpper<CT>(), std::locale()));
// But practically speaking, this works faster
if ( !this->empty() ) if ( !this->empty() )
ssupr(GetBuf(), this->size()); ssupr(GetBuffer(), this->size());
return *this; return *this;
} }
MYTYPE& MakeLower() MYTYPE& MakeLower()
{ {
// Strictly speaking, this would be about the most portable way
// std::transform(begin(),
// end(),
// begin(),
// std::bind2nd(SSToLower<CT>(), std::locale()));
// But practically speaking, this works faster
if ( !this->empty() ) if ( !this->empty() )
sslwr(GetBuf(), this->size()); sslwr(GetBuffer(), this->size());
return *this; return *this;
} }
@@ -649,7 +628,7 @@ public:
// the at() function that we use here also calls _Freeze() providing us some // the at() function that we use here also calls _Freeze() providing us some
// protection from multithreading problems associated with ref-counting. // protection from multithreading problems associated with ref-counting.
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
CT* GetBuf(int nMinLen=-1) CT* GetBuffer(int nMinLen=-1)
{ {
if ( static_cast<int>(this->size()) < nMinLen ) if ( static_cast<int>(this->size()) < nMinLen )
this->resize(static_cast<MYSIZE>(nMinLen)); this->resize(static_cast<MYSIZE>(nMinLen));
@@ -657,16 +636,13 @@ public:
return this->empty() ? const_cast<CT*>(this->data()) : &(this->at(0)); return this->empty() ? const_cast<CT*>(this->data()) : &(this->at(0));
} }
void RelBuf(int nNewLen=-1) void ReleaseBuffer(int nNewLen=-1)
{ {
this->resize(static_cast<MYSIZE>(nNewLen > -1 ? nNewLen : sslen(this->c_str()))); this->resize(static_cast<MYSIZE>(nNewLen > -1 ? nNewLen : sslen(this->c_str())));
} }
#define MAX_FMT_TRIES 5 // #of times we try #define MAX_FMT_TRIES 5 // #of times we try
#define FMT_BLOCK_SIZE 2048 // # of bytes to increment per try #define FMT_BLOCK_SIZE 2048 // # of bytes to increment per try
#define BUFSIZE_1ST 256
#define BUFSIZE_2ND 512
#define STD_BUF_SIZE 1024
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// FUNCTION: FormatV // FUNCTION: FormatV
@@ -777,14 +753,6 @@ public:
return CompareNoCase(szThat) == 0; return CompareNoCase(szThat) == 0;
} }
// -------------------------------------------------------------------------
// GetXXXX -- Direct access to character buffer
// -------------------------------------------------------------------------
CT* GetBuffer(int nMinLen=-1)
{
return GetBuf(nMinLen);
}
MYTYPE Left(int nCount) const MYTYPE Left(int nCount) const
{ {
// Range check the count. // Range check the count.
@@ -793,11 +761,6 @@ public:
return this->substr(0, static_cast<MYSIZE>(nCount)); return this->substr(0, static_cast<MYSIZE>(nCount));
} }
void ReleaseBuffer(int nNewLen=-1)
{
RelBuf(nNewLen);
}
int Replace(CT chOld, CT chNew) int Replace(CT chOld, CT chNew)
{ {
int nReplaced = 0; int nReplaced = 0;