SNAP Library 2.4, User Reference  2015-05-11 19:40:56
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TMem Class Reference

#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
 
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.

84  :
85  MxBfL(_MxBfL), BfL(0), Bf(NULL){ IAssert(BfL>=0);
86  if (MxBfL>0){Bf=new char[MxBfL]; IAssert(Bf!=NULL);}}
#define IAssert(Cond)
Definition: bd.h:262
char * Bf
Definition: dt.h:80
int BfL
Definition: dt.h:79
int MxBfL
Definition: dt.h:79
TMem::TMem ( const void *  _Bf,
const int &  _BfL 
)
inline

Definition at line 88 of file dt.h.

88  :
89  MxBfL(_BfL), BfL(_BfL), Bf(NULL){ IAssert(BfL>=0);
90  if (BfL>0){Bf=new char[BfL]; IAssert(Bf!=NULL); memcpy(Bf, _Bf, BfL);}}
#define IAssert(Cond)
Definition: bd.h:262
char * Bf
Definition: dt.h:80
int BfL
Definition: dt.h:79
int MxBfL
Definition: dt.h:79
TMem::TMem ( const TMem Mem)
inline

Definition at line 92 of file dt.h.

92  :
93  MxBfL(Mem.MxBfL), BfL(Mem.BfL), Bf(NULL){
94  if (MxBfL>0){Bf=new char[MxBfL]; memcpy(Bf, Mem.Bf, BfL);}}
char * Bf
Definition: dt.h:80
int BfL
Definition: dt.h:79
int MxBfL
Definition: dt.h:79
TMem::TMem ( const TStr Str)

Definition at line 234 of file dt.cpp.

234  :
235  MxBfL(Str.Len()), BfL(MxBfL), Bf(NULL){
236  if (MxBfL>0){
237  Bf=new char[MxBfL];
238  if (BfL>0){memcpy(Bf, Str.CStr(), BfL);}
239  }
240 }
int Len() const
Definition: dt.h:487
char * Bf
Definition: dt.h:80
int BfL
Definition: dt.h:79
int MxBfL
Definition: dt.h:79
char * CStr()
Definition: dt.h:476
TMem::~TMem ( )
inline

Definition at line 99 of file dt.h.

99 {if (Bf!=NULL){delete[] Bf;}}
char * Bf
Definition: dt.h:80
TMem::TMem ( TSIn SIn)
inlineexplicit

Definition at line 100 of file dt.h.

100  {
101  SIn.Load(MxBfL); SIn.Load(BfL);
102  Bf=new char[MxBfL=BfL]; SIn.LoadBf(Bf, BfL);}
char * Bf
Definition: dt.h:80
int BfL
Definition: dt.h:79
void Load(bool &Bool)
Definition: fl.h:84
void LoadBf(const void *Bf, const TSize &BfL)
Definition: fl.h:81
int MxBfL
Definition: dt.h:79

Member Function Documentation

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

Definition at line 291 of file dt.cpp.

291  {
292  IAssert((_BfL>=0) && (_Bf != NULL));
293  Reserve(Len() + _BfL, false);
294  memcpy(Bf + BfL, _Bf, _BfL);
295  BfL+=_BfL;
296  //char* ChBf=(char*)Bf;
297  //for (int BfC=0; BfC<BfL; BfC++){
298  // char Ch=ChBf[BfC];
299  // operator+=(Ch);
300  //}
301 }
#define IAssert(Cond)
Definition: bd.h:262
char * Bf
Definition: dt.h:80
int Len() const
Definition: dt.h:134
int BfL
Definition: dt.h:79
void Reserve(const int &_MxBfL, const bool &DoClr=true)
Definition: dt.h:128
void TMem::Clr ( const bool &  DoDel = true)
inline

Definition at line 131 of file dt.h.

131  {
132  if (DoDel){if (Bf!=NULL){delete[] Bf;} MxBfL=0; BfL=0; Bf=NULL;}
133  else {BfL=0;}}
char * Bf
Definition: dt.h:80
int BfL
Definition: dt.h:79
int MxBfL
Definition: dt.h:79
void TMem::Del ( const int &  BChN,
const int &  EChN 
)

Definition at line 277 of file dt.cpp.

277  {
278  if (BChN>EChN){return;}
279  if ((BChN==0)&&(EChN==BfL-1)){Clr(); return;}
280  IAssert((0<=BChN)&&(BChN<=EChN)&&(EChN<BfL));
281  memmove(Bf+BChN, Bf+EChN+1, BfL-EChN-1);
282  BfL-=(EChN-BChN+1);
283 }
#define IAssert(Cond)
Definition: bd.h:262
char * Bf
Definition: dt.h:80
int BfL
Definition: dt.h:79
void Clr(const bool &DoDel=true)
Definition: dt.h:131
bool TMem::DoFitLen ( const int &  LBfL) const
inlineprivate

Definition at line 82 of file dt.h.

82 {return BfL+LBfL<=MxBfL;}
int BfL
Definition: dt.h:79
int MxBfL
Definition: dt.h:79
bool TMem::DoFitStr ( const TStr Str) const

Definition at line 247 of file dt.cpp.

247  {
248  return DoFitLen(Str.Len()+1);
249 }
int Len() const
Definition: dt.h:487
bool DoFitLen(const int &LBfL) const
Definition: dt.h:82
bool TMem::Empty ( ) const
inline

Definition at line 135 of file dt.h.

135 {return BfL==0;}
int BfL
Definition: dt.h:79
void TMem::Gen ( const int &  _BfL)
inline

Definition at line 123 of file dt.h.

123  {
124  Clr(); Resize(_BfL); BfL=_BfL;}
int BfL
Definition: dt.h:79
void Resize(const int &_MxBfL)
Definition: dt.cpp:225
void Clr(const bool &DoDel=true)
Definition: dt.h:131
void TMem::GenZeros ( const int &  _BfL)
inline

Definition at line 125 of file dt.h.

125  {
126  Clr(false); Resize(_BfL); BfL=_BfL;
127  if (BfL > 0) memset(Bf, 0, BfL);}
char * Bf
Definition: dt.h:80
int BfL
Definition: dt.h:79
void Resize(const int &_MxBfL)
Definition: dt.cpp:225
void Clr(const bool &DoDel=true)
Definition: dt.h:131
TStr TMem::GetAsStr ( const char &  NewNullCh = '\0') const

Definition at line 303 of file dt.cpp.

303  {
304  if (NewNullCh!='\0'){
305  TChA ChA(*this);
306  ChA.ChangeCh('\0', NewNullCh);
307  return ChA;
308  } else {
309  return TStr(*this);
310  }
311 }
Definition: dt.h:201
Definition: dt.h:412
char* TMem::GetBf ( ) const
inline

Definition at line 144 of file dt.h.

144 {return Bf;}
char * Bf
Definition: dt.h:80
int TMem::GetMemUsed ( ) const
inline

Definition at line 121 of file dt.h.

121 {return int(2*sizeof(int)+sizeof(char*)+MxBfL);}
int MxBfL
Definition: dt.h:79
PSIn TMem::GetSIn ( ) const
inline

Definition at line 146 of file dt.h.

146  {
147  TMOut MOut(BfL); MOut.SaveBf(Bf, BfL); return MOut.GetSIn();}
char * Bf
Definition: dt.h:80
int BfL
Definition: dt.h:79
Definition: fl.h:417
int TMem::Len ( ) const
inline

Definition at line 134 of file dt.h.

134 {return BfL;}
int BfL
Definition: dt.h:79
static void TMem::LoadMem ( const PSIn SIn,
TMem Mem 
)
inlinestatic

Definition at line 149 of file dt.h.

149  {
150  Mem.Clr(); Mem.Gen(SIn->Len()); SIn->GetBf(Mem.Bf, SIn->Len());}
void Gen(const int &_BfL)
Definition: dt.h:123
char * Bf
Definition: dt.h:80
void Clr(const bool &DoDel=true)
Definition: dt.h:131
static void TMem::LoadMem ( const PSIn SIn,
const PMem Mem 
)
inlinestatic

Definition at line 151 of file dt.h.

151  {
152  Mem->Clr(); Mem->Gen(SIn->Len()); SIn->GetBf(Mem->Bf, SIn->Len());}
void Gen(const int &_BfL)
Definition: dt.h:123
char * Bf
Definition: dt.h:80
void Clr(const bool &DoDel=true)
Definition: dt.h:131
void TMem::LoadXml ( const PXmlTok XmlTok,
const TStr Nm 
)
static PMem TMem::New ( const int &  MxBfL = 0)
inlinestatic

Definition at line 87 of file dt.h.

87 {return new TMem(MxBfL);}
int MxBfL
Definition: dt.h:79
TMem(const int &_MxBfL=0)
Definition: dt.h:84
static PMem TMem::New ( const void *  Bf,
const int &  BfL 
)
inlinestatic

Definition at line 91 of file dt.h.

91 {return new TMem(Bf, BfL);}
char * Bf
Definition: dt.h:80
int BfL
Definition: dt.h:79
TMem(const int &_MxBfL=0)
Definition: dt.h:84
static PMem TMem::New ( const TMem Mem)
inlinestatic

Definition at line 95 of file dt.h.

95 {return new TMem(Mem);}
TMem(const int &_MxBfL=0)
Definition: dt.h:84
static PMem TMem::New ( const PMem Mem)
inlinestatic

Definition at line 96 of file dt.h.

96 {return new TMem(*Mem);}
TMem(const int &_MxBfL=0)
Definition: dt.h:84
static PMem TMem::New ( const TStr Str)
inlinestatic

Definition at line 98 of file dt.h.

98 {return new TMem(Str);}
TMem(const int &_MxBfL=0)
Definition: dt.h:84
char* TMem::operator() ( ) const
inline

Definition at line 114 of file dt.h.

114 {return Bf;}
char * Bf
Definition: dt.h:80
TMem & TMem::operator+= ( const char &  Ch)

Definition at line 251 of file dt.cpp.

251  {
252  if (BfL==MxBfL){Resize(BfL+1);}
253  Bf[BfL]=Ch; BfL++; return *this;
254 }
char * Bf
Definition: dt.h:80
int BfL
Definition: dt.h:79
void Resize(const int &_MxBfL)
Definition: dt.cpp:225
int MxBfL
Definition: dt.h:79
TMem & TMem::operator+= ( const TMem Mem)

Definition at line 256 of file dt.cpp.

256  {
257  int LBfL=Mem.Len(); if (BfL+LBfL>MxBfL){Resize(BfL+LBfL);}
258  if (LBfL>0){memcpy(&Bf[BfL], Mem(), LBfL);}
259  BfL+=LBfL; return *this;
260 }
char * Bf
Definition: dt.h:80
int Len() const
Definition: dt.h:134
int BfL
Definition: dt.h:79
void Resize(const int &_MxBfL)
Definition: dt.cpp:225
int MxBfL
Definition: dt.h:79
TMem & TMem::operator+= ( const TStr Str)

Definition at line 262 of file dt.cpp.

262  {
263  int LBfL=Str.Len(); if (BfL+LBfL>MxBfL){Resize(BfL+LBfL);}
264  if (LBfL>0){memcpy(Bf+BfL, Str.CStr(), LBfL);}
265  BfL+=LBfL; return *this;
266 }
int Len() const
Definition: dt.h:487
char * Bf
Definition: dt.h:80
int BfL
Definition: dt.h:79
void Resize(const int &_MxBfL)
Definition: dt.cpp:225
int MxBfL
Definition: dt.h:79
char * CStr()
Definition: dt.h:476
TMem & TMem::operator+= ( const PSIn SIn)

Definition at line 268 of file dt.cpp.

268  {
269  int LBfL=SIn->Len(); if (BfL+LBfL>MxBfL){Resize(BfL+LBfL);}
270  char* LBf=new char[LBfL];
271  SIn->GetBf(LBf, LBfL);
272  if (LBfL>0){memcpy(Bf+BfL, LBf, LBfL);}
273  delete[] LBf;
274  BfL+=LBfL; return *this;
275 }
char * Bf
Definition: dt.h:80
int BfL
Definition: dt.h:79
void Resize(const int &_MxBfL)
Definition: dt.cpp:225
int MxBfL
Definition: dt.h:79
TMem& TMem::operator= ( const TMem Mem)
inline

Definition at line 108 of file dt.h.

108  {
109  if (this!=&Mem){
110  if (Bf!=NULL){delete[] Bf;}
111  MxBfL=Mem.MxBfL; BfL=Mem.BfL; Bf=NULL;
112  if (MxBfL>0){Bf=new char[MxBfL]; memcpy(Bf, Mem.Bf, BfL);}}
113  return *this;}
char * Bf
Definition: dt.h:80
int BfL
Definition: dt.h:79
int MxBfL
Definition: dt.h:79
char& TMem::operator[] ( const int &  ChN) const
inline

Definition at line 119 of file dt.h.

119  {
120  Assert((0<=ChN)&&(ChN<BfL)); return Bf[ChN];}
char * Bf
Definition: dt.h:80
int BfL
Definition: dt.h:79
#define Assert(Cond)
Definition: bd.h:251
char TMem::Pop ( )
inline

Definition at line 139 of file dt.h.

139 {IAssert(BfL>0); BfL--; return Bf[BfL];}
#define IAssert(Cond)
Definition: bd.h:262
char * Bf
Definition: dt.h:80
int BfL
Definition: dt.h:79
void TMem::Push ( const char &  Ch)
inline

Definition at line 138 of file dt.h.

138 {operator+=(Ch);}
TMem & operator+=(const char &Ch)
Definition: dt.cpp:251
void TMem::Reserve ( const int &  _MxBfL,
const bool &  DoClr = true 
)
inline

Definition at line 128 of file dt.h.

128  {
129  if (DoClr){ Clr(); } Resize(_MxBfL);}
void Resize(const int &_MxBfL)
Definition: dt.cpp:225
void Clr(const bool &DoDel=true)
Definition: dt.h:131
void TMem::Resize ( const int &  _MxBfL)
private

Definition at line 225 of file dt.cpp.

225  {
226  if (_MxBfL<=MxBfL){return;}
227  else {if (MxBfL*2<_MxBfL){MxBfL=_MxBfL;} else {MxBfL*=2;}}
228  char* NewBf=new char[MxBfL]; IAssert(NewBf!=NULL);
229  if (BfL>0){memcpy(NewBf, Bf, BfL);}
230  if (Bf!=NULL){delete[] Bf;}
231  Bf=NewBf;
232 }
#define IAssert(Cond)
Definition: bd.h:262
char * Bf
Definition: dt.h:80
int BfL
Definition: dt.h:79
int MxBfL
Definition: dt.h:79
void TMem::Save ( TSOut SOut) const
inline

Definition at line 103 of file dt.h.

103  {
104  SOut.Save(MxBfL); SOut.Save(BfL); SOut.SaveBf(Bf, BfL);}
char * Bf
Definition: dt.h:80
int BfL
Definition: dt.h:79
void SaveBf(const void *Bf, const TSize &BfL)
Definition: fl.h:172
void Save(const bool &Bool)
Definition: fl.h:173
int MxBfL
Definition: dt.h:79
void TMem::SaveMem ( const PSOut SOut) const
inline

Definition at line 153 of file dt.h.

153 {SOut->SaveBf(Bf, Len());}
char * Bf
Definition: dt.h:80
int Len() const
Definition: dt.h:134
void SaveBf(const void *Bf, const TSize &BfL)
Definition: fl.h:172
void TMem::SaveXml ( TSOut SOut,
const TStr Nm 
) const

Definition at line 242 of file dt.cpp.

242  {
243  XSaveHdArg(Nm, "BfL", TInt::GetStr(BfL));
245 }
TStr GetStr() const
Definition: dt.h:1105
#define XSaveHdArg(Nm, ArgNm, ArgVal)
Definition: bd.h:321
static TStr GetXmlStrFromPlainMem(const TMem &PlainMem)
Definition: xml.cpp:945
int BfL
Definition: dt.h:79
int PutStr(const char *CStr)
Definition: fl.cpp:117
void TMem::Trunc ( const int &  _BfL)
inline

Definition at line 136 of file dt.h.

136  {
137  if ((0<=_BfL)&&(_BfL<=BfL)){BfL=_BfL;}}
int BfL
Definition: dt.h:79

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.

int TMem::BfL
private

Definition at line 79 of file dt.h.

TCRef TMem::CRef
private

Definition at line 77 of file dt.h.

int TMem::MxBfL
private

Definition at line 79 of file dt.h.


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