SNAP Library 2.2, User 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>

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.

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

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

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

                         :
  MxBfL(Str.Len()), BfL(MxBfL), Bf(NULL){
  if (MxBfL>0){
    Bf=new char[MxBfL];
    if (BfL>0){memcpy(Bf, Str.CStr(), BfL);}
  }
}
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.

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

Member Function Documentation

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

Definition at line 291 of file dt.cpp.

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

                                  {
    if (DoDel){if (Bf!=NULL){delete[] Bf;} MxBfL=0; BfL=0; Bf=NULL;}
    else {BfL=0;}}
void TMem::Del ( const int &  BChN,
const int &  EChN 
)

Definition at line 277 of file dt.cpp.

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

{return BfL+LBfL<=MxBfL;}
bool TMem::DoFitStr ( const TStr Str) const

Definition at line 247 of file dt.cpp.

                                         {
  return DoFitLen(Str.Len()+1);
}
bool TMem::Empty ( ) const [inline]

Definition at line 135 of file dt.h.

{return BfL==0;}
void TMem::Gen ( const int &  _BfL) [inline]

Definition at line 123 of file dt.h.

                           {
    Clr(); Resize(_BfL); BfL=_BfL;}
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.

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

{return Bf;}
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.

                      {
    TMOut MOut(BfL); MOut.SaveBf(Bf, BfL); return MOut.GetSIn();}
int TMem::Len ( ) const [inline]

Definition at line 134 of file dt.h.

{return BfL;}
static void TMem::LoadMem ( const PSIn SIn,
TMem Mem 
) [inline, static]

Definition at line 149 of file dt.h.

                                                 {
    Mem.Clr(); Mem.Gen(SIn->Len()); SIn->GetBf(Mem.Bf, SIn->Len());}
static void TMem::LoadMem ( const PSIn SIn,
const PMem Mem 
) [inline, static]

Definition at line 151 of file dt.h.

                                                       {
    Mem->Clr(); Mem->Gen(SIn->Len()); SIn->GetBf(Mem->Bf, SIn->Len());}
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.

                                    {
  if (BfL==MxBfL){Resize(BfL+1);}
  Bf[BfL]=Ch; BfL++; return *this;
}
TMem & TMem::operator+= ( const TMem Mem)

Definition at line 256 of file dt.cpp.

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

Definition at line 262 of file dt.cpp.

                                     {
  int LBfL=Str.Len(); if (BfL+LBfL>MxBfL){Resize(BfL+LBfL);}
  if (LBfL>0){memcpy(Bf+BfL, Str.CStr(), LBfL);}
  BfL+=LBfL; return *this;
}
TMem & TMem::operator+= ( const PSIn SIn)

Definition at line 268 of file dt.cpp.

                                     {
  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;
}
TMem& TMem::operator= ( const TMem Mem) [inline]

Definition at line 108 of file dt.h.

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

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

Definition at line 139 of file dt.h.

{IAssert(BfL>0); BfL--; return Bf[BfL];}
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.

                                                           {
    if (DoClr){ Clr(); } Resize(_MxBfL);}
void TMem::Resize ( const int &  _MxBfL) [private]

Definition at line 225 of file dt.cpp.

                                  {
  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]

Definition at line 103 of file dt.h.

                               {
    SOut.Save(MxBfL); SOut.Save(BfL); SOut.SaveBf(Bf, BfL);}
void TMem::SaveMem ( const PSOut SOut) const [inline]

Definition at line 153 of file dt.h.

{SOut->SaveBf(Bf, Len());}
void TMem::SaveXml ( TSOut SOut,
const TStr Nm 
) const

Definition at line 242 of file dt.cpp.

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

Definition at line 136 of file dt.h.

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

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: