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
TMOut Class Reference

#include <fl.h>

Inheritance diagram for TMOut:
Collaboration diagram for TMOut:

List of all members.

Public Member Functions

 TMOut (const int &_MxBfL=1024)
 TMOut (char *_Bf, const int &_MxBfL)
 ~TMOut ()
int PutCh (const char &Ch)
int PutBf (const void *LBf, const TSize &LBfL)
void AppendBf (const void *LBf, const TSize &LBfL)
void Flush ()
int Len () const
void Clr ()
char GetCh (const int &ChN) const
TStr GetAsStr () const
void CutBf (const int &CutBfL)
PSIn GetSIn (const bool &IsCut=true, const int &CutBfL=-1)
char * GetBfAddr () const
bool IsCrLfLn () const
TStr GetCrLfLn ()
bool IsEolnLn () const
TStr GetEolnLn (const bool &DoAddEoln, const bool &DoCutBf)
void MkEolnLn ()

Static Public Member Functions

static PSOut New (const int &MxBfL=1024)

Private Member Functions

void Resize (const int &ReqLen=-1)
 TMOut (const TMOut &)
TMOutoperator= (const TMOut &)

Private Attributes

char * Bf
int BfL
int MxBfL
bool OwnBf

Detailed Description

Definition at line 417 of file fl.h.


Constructor & Destructor Documentation

TMOut::TMOut ( const TMOut ) [private]

Referenced by New().

Here is the caller graph for this function:

TMOut::TMOut ( const int &  _MxBfL = 1024)

Definition at line 618 of file fl.cpp.

References Bf, and MxBfL.

                             :
  TSBase("Output-Memory"), TSOut("Output-Memory"),
  Bf(NULL), BfL(0), MxBfL(0), OwnBf(true){
  MxBfL=_MxBfL>0?_MxBfL:1024;
  Bf=new char[MxBfL];
}
TMOut::TMOut ( char *  _Bf,
const int &  _MxBfL 
)

Definition at line 625 of file fl.cpp.

                                        :
  TSBase("Output-Memory"), TSOut("Output-Memory"),
  Bf(_Bf), BfL(0), MxBfL(_MxBfL), OwnBf(false){}
TMOut::~TMOut ( ) [inline]

Definition at line 431 of file fl.h.

References Bf, and OwnBf.

{if (OwnBf&&(Bf!=NULL)){delete[] Bf;}}

Member Function Documentation

void TMOut::AppendBf ( const void *  LBf,
const TSize LBfL 
)

Definition at line 629 of file fl.cpp.

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

                                                       {
  Resize(Len() + (int)LBfL);
  memcpy(Bf + BfL, LBf, LBfL);
  BfL += (int)LBfL;
}

Here is the call graph for this function:

void TMOut::Clr ( ) [inline]

Definition at line 440 of file fl.h.

References BfL.

{BfL=0;}
void TMOut::CutBf ( const int &  CutBfL)

Definition at line 653 of file fl.cpp.

References Bf, BfL, and IAssert.

Referenced by GetCrLfLn(), GetEolnLn(), and GetSIn().

                                  {
  IAssert((0<=CutBfL)&&(CutBfL<=BfL));
  if (CutBfL==BfL){BfL=0;}
  else {memmove(Bf, Bf+CutBfL, BfL-CutBfL); BfL=BfL-CutBfL;}
}

Here is the caller graph for this function:

void TMOut::Flush ( ) [inline, virtual]

Implements TSOut.

Definition at line 437 of file fl.h.

{}
TStr TMOut::GetAsStr ( ) const

Definition at line 647 of file fl.cpp.

References Bf, and BfL.

Referenced by THtmlDoc::GetRedirHtmlDocStr(), and TXmlDoc::SaveStr().

                           {
  TChA ChA(BfL);
  for (int BfC=0; BfC<BfL; BfC++){ChA+=Bf[BfC];}
  return ChA;
}

Here is the caller graph for this function:

char* TMOut::GetBfAddr ( ) const [inline]

Definition at line 446 of file fl.h.

References Bf.

{return Bf;}
char TMOut::GetCh ( const int &  ChN) const [inline]

Definition at line 441 of file fl.h.

References Bf, BfL, and IAssert.

                                   {
    IAssert((0<=ChN)&&(ChN<BfL)); return Bf[ChN];}

Definition at line 679 of file fl.cpp.

References Bf, BfL, TCh::CrCh, CutBf(), IAssert, IsCrLfLn(), and TCh::LfCh.

                     {
  IAssert(IsCrLfLn());
  TChA Ln;
  for (int BfC=0; BfC<BfL; BfC++){
    char Ch=Bf[BfC];
    if ((Ch==TCh::CrCh)&&((BfC+1<BfL)&&(Bf[BfC+1]==TCh::LfCh))){
      Ln+=TCh::CrCh; Ln+=TCh::LfCh; CutBf(BfC+1+1); break;
    } else {
      Ln+=Ch;
    }
  }
  return Ln;
}

Here is the call graph for this function:

TStr TMOut::GetEolnLn ( const bool &  DoAddEoln,
const bool &  DoCutBf 
)

Definition at line 700 of file fl.cpp.

References Bf, BfL, TCh::CrCh, CutBf(), IAssert, IsEolnLn(), and TCh::LfCh.

                                                               {
  IAssert(IsEolnLn());
  int LnChs=0; TChA Ln;
  for (int BfC=0; BfC<BfL; BfC++){
    char Ch=Bf[BfC];
    if ((Ch==TCh::CrCh)||(Ch==TCh::LfCh)){
      LnChs++; if (DoAddEoln){Ln+=Ch;}
      if (BfC+1<BfL){
        char NextCh=Bf[BfC+1];
        if (((Ch==TCh::CrCh)&&(NextCh==TCh::LfCh))||
         ((Ch==TCh::LfCh)&&(NextCh==TCh::CrCh))){
          LnChs++; if (DoAddEoln){Ln+=NextCh;}
        }
      }
      break;
    } else {
      LnChs++; Ln+=Ch;
    }
  }
  if (DoCutBf){
    CutBf(LnChs);
  }
  return Ln;
}

Here is the call graph for this function:

PSIn TMOut::GetSIn ( const bool &  IsCut = true,
const int &  CutBfL = -1 
)

Definition at line 659 of file fl.cpp.

References Bf, BfL, CutBf(), TInt::GetMn(), IAssert, MxBfL, and OwnBf.

Referenced by TFHash< TKey, TFDat, TVDat >::AddDat(), TFHash< TKey, TFDat, TVDat >::AddKey(), TMem::GetSIn(), TExpVal::GetStr(), TExp::GetStr(), TFHashKey< TKey, TFDat, TVDat >::OnDelFromCache(), TFHash< TKey, TFDat, TVDat >::TFHash(), and TFHash< TKey, TFDat, TVDat >::~TFHash().

                                                      {
  IAssert((CutBfL==-1)||((0<=CutBfL)));
  int SInBfL= (CutBfL==-1) ? BfL : TInt::GetMn(BfL, CutBfL);
  PSIn SIn;
  if (OwnBf&&IsCut&&(SInBfL==BfL)){
    SIn=PSIn(new TMIn(Bf, SInBfL, true));
    Bf=NULL; BfL=MxBfL=0; OwnBf=true;
  } else {
    SIn=PSIn(new TMIn(Bf, SInBfL, false));
    if (IsCut){CutBf(SInBfL);}
  }
  return SIn;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool TMOut::IsCrLfLn ( ) const

Definition at line 673 of file fl.cpp.

References Bf, BfL, TCh::CrCh, and TCh::LfCh.

Referenced by GetCrLfLn().

                           {
  for (int BfC=0; BfC<BfL; BfC++){
    if ((Bf[BfC]==TCh::CrCh)&&((BfC+1<BfL)&&(Bf[BfC+1]==TCh::LfCh))){return true;}}
  return false;
}

Here is the caller graph for this function:

bool TMOut::IsEolnLn ( ) const

Definition at line 693 of file fl.cpp.

References Bf, BfL, TCh::CrCh, and TCh::LfCh.

Referenced by GetEolnLn(), and MkEolnLn().

                           {
  for (int BfC=0; BfC<BfL; BfC++){
    if ((Bf[BfC]==TCh::CrCh)||(Bf[BfC]==TCh::LfCh)){return true;}
  }
  return false;
}

Here is the caller graph for this function:

int TMOut::Len ( ) const [inline]

Definition at line 439 of file fl.h.

References BfL.

Referenced by AppendBf().

{return BfL;}

Here is the caller graph for this function:

void TMOut::MkEolnLn ( )

Definition at line 725 of file fl.cpp.

References TCh::CrCh, IsEolnLn(), TCh::LfCh, and PutCh().

                    {
  if (!IsEolnLn()){
    PutCh(TCh::CrCh); PutCh(TCh::LfCh);}
}

Here is the call graph for this function:

static PSOut TMOut::New ( const int &  MxBfL = 1024) [inline, static]

Definition at line 428 of file fl.h.

References MxBfL, and TMOut().

Referenced by TExp::GetStr().

                                         {
    return PSOut(new TMOut(MxBfL));}

Here is the call graph for this function:

Here is the caller graph for this function:

TMOut& TMOut::operator= ( const TMOut ) [private]
int TMOut::PutBf ( const void *  LBf,
const TSize LBfL 
) [virtual]

Implements TSOut.

Definition at line 635 of file fl.cpp.

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

                                                  {
  int LBfS=0;
  if (TSize(BfL+LBfL)>TSize(MxBfL)){
    for (TSize LBfC=0; LBfC<LBfL; LBfC++){
      LBfS+=PutCh(((char*)LBf)[LBfC]);}
  } else {
    for (TSize LBfC=0; LBfC<LBfL; LBfC++){
      LBfS+=(Bf[BfL++]=((char*)LBf)[LBfC]);}
  }
  return LBfS;
}

Here is the call graph for this function:

int TMOut::PutCh ( const char &  Ch) [inline, virtual]

Implements TSOut.

Definition at line 433 of file fl.h.

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

Referenced by MkEolnLn(), and PutBf().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void TMOut::Resize ( const int &  ReqLen = -1) [private]

Definition at line 603 of file fl.cpp.

References Bf, BfL, IAssert, MxBfL, and OwnBf.

Referenced by AppendBf(), and PutCh().

                                   {
  IAssert(OwnBf&&(BfL==MxBfL || ReqLen >= 0));
  if (Bf==NULL){
    IAssert(MxBfL==0); 
    if (ReqLen < 0) Bf=new char[MxBfL=1024];
    else Bf=new char[MxBfL=ReqLen];
  } else {
    if (ReqLen < 0){ MxBfL*=2; }
    else if (ReqLen < MxBfL){ return; } // nothing to do 
    else { MxBfL=(2*MxBfL < ReqLen ? ReqLen : 2*MxBfL); }
    char* NewBf=new char[MxBfL];
    memmove(NewBf, Bf, BfL); delete[] Bf; Bf=NewBf;
  }
}

Here is the caller graph for this function:


Member Data Documentation

int TMOut::BfL [private]
int TMOut::MxBfL [private]

Definition at line 420 of file fl.h.

Referenced by GetSIn(), New(), PutBf(), PutCh(), Resize(), and TMOut().

bool TMOut::OwnBf [private]

Definition at line 421 of file fl.h.

Referenced by GetSIn(), Resize(), and ~TMOut().


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