SNAP Library 2.2, Developer Reference  2014-03-11 19:15:55
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TMem Class Reference

#include <dt.h>

Collaboration diagram for TMem:

List of all members.

Public Member Functions

 TMem (const int &_MxBfL=0)
 TMem (const void *_Bf, const int &_BfL)
 TMem (const TMem &Mem)
 TMem (const TStr &Str)
 ~TMem ()
 TMem (TSIn &SIn)
void Save (TSOut &SOut) const
void LoadXml (const PXmlTok &XmlTok, const TStr &Nm)
void SaveXml (TSOut &SOut, const TStr &Nm) const
TMemoperator= (const TMem &Mem)
char * operator() () const
TMemoperator+= (const char &Ch)
TMemoperator+= (const TMem &Mem)
TMemoperator+= (const TStr &Str)
TMemoperator+= (const PSIn &SIn)
char & operator[] (const int &ChN) const
int GetMemUsed () const
void Gen (const int &_BfL)
void GenZeros (const int &_BfL)
void Reserve (const int &_MxBfL, const bool &DoClr=true)
void Del (const int &BChN, const int &EChN)
void Clr (const bool &DoDel=true)
int Len () const
bool Empty () const
void Trunc (const int &_BfL)
void Push (const char &Ch)
char Pop ()
bool DoFitStr (const TStr &Str) const
void AddBf (const void *Bf, const int &BfL)
char * GetBf () const
TStr GetAsStr (const char &NewNullCh='\0') const
PSIn GetSIn () const
void SaveMem (const PSOut &SOut) const

Static Public Member Functions

static PMem New (const int &MxBfL=0)
static PMem New (const void *Bf, const int &BfL)
static PMem New (const TMem &Mem)
static PMem New (const PMem &Mem)
static PMem New (const TStr &Str)
static void LoadMem (const PSIn &SIn, TMem &Mem)
static void LoadMem (const PSIn &SIn, const PMem &Mem)

Private Member Functions

void Resize (const int &_MxBfL)
bool DoFitLen (const int &LBfL) const

Private Attributes

TCRef CRef
int MxBfL
int BfL
char * Bf

Friends

class TPt< TMem >

Detailed Description

Definition at line 77 of file dt.h.


Constructor & Destructor Documentation

TMem::TMem ( const int &  _MxBfL = 0) [inline]

Definition at line 84 of file dt.h.

References IAssert.

                           :
    MxBfL(_MxBfL), BfL(0), Bf(NULL){ IAssert(BfL>=0);
    if (MxBfL>0){Bf=new char[MxBfL]; IAssert(Bf!=NULL);}}
TMem::TMem ( const void *  _Bf,
const int &  _BfL 
) [inline]

Definition at line 88 of file dt.h.

References IAssert.

                                        :
    MxBfL(_BfL), BfL(_BfL), Bf(NULL){ IAssert(BfL>=0);
    if (BfL>0){Bf=new char[BfL]; IAssert(Bf!=NULL); memcpy(Bf, _Bf, BfL);}}
TMem::TMem ( const TMem Mem) [inline]

Definition at line 92 of file dt.h.

References Bf.

                       :
    MxBfL(Mem.MxBfL), BfL(Mem.BfL), Bf(NULL){
    if (MxBfL>0){Bf=new char[MxBfL]; memcpy(Bf, Mem.Bf, BfL);}}
TMem::TMem ( const TStr Str)

Definition at line 234 of file dt.cpp.

References Bf, BfL, TStr::CStr(), and MxBfL.

                         :
  MxBfL(Str.Len()), BfL(MxBfL), Bf(NULL){
  if (MxBfL>0){
    Bf=new char[MxBfL];
    if (BfL>0){memcpy(Bf, Str.CStr(), BfL);}
  }
}

Here is the call graph for this function:

TMem::~TMem ( ) [inline]

Definition at line 99 of file dt.h.

{if (Bf!=NULL){delete[] Bf;}}
TMem::TMem ( TSIn SIn) [inline, explicit]

Definition at line 100 of file dt.h.

References TSIn::Load(), and TSIn::LoadBf().

                          {
    SIn.Load(MxBfL); SIn.Load(BfL);
    Bf=new char[MxBfL=BfL]; SIn.LoadBf(Bf, BfL);}

Here is the call graph for this function:


Member Function Documentation

void TMem::AddBf ( const void *  Bf,
const int &  BfL 
)

Definition at line 291 of file dt.cpp.

References Bf, BfL, IAssert, Len(), and Reserve().

                                                {
        IAssert((_BfL>=0) && (_Bf != NULL));
  Reserve(Len() + _BfL, false);
  memcpy(Bf + BfL, _Bf, _BfL);  
   BfL+=_BfL;
  //char* ChBf=(char*)Bf;
  //for (int BfC=0; BfC<BfL; BfC++){
  //  char Ch=ChBf[BfC];
  //  operator+=(Ch);
  //}
}

Here is the call graph for this function:

void TMem::Clr ( const bool &  DoDel = true) [inline]

Definition at line 131 of file dt.h.

Referenced by THttpLx::ClrMemSf(), Del(), THttpRq::GetAsMem(), THttpResp::GetAsMem(), THttpRq::GetBodyAsMem(), LoadMem(), and THttpResp::ParseHttpResp().

                                  {
    if (DoDel){if (Bf!=NULL){delete[] Bf;} MxBfL=0; BfL=0; Bf=NULL;}
    else {BfL=0;}}

Here is the caller graph for this function:

void TMem::Del ( const int &  BChN,
const int &  EChN 
)

Definition at line 277 of file dt.cpp.

References Bf, BfL, Clr(), and IAssert.

                                              {
  if (BChN>EChN){return;}
  if ((BChN==0)&&(EChN==BfL-1)){Clr(); return;}
  IAssert((0<=BChN)&&(BChN<=EChN)&&(EChN<BfL));
  memmove(Bf+BChN, Bf+EChN+1, BfL-EChN-1);
  BfL-=(EChN-BChN+1);
}

Here is the call graph for this function:

bool TMem::DoFitLen ( const int &  LBfL) const [inline, private]

Definition at line 82 of file dt.h.

Referenced by DoFitStr().

{return BfL+LBfL<=MxBfL;}

Here is the caller graph for this function:

bool TMem::DoFitStr ( const TStr Str) const

Definition at line 247 of file dt.cpp.

References DoFitLen(), and TStr::Len().

                                         {
  return DoFitLen(Str.Len()+1);
}

Here is the call graph for this function:

bool TMem::Empty ( ) const [inline]

Definition at line 135 of file dt.h.

Referenced by THttpRq::GetStr().

{return BfL==0;}

Here is the caller graph for this function:

void TMem::Gen ( const int &  _BfL) [inline]

Definition at line 123 of file dt.h.

Referenced by TMd5::GetSigMem(), and LoadMem().

                           {
    Clr(); Resize(_BfL); BfL=_BfL;}

Here is the caller graph for this function:

void TMem::GenZeros ( const int &  _BfL) [inline]

Definition at line 125 of file dt.h.

                                {
    Clr(false); Resize(_BfL); BfL=_BfL;
    if (BfL > 0) memset(Bf, 0, BfL);}
TStr TMem::GetAsStr ( const char &  NewNullCh = '\0') const

Definition at line 303 of file dt.cpp.

References TChA::ChangeCh().

Referenced by THttpRq::GetStr(), THttpResp::ParseHttpResp(), and THttpRq::ParseHttpRq().

                                               {
  if (NewNullCh!='\0'){
    TChA ChA(*this);
    ChA.ChangeCh('\0', NewNullCh);
    return ChA;
  } else {
    return TStr(*this);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* TMem::GetBf ( ) const [inline]

Definition at line 144 of file dt.h.

Referenced by TChA::operator+=().

{return Bf;}

Here is the caller graph for this function:

int TMem::GetMemUsed ( ) const [inline]

Definition at line 121 of file dt.h.

{return int(2*sizeof(int)+sizeof(char*)+MxBfL);}
PSIn TMem::GetSIn ( ) const [inline]

Definition at line 146 of file dt.h.

References TMOut::GetSIn(), and TSOut::SaveBf().

                      {
    TMOut MOut(BfL); MOut.SaveBf(Bf, BfL); return MOut.GetSIn();}

Here is the call graph for this function:

int TMem::Len ( ) const [inline]

Definition at line 134 of file dt.h.

Referenced by AddBf(), THttpResp::GetSIn(), THttpRq::GetStr(), TXmlLx::GetXmlStrFromPlainMem(), operator+=(), TChA::operator+=(), THttpRq::ParseHttpRq(), TSOut::PutMem(), TChA::TChA(), and TStr::TStr().

{return BfL;}

Here is the caller graph for this function:

static void TMem::LoadMem ( const PSIn SIn,
TMem Mem 
) [inline, static]

Definition at line 149 of file dt.h.

References Bf, Clr(), Gen(), TSIn::GetBf(), and TSIn::Len().

Referenced by THttpLx::GetRest(), and THttpResp::THttpResp().

                                                 {
    Mem.Clr(); Mem.Gen(SIn->Len()); SIn->GetBf(Mem.Bf, SIn->Len());}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TMem::LoadMem ( const PSIn SIn,
const PMem Mem 
) [inline, static]

Definition at line 151 of file dt.h.

References Bf, Clr(), Gen(), TSIn::GetBf(), and TSIn::Len().

                                                       {
    Mem->Clr(); Mem->Gen(SIn->Len()); SIn->GetBf(Mem->Bf, SIn->Len());}

Here is the call graph for this function:

void TMem::LoadXml ( const PXmlTok XmlTok,
const TStr Nm 
)
static PMem TMem::New ( const int &  MxBfL = 0) [inline, static]

Definition at line 87 of file dt.h.

{return new TMem(MxBfL);}
static PMem TMem::New ( const void *  Bf,
const int &  BfL 
) [inline, static]

Definition at line 91 of file dt.h.

{return new TMem(Bf, BfL);}
static PMem TMem::New ( const TMem Mem) [inline, static]

Definition at line 95 of file dt.h.

{return new TMem(Mem);}
static PMem TMem::New ( const PMem Mem) [inline, static]

Definition at line 96 of file dt.h.

{return new TMem(*Mem);}
static PMem TMem::New ( const TStr Str) [inline, static]

Definition at line 98 of file dt.h.

{return new TMem(Str);}
char* TMem::operator() ( ) const [inline]

Definition at line 114 of file dt.h.

{return Bf;}
TMem & TMem::operator+= ( const char &  Ch)

Definition at line 251 of file dt.cpp.

References Bf, BfL, MxBfL, and Resize().

                                    {
  if (BfL==MxBfL){Resize(BfL+1);}
  Bf[BfL]=Ch; BfL++; return *this;
}

Here is the call graph for this function:

TMem & TMem::operator+= ( const TMem Mem)

Definition at line 256 of file dt.cpp.

References Bf, BfL, Len(), MxBfL, and Resize().

                                     {
  int LBfL=Mem.Len(); if (BfL+LBfL>MxBfL){Resize(BfL+LBfL);}
  if (LBfL>0){memcpy(&Bf[BfL], Mem(), LBfL);}
  BfL+=LBfL; return *this;
}

Here is the call graph for this function:

TMem & TMem::operator+= ( const TStr Str)

Definition at line 262 of file dt.cpp.

References Bf, BfL, TStr::CStr(), TStr::Len(), MxBfL, and Resize().

                                     {
  int LBfL=Str.Len(); if (BfL+LBfL>MxBfL){Resize(BfL+LBfL);}
  if (LBfL>0){memcpy(Bf+BfL, Str.CStr(), LBfL);}
  BfL+=LBfL; return *this;
}

Here is the call graph for this function:

TMem & TMem::operator+= ( const PSIn SIn)

Definition at line 268 of file dt.cpp.

References Bf, BfL, TSIn::GetBf(), TSIn::Len(), MxBfL, and Resize().

                                     {
  int LBfL=SIn->Len(); if (BfL+LBfL>MxBfL){Resize(BfL+LBfL);}
  char* LBf=new char[LBfL];
  SIn->GetBf(LBf, LBfL);
  if (LBfL>0){memcpy(Bf+BfL, LBf, LBfL);}
  delete[] LBf;
  BfL+=LBfL; return *this;
}

Here is the call graph for this function:

TMem& TMem::operator= ( const TMem Mem) [inline]

Definition at line 108 of file dt.h.

References Bf, BfL, and MxBfL.

                                  {
    if (this!=&Mem){
      if (Bf!=NULL){delete[] Bf;}
      MxBfL=Mem.MxBfL; BfL=Mem.BfL; Bf=NULL;
      if (MxBfL>0){Bf=new char[MxBfL]; memcpy(Bf, Mem.Bf, BfL);}}
    return *this;}
char& TMem::operator[] ( const int &  ChN) const [inline]

Definition at line 119 of file dt.h.

References Assert.

                                         {
    Assert((0<=ChN)&&(ChN<BfL)); return Bf[ChN];}
char TMem::Pop ( ) [inline]

Definition at line 139 of file dt.h.

References IAssert.

Referenced by THttpLx::PutCh().

{IAssert(BfL>0); BfL--; return Bf[BfL];}

Here is the caller graph for this function:

void TMem::Push ( const char &  Ch) [inline]

Definition at line 138 of file dt.h.

{operator+=(Ch);}
void TMem::Reserve ( const int &  _MxBfL,
const bool &  DoClr = true 
) [inline]

Definition at line 128 of file dt.h.

Referenced by AddBf().

                                                           {
    if (DoClr){ Clr(); } Resize(_MxBfL);}

Here is the caller graph for this function:

void TMem::Resize ( const int &  _MxBfL) [private]

Definition at line 225 of file dt.cpp.

References Bf, BfL, IAssert, and MxBfL.

Referenced by operator+=().

                                  {
  if (_MxBfL<=MxBfL){return;}
  else {if (MxBfL*2<_MxBfL){MxBfL=_MxBfL;} else {MxBfL*=2;}}
  char* NewBf=new char[MxBfL]; IAssert(NewBf!=NULL);
  if (BfL>0){memcpy(NewBf, Bf, BfL);}
  if (Bf!=NULL){delete[] Bf;}
  Bf=NewBf;
}

Here is the caller graph for this function:

void TMem::Save ( TSOut SOut) const [inline]

Definition at line 103 of file dt.h.

References TSOut::Save(), and TSOut::SaveBf().

                               {
    SOut.Save(MxBfL); SOut.Save(BfL); SOut.SaveBf(Bf, BfL);}

Here is the call graph for this function:

void TMem::SaveMem ( const PSOut SOut) const [inline]

Definition at line 153 of file dt.h.

References TSOut::SaveBf().

{SOut->SaveBf(Bf, Len());}

Here is the call graph for this function:

void TMem::SaveXml ( TSOut SOut,
const TStr Nm 
) const

Definition at line 242 of file dt.cpp.

References BfL, TInt::GetStr(), TXmlLx::GetXmlStrFromPlainMem(), TSOut::PutStr(), and XSaveHdArg.

Here is the call graph for this function:

void TMem::Trunc ( const int &  _BfL) [inline]

Definition at line 136 of file dt.h.

Referenced by THttpRq::ParseHttpRq().

                             {
    if ((0<=_BfL)&&(_BfL<=BfL)){BfL=_BfL;}}

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class TPt< TMem > [friend]

Definition at line 77 of file dt.h.


Member Data Documentation

char* TMem::Bf [private]

Definition at line 80 of file dt.h.

Referenced by AddBf(), Del(), LoadMem(), operator+=(), operator=(), Resize(), and TMem().

int TMem::BfL [private]

Definition at line 79 of file dt.h.

Referenced by AddBf(), Del(), operator+=(), operator=(), Resize(), SaveXml(), and TMem().

TCRef TMem::CRef [private]

Definition at line 77 of file dt.h.

int TMem::MxBfL [private]

Definition at line 79 of file dt.h.

Referenced by operator+=(), operator=(), Resize(), and TMem().


The documentation for this class was generated from the following files: