SNAP Library 2.0, Developer Reference
2013-05-13 16:33:57
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <dt.h>
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 |
TMem & | operator= (const TMem &Mem) |
char * | operator() () const |
TMem & | operator+= (const char &Ch) |
TMem & | operator+= (const TMem &Mem) |
TMem & | operator+= (const TStr &Str) |
TMem & | operator+= (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 > |
TMem::TMem | ( | const int & | _MxBfL = 0 | ) | [inline] |
TMem::TMem | ( | const void * | _Bf, |
const int & | _BfL | ||
) | [inline] |
TMem::TMem | ( | const TMem & | Mem | ) | [inline] |
TMem::TMem | ( | const TStr & | Str | ) |
TMem::~TMem | ( | ) | [inline] |
TMem::TMem | ( | TSIn & | SIn | ) | [inline, explicit] |
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); //} }
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().
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); }
bool TMem::DoFitLen | ( | const int & | LBfL | ) | const [inline, private] |
Definition at line 82 of file dt.h.
Referenced by DoFitStr().
bool TMem::DoFitStr | ( | const TStr & | Str | ) | const |
Definition at line 247 of file dt.cpp.
References DoFitLen(), and TStr::Len().
bool TMem::Empty | ( | ) | const [inline] |
Definition at line 135 of file dt.h.
Referenced by THttpRq::GetStr().
{return BfL==0;}
void TMem::Gen | ( | const int & | _BfL | ) | [inline] |
void TMem::GenZeros | ( | const int & | _BfL | ) | [inline] |
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); } }
char* TMem::GetBf | ( | ) | const [inline] |
Definition at line 144 of file dt.h.
Referenced by TChA::operator+=().
{return Bf;}
int TMem::GetMemUsed | ( | ) | const [inline] |
PSIn TMem::GetSIn | ( | ) | const [inline] |
Definition at line 146 of file dt.h.
References TMOut::GetSIn(), and TSOut::SaveBf().
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;}
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().
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().
void TMem::LoadXml | ( | const PXmlTok & | XmlTok, |
const TStr & | Nm | ||
) |
TMem & TMem::operator+= | ( | const char & | Ch | ) |
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; }
char& TMem::operator[] | ( | const int & | ChN | ) | const [inline] |
char TMem::Pop | ( | ) | [inline] |
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] |
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; }
void TMem::Save | ( | TSOut & | SOut | ) | const [inline] |
void TMem::SaveMem | ( | const PSOut & | SOut | ) | const [inline] |
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.
{ XSaveHdArg(Nm, "BfL", TInt::GetStr(BfL)); SOut.PutStr(TXmlLx::GetXmlStrFromPlainMem(*this)); }
void TMem::Trunc | ( | const int & | _BfL | ) | [inline] |
Definition at line 136 of file dt.h.
Referenced by THttpRq::ParseHttpRq().
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] |
int TMem::MxBfL [private] |
Definition at line 79 of file dt.h.
Referenced by operator+=(), operator=(), Resize(), and TMem().