TString<T>& TString<T>::DiffCat(const T *pStart, const T *pEnd) { _ASSERT(pBuf && pStart && pEnd); int StrLen = pEnd - pStart; SetAllocSize(nBufSize + StrLen); My_strncpy(GetBuffer() + GetLen(), pStart, StrLen); ReleaseBuffer(nBufSize + StrLen - 1); return *this; }
TString<T>& TString<T>::Cat(const T *pStr) { _ASSERT(pBuf && pStr); int StrLen = My_lstrlen(pStr); SetAllocSize(nBufSize + StrLen); My_lstrcpy(GetBuffer() + GetLen(), pStr); ReleaseBuffer(nBufSize + StrLen - 1); return *this; }
int Append (const T & el) { if (size == allocsize) { SetAllocSize (2*allocsize+1); } ((T*)data)[size] = el; size++; return size; }
TString<T>& TString<T>::Cat(const T c) { _ASSERT(pBuf); SetAllocSize(nBufSize + 1); int CurLen = GetLen(); T *p = GetBuffer(); p[CurLen] = c; p[CurLen + 1] = '\0'; ReleaseBuffer(nBufSize); return *this; }
void TString<T>::SetBufSize(int nNewBufSize) { _ASSERT(nNewBufSize >= 0); if (nNewBufSize < nBufSize) { _ASSERT(pBuf); pBuf[nNewBufSize - 1] = 0; } if ((unsigned)(nAllocSize - nNewBufSize) / STR_GROWBY) { SetAllocSize((nNewBufSize + STR_GROWBY - 1) - (nNewBufSize + STR_GROWBY - 1) % STR_GROWBY); } nBufSize = nNewBufSize; }
void TString<T>::Empty() { nBufSize = 1; SetAllocSize(STR_GROWBY); pBuf[0] = 0; }