Beispiel #1
0
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;
}
Beispiel #2
0
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;
}
Beispiel #3
0
  int Append (const T & el)
  {
    if (size == allocsize) 
      {
	SetAllocSize (2*allocsize+1);
      }
    ((T*)data)[size] = el;
    size++;
    return size;
  }
Beispiel #4
0
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;
}
Beispiel #5
0
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;
}
Beispiel #6
0
void TString<T>::Empty()
{
    nBufSize = 1;
    SetAllocSize(STR_GROWBY);
    pBuf[0] = 0;
}