SNAP Library 3.0, Developer Reference  2016-07-20 17:56:49
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
TMOut Class Reference

#include <fl.h>

Inheritance diagram for TMOut:
Collaboration diagram for TMOut:

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 ()
 
- Public Member Functions inherited from TSOut
 TSOut ()
 
 TSOut (const TStr &Str)
 
virtual ~TSOut ()
 
void EnableLnTrunc (const int &_MxLnLen)
 
void DisableLnTrunc ()
 
virtual TFileId GetFileId () const
 
int PutMem (const TMem &Mem)
 
int PutCh (const char &Ch, const int &Chs)
 
int PutBool (const bool &Bool)
 
int PutInt (const int &Int)
 
int PutInt (const int &Int, const char *FmtStr)
 
int PutUInt (const uint &Int)
 
int PutUInt (const uint &Int, const char *FmtStr)
 
int PutFlt (const double &Flt)
 
int PutFlt (const double &Flt, const char *FmtStr)
 
int PutStr (const char *CStr)
 
int PutStr (const TChA &ChA)
 
int PutStr (const TStr &Str, const char *FmtStr)
 
int PutStr (const TStr &Str, const bool &ForceInLn=false)
 
int PutStrLn (const TStr &Str, const bool &ForceInLn=false)
 
int PutStrFmt (const char *FmtStr,...)
 
int PutStrFmtLn (const char *FmtStr,...)
 
int PutIndent (const int &IndentLev=1)
 
int PutLn (const int &Lns=1)
 
int PutDosLn (const int &Lns=1)
 
int PutSep (const int &NextStrLen=0)
 
int PutSepLn (const int &Lns=0)
 
void SaveCs ()
 
void SaveBf (const void *Bf, const TSize &BfL)
 
void Save (const bool &Bool)
 
void Save (const char &Ch)
 
void Save (const uchar &UCh)
 
void Save (const short &Short)
 
void Save (const ushort &UShort)
 
void Save (const int &Int)
 
void Save (const uint &UInt)
 
void Save (const int64 &Int)
 
void Save (const uint64 &UInt)
 
void Save (const double &Flt)
 
void Save (const sdouble &SFlt)
 
void Save (const ldouble &LFlt)
 
void Save (const char *CStr, const TSize &CStrLen)
 
void Save (const char *CStr)
 
void Save (TSIn &SIn, const TSize &BfL=-1)
 
void Save (const PSIn &SIn, const TSize &BfL=-1)
 
void Save (const void *Bf, const TSize &BfL)
 
TSOutoperator<< (const bool &Bool)
 
TSOutoperator<< (const uchar &UCh)
 
TSOutoperator<< (const char &Ch)
 
TSOutoperator<< (const short &Sh)
 
TSOutoperator<< (const ushort &USh)
 
TSOutoperator<< (const int &Int)
 
TSOutoperator<< (const uint &Int)
 
TSOutoperator<< (const int64 &Int)
 
TSOutoperator<< (const uint64 &UInt)
 
TSOutoperator<< (const float &Flt)
 
TSOutoperator<< (const double &Double)
 
TSOutoperator<< (const long double &LDouble)
 
TSOutoperator<< (const TSOutMnp &Mnp)
 
TSOutoperator<< (TSOut &(*FuncPt)(TSOut &))
 
TSOutoperator<< (TSIn &SIn)
 
TSOutoperator<< (PSIn &SIn)
 
- Public Member Functions inherited from TSBase
 TSBase (const TSStr &Nm)
 
virtual ~TSBase ()
 
virtual TStr GetSNm () const
 

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
 

Additional Inherited Members

- Static Public Attributes inherited from TSOut
static const TPt< TSOutStdOut =PSOut(new TStdOut())
 
- Protected Attributes inherited from TSBase
TCRef CRef
 
TSStr SNm
 
TCs Cs
 

Detailed Description

Definition at line 442 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 784 of file fl.cpp.

References Bf, and MxBfL.

784  :
785  TSBase("Output-Memory"), TSOut("Output-Memory"),
786  Bf(NULL), BfL(0), MxBfL(0), OwnBf(true){
787  MxBfL=_MxBfL>0?_MxBfL:1024;
788  Bf=new char[MxBfL];
789 }
int BfL
Definition: fl.h:445
TSBase(const TSStr &Nm)
Definition: fl.h:50
int MxBfL
Definition: fl.h:445
bool OwnBf
Definition: fl.h:446
TSOut()
Definition: fl.h:136
char * Bf
Definition: fl.h:444
TMOut::TMOut ( char *  _Bf,
const int &  _MxBfL 
)

Definition at line 791 of file fl.cpp.

791  :
792  TSBase("Output-Memory"), TSOut("Output-Memory"),
793  Bf(_Bf), BfL(0), MxBfL(_MxBfL), OwnBf(false){}
int BfL
Definition: fl.h:445
TSBase(const TSStr &Nm)
Definition: fl.h:50
int MxBfL
Definition: fl.h:445
bool OwnBf
Definition: fl.h:446
TSOut()
Definition: fl.h:136
char * Bf
Definition: fl.h:444
TMOut::~TMOut ( )
inline

Definition at line 456 of file fl.h.

References Bf, and OwnBf.

456 {if (OwnBf&&(Bf!=NULL)){delete[] Bf;}}
bool OwnBf
Definition: fl.h:446
char * Bf
Definition: fl.h:444

Member Function Documentation

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

Definition at line 795 of file fl.cpp.

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

795  {
796  Resize(Len() + (int)LBfL);
797  memcpy(Bf + BfL, LBf, LBfL);
798  BfL += (int)LBfL;
799 }
int BfL
Definition: fl.h:445
void Resize(const int &ReqLen=-1)
Definition: fl.cpp:769
char * Bf
Definition: fl.h:444
int Len() const
Definition: fl.h:464

Here is the call graph for this function:

void TMOut::Clr ( )
inline

Definition at line 465 of file fl.h.

References BfL.

465 {BfL=0;}
int BfL
Definition: fl.h:445
void TMOut::CutBf ( const int &  CutBfL)

Definition at line 819 of file fl.cpp.

References Bf, BfL, and IAssert.

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

819  {
820  IAssert((0<=CutBfL)&&(CutBfL<=BfL));
821  if (CutBfL==BfL){BfL=0;}
822  else {memmove(Bf, Bf+CutBfL, BfL-CutBfL); BfL=BfL-CutBfL;}
823 }
#define IAssert(Cond)
Definition: bd.h:262
int BfL
Definition: fl.h:445
char * Bf
Definition: fl.h:444

Here is the caller graph for this function:

void TMOut::Flush ( )
inlinevirtual

Implements TSOut.

Definition at line 462 of file fl.h.

462 {}
TStr TMOut::GetAsStr ( ) const

Definition at line 813 of file fl.cpp.

References Bf, and BfL.

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

813  {
814  TChA ChA(BfL);
815  for (int BfC=0; BfC<BfL; BfC++){ChA+=Bf[BfC];}
816  return ChA;
817 }
int BfL
Definition: fl.h:445
Definition: dt.h:201
char * Bf
Definition: fl.h:444

Here is the caller graph for this function:

char* TMOut::GetBfAddr ( ) const
inline

Definition at line 471 of file fl.h.

References Bf.

471 {return Bf;}
char * Bf
Definition: fl.h:444
char TMOut::GetCh ( const int &  ChN) const
inline

Definition at line 466 of file fl.h.

References Bf, BfL, and IAssert.

466  {
467  IAssert((0<=ChN)&&(ChN<BfL)); return Bf[ChN];}
#define IAssert(Cond)
Definition: bd.h:262
int BfL
Definition: fl.h:445
char * Bf
Definition: fl.h:444
TStr TMOut::GetCrLfLn ( )

Definition at line 845 of file fl.cpp.

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

845  {
846  IAssert(IsCrLfLn());
847  TChA Ln;
848  for (int BfC=0; BfC<BfL; BfC++){
849  char Ch=Bf[BfC];
850  if ((Ch==TCh::CrCh)&&((BfC+1<BfL)&&(Bf[BfC+1]==TCh::LfCh))){
851  Ln+=TCh::CrCh; Ln+=TCh::LfCh; CutBf(BfC+1+1); break;
852  } else {
853  Ln+=Ch;
854  }
855  }
856  return Ln;
857 }
#define IAssert(Cond)
Definition: bd.h:262
int BfL
Definition: fl.h:445
void CutBf(const int &CutBfL)
Definition: fl.cpp:819
static const char LfCh
Definition: dt.h:945
Definition: dt.h:201
static const char CrCh
Definition: dt.h:946
bool IsCrLfLn() const
Definition: fl.cpp:839
char * Bf
Definition: fl.h:444

Here is the call graph for this function:

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

Definition at line 866 of file fl.cpp.

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

866  {
867  IAssert(IsEolnLn());
868  int LnChs=0; TChA Ln;
869  for (int BfC=0; BfC<BfL; BfC++){
870  char Ch=Bf[BfC];
871  if ((Ch==TCh::CrCh)||(Ch==TCh::LfCh)){
872  LnChs++; if (DoAddEoln){Ln+=Ch;}
873  if (BfC+1<BfL){
874  char NextCh=Bf[BfC+1];
875  if (((Ch==TCh::CrCh)&&(NextCh==TCh::LfCh))||
876  ((Ch==TCh::LfCh)&&(NextCh==TCh::CrCh))){
877  LnChs++; if (DoAddEoln){Ln+=NextCh;}
878  }
879  }
880  break;
881  } else {
882  LnChs++; Ln+=Ch;
883  }
884  }
885  if (DoCutBf){
886  CutBf(LnChs);
887  }
888  return Ln;
889 }
#define IAssert(Cond)
Definition: bd.h:262
int BfL
Definition: fl.h:445
bool IsEolnLn() const
Definition: fl.cpp:859
void CutBf(const int &CutBfL)
Definition: fl.cpp:819
static const char LfCh
Definition: dt.h:945
Definition: dt.h:201
static const char CrCh
Definition: dt.h:946
char * Bf
Definition: fl.h:444

Here is the call graph for this function:

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

Definition at line 825 of file fl.cpp.

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

Referenced by TMem::GetSIn().

825  {
826  IAssert((CutBfL==-1)||((0<=CutBfL)));
827  int SInBfL= (CutBfL==-1) ? BfL : TInt::GetMn(BfL, CutBfL);
828  PSIn SIn;
829  if (OwnBf&&IsCut&&(SInBfL==BfL)){
830  SIn=PSIn(new TMIn(Bf, SInBfL, true));
831  Bf=NULL; BfL=MxBfL=0; OwnBf=true;
832  } else {
833  SIn=PSIn(new TMIn(Bf, SInBfL, false));
834  if (IsCut){CutBf(SInBfL);}
835  }
836  return SIn;
837 }
#define IAssert(Cond)
Definition: bd.h:262
int BfL
Definition: fl.h:445
void CutBf(const int &CutBfL)
Definition: fl.cpp:819
Definition: fl.h:384
static int GetMn(const int &Int1, const int &Int2)
Definition: dt.h:1090
int MxBfL
Definition: fl.h:445
bool OwnBf
Definition: fl.h:446
TPt< TSIn > PSIn
Definition: fl.h:119
char * Bf
Definition: fl.h:444

Here is the call graph for this function:

Here is the caller graph for this function:

bool TMOut::IsCrLfLn ( ) const

Definition at line 839 of file fl.cpp.

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

Referenced by GetCrLfLn().

839  {
840  for (int BfC=0; BfC<BfL; BfC++){
841  if ((Bf[BfC]==TCh::CrCh)&&((BfC+1<BfL)&&(Bf[BfC+1]==TCh::LfCh))){return true;}}
842  return false;
843 }
int BfL
Definition: fl.h:445
static const char LfCh
Definition: dt.h:945
static const char CrCh
Definition: dt.h:946
char * Bf
Definition: fl.h:444

Here is the caller graph for this function:

bool TMOut::IsEolnLn ( ) const

Definition at line 859 of file fl.cpp.

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

Referenced by GetEolnLn(), and MkEolnLn().

859  {
860  for (int BfC=0; BfC<BfL; BfC++){
861  if ((Bf[BfC]==TCh::CrCh)||(Bf[BfC]==TCh::LfCh)){return true;}
862  }
863  return false;
864 }
int BfL
Definition: fl.h:445
static const char LfCh
Definition: dt.h:945
static const char CrCh
Definition: dt.h:946
char * Bf
Definition: fl.h:444

Here is the caller graph for this function:

int TMOut::Len ( ) const
inline

Definition at line 464 of file fl.h.

References BfL.

Referenced by AppendBf().

464 {return BfL;}
int BfL
Definition: fl.h:445

Here is the caller graph for this function:

void TMOut::MkEolnLn ( )

Definition at line 891 of file fl.cpp.

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

891  {
892  if (!IsEolnLn()){
894 }
int PutCh(const char &Ch)
Definition: fl.h:458
bool IsEolnLn() const
Definition: fl.cpp:859
static const char LfCh
Definition: dt.h:945
static const char CrCh
Definition: dt.h:946

Here is the call graph for this function:

static PSOut TMOut::New ( const int &  MxBfL = 1024)
inlinestatic

Definition at line 453 of file fl.h.

References MxBfL, and TMOut().

Referenced by TXmlDoc::SaveStr().

453  {
454  return PSOut(new TMOut(MxBfL));}
TMOut(const TMOut &)
int MxBfL
Definition: fl.h:445
TPt< TSOut > PSOut
Definition: fl.h:211

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 801 of file fl.cpp.

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

801  {
802  int LBfS=0;
803  if (TSize(BfL+LBfL)>TSize(MxBfL)){
804  for (TSize LBfC=0; LBfC<LBfL; LBfC++){
805  LBfS+=PutCh(((char*)LBf)[LBfC]);}
806  } else {
807  for (TSize LBfC=0; LBfC<LBfL; LBfC++){
808  LBfS+=(Bf[BfL++]=((char*)LBf)[LBfC]);}
809  }
810  return LBfS;
811 }
int BfL
Definition: fl.h:445
int PutCh(const char &Ch)
Definition: fl.h:458
size_t TSize
Definition: bd.h:58
int MxBfL
Definition: fl.h:445
char * Bf
Definition: fl.h:444

Here is the call graph for this function:

int TMOut::PutCh ( const char &  Ch)
inlinevirtual

Implements TSOut.

Definition at line 458 of file fl.h.

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

Referenced by MkEolnLn(), and PutBf().

458  {if (BfL==MxBfL){
459  Resize();} return Bf[BfL++]=Ch;}
int BfL
Definition: fl.h:445
int MxBfL
Definition: fl.h:445
void Resize(const int &ReqLen=-1)
Definition: fl.cpp:769
char * Bf
Definition: fl.h:444

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 769 of file fl.cpp.

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

Referenced by AppendBf(), and PutCh().

769  {
770  IAssert(OwnBf&&(BfL==MxBfL || ReqLen >= 0));
771  if (Bf==NULL){
772  IAssert(MxBfL==0);
773  if (ReqLen < 0) Bf=new char[MxBfL=1024];
774  else Bf=new char[MxBfL=ReqLen];
775  } else {
776  if (ReqLen < 0){ MxBfL*=2; }
777  else if (ReqLen < MxBfL){ return; } // nothing to do
778  else { MxBfL=(2*MxBfL < ReqLen ? ReqLen : 2*MxBfL); }
779  char* NewBf=new char[MxBfL];
780  memmove(NewBf, Bf, BfL); delete[] Bf; Bf=NewBf;
781  }
782 }
#define IAssert(Cond)
Definition: bd.h:262
int BfL
Definition: fl.h:445
int MxBfL
Definition: fl.h:445
bool OwnBf
Definition: fl.h:446
char * Bf
Definition: fl.h:444

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 445 of file fl.h.

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

bool TMOut::OwnBf
private

Definition at line 446 of file fl.h.

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


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