SNAP Library , Developer Reference  2013-01-07 14:03:36
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 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 ()
 TMOut (const TMOut &)
TMOutoperator= (const TMOut &)

Private Attributes

char * Bf
int BfL
int MxBfL
bool OwnBf

Detailed Description

Definition at line 410 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 509 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 516 of file fl.cpp.

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

Definition at line 424 of file fl.h.

References Bf, and OwnBf.

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

Member Function Documentation

void TMOut::Clr ( ) [inline]

Definition at line 432 of file fl.h.

References BfL.

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

Definition at line 538 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 429 of file fl.h.

{}
TStr TMOut::GetAsStr ( ) const

Definition at line 532 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 438 of file fl.h.

References Bf.

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

Definition at line 433 of file fl.h.

References Bf, BfL, and IAssert.

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

Definition at line 564 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 585 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 544 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 558 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 578 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 431 of file fl.h.

References BfL.

{return BfL;}
void TMOut::MkEolnLn ( )

Definition at line 610 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 421 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 520 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 426 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 ( ) [private]

Definition at line 499 of file fl.cpp.

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

Referenced by PutCh().

                  {
  IAssert(OwnBf&&(BfL==MxBfL));
  if (Bf==NULL){
    IAssert(MxBfL==0); Bf=new char[MxBfL=1024];
  } else {
    MxBfL*=2; char* NewBf=new char[MxBfL];
    memmove(NewBf, Bf, BfL); delete[] Bf; Bf=NewBf;
  }
}

Here is the caller graph for this function:


Member Data Documentation

char* TMOut::Bf [private]
int TMOut::BfL [private]
int TMOut::MxBfL [private]

Definition at line 413 of file fl.h.

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

bool TMOut::OwnBf [private]

Definition at line 414 of file fl.h.

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


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