SNAP Library 6.0, User Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
TMOut Class Reference

#include <fl.h>

Inherits TSOut.

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

Constructor & Destructor Documentation

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

Definition at line 840 of file fl.cpp.

840  :
841  TSBase("Output-Memory"), TSOut("Output-Memory"),
842  Bf(NULL), BfL(0), MxBfL(0), OwnBf(true){
843  MxBfL=_MxBfL>0?_MxBfL:1024;
844  Bf=new char[MxBfL];
845 }
int BfL
Definition: fl.h:498
TSBase(const TSStr &Nm)
Definition: fl.h:50
int MxBfL
Definition: fl.h:498
bool OwnBf
Definition: fl.h:499
TSOut()
Definition: fl.h:136
char * Bf
Definition: fl.h:497
TMOut::TMOut ( char *  _Bf,
const int &  _MxBfL 
)

Definition at line 847 of file fl.cpp.

847  :
848  TSBase("Output-Memory"), TSOut("Output-Memory"),
849  Bf(_Bf), BfL(0), MxBfL(_MxBfL), OwnBf(false){}
int BfL
Definition: fl.h:498
TSBase(const TSStr &Nm)
Definition: fl.h:50
int MxBfL
Definition: fl.h:498
bool OwnBf
Definition: fl.h:499
TSOut()
Definition: fl.h:136
char * Bf
Definition: fl.h:497
TMOut::~TMOut ( )
inline

Definition at line 509 of file fl.h.

509 {if (OwnBf&&(Bf!=NULL)){delete[] Bf;}}
bool OwnBf
Definition: fl.h:499
char * Bf
Definition: fl.h:497

Member Function Documentation

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

Definition at line 851 of file fl.cpp.

851  {
852  Resize(Len() + (int)LBfL);
853  memcpy(Bf + BfL, LBf, LBfL);
854  BfL += (int)LBfL;
855 }
int BfL
Definition: fl.h:498
void Resize(const int &ReqLen=-1)
Definition: fl.cpp:825
char * Bf
Definition: fl.h:497
int Len() const
Definition: fl.h:517
void TMOut::Clr ( )
inline

Definition at line 518 of file fl.h.

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

Definition at line 875 of file fl.cpp.

875  {
876  IAssert((0<=CutBfL)&&(CutBfL<=BfL));
877  if (CutBfL==BfL){BfL=0;}
878  else {memmove(Bf, Bf+CutBfL, BfL-CutBfL); BfL=BfL-CutBfL;}
879 }
#define IAssert(Cond)
Definition: bd.h:262
int BfL
Definition: fl.h:498
char * Bf
Definition: fl.h:497
void TMOut::Flush ( )
inlinevirtual

Implements TSOut.

Definition at line 515 of file fl.h.

515 {}
TStr TMOut::GetAsStr ( ) const

Definition at line 869 of file fl.cpp.

869  {
870  TChA ChA(BfL);
871  for (int BfC=0; BfC<BfL; BfC++){ChA+=Bf[BfC];}
872  return ChA;
873 }
int BfL
Definition: fl.h:498
Definition: dt.h:201
char * Bf
Definition: fl.h:497
char* TMOut::GetBfAddr ( ) const
inline

Definition at line 524 of file fl.h.

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

Definition at line 519 of file fl.h.

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

Definition at line 901 of file fl.cpp.

901  {
902  IAssert(IsCrLfLn());
903  TChA Ln;
904  for (int BfC=0; BfC<BfL; BfC++){
905  char Ch=Bf[BfC];
906  if ((Ch==TCh::CrCh)&&((BfC+1<BfL)&&(Bf[BfC+1]==TCh::LfCh))){
907  Ln+=TCh::CrCh; Ln+=TCh::LfCh; CutBf(BfC+1+1); break;
908  } else {
909  Ln+=Ch;
910  }
911  }
912  return Ln;
913 }
#define IAssert(Cond)
Definition: bd.h:262
int BfL
Definition: fl.h:498
void CutBf(const int &CutBfL)
Definition: fl.cpp:875
static const char LfCh
Definition: dt.h:1038
Definition: dt.h:201
static const char CrCh
Definition: dt.h:1039
bool IsCrLfLn() const
Definition: fl.cpp:895
char * Bf
Definition: fl.h:497
TStr TMOut::GetEolnLn ( const bool &  DoAddEoln,
const bool &  DoCutBf 
)

Definition at line 922 of file fl.cpp.

922  {
923  IAssert(IsEolnLn());
924  int LnChs=0; TChA Ln;
925  for (int BfC=0; BfC<BfL; BfC++){
926  char Ch=Bf[BfC];
927  if ((Ch==TCh::CrCh)||(Ch==TCh::LfCh)){
928  LnChs++; if (DoAddEoln){Ln+=Ch;}
929  if (BfC+1<BfL){
930  char NextCh=Bf[BfC+1];
931  if (((Ch==TCh::CrCh)&&(NextCh==TCh::LfCh))||
932  ((Ch==TCh::LfCh)&&(NextCh==TCh::CrCh))){
933  LnChs++; if (DoAddEoln){Ln+=NextCh;}
934  }
935  }
936  break;
937  } else {
938  LnChs++; Ln+=Ch;
939  }
940  }
941  if (DoCutBf){
942  CutBf(LnChs);
943  }
944  return Ln;
945 }
#define IAssert(Cond)
Definition: bd.h:262
int BfL
Definition: fl.h:498
bool IsEolnLn() const
Definition: fl.cpp:915
void CutBf(const int &CutBfL)
Definition: fl.cpp:875
static const char LfCh
Definition: dt.h:1038
Definition: dt.h:201
static const char CrCh
Definition: dt.h:1039
char * Bf
Definition: fl.h:497
PSIn TMOut::GetSIn ( const bool &  IsCut = true,
const int &  CutBfL = -1 
)

Definition at line 881 of file fl.cpp.

881  {
882  IAssert((CutBfL==-1)||((0<=CutBfL)));
883  int SInBfL= (CutBfL==-1) ? BfL : TInt::GetMn(BfL, CutBfL);
884  PSIn SIn;
885  if (OwnBf&&IsCut&&(SInBfL==BfL)){
886  SIn=PSIn(new TMIn(Bf, SInBfL, true));
887  Bf=NULL; BfL=MxBfL=0; OwnBf=true;
888  } else {
889  SIn=PSIn(new TMIn(Bf, SInBfL, false));
890  if (IsCut){CutBf(SInBfL);}
891  }
892  return SIn;
893 }
#define IAssert(Cond)
Definition: bd.h:262
int BfL
Definition: fl.h:498
void CutBf(const int &CutBfL)
Definition: fl.cpp:875
Definition: fl.h:437
static int GetMn(const int &Int1, const int &Int2)
Definition: dt.h:1183
int MxBfL
Definition: fl.h:498
bool OwnBf
Definition: fl.h:499
TPt< TSIn > PSIn
Definition: fl.h:119
char * Bf
Definition: fl.h:497
bool TMOut::IsCrLfLn ( ) const

Definition at line 895 of file fl.cpp.

895  {
896  for (int BfC=0; BfC<BfL; BfC++){
897  if ((Bf[BfC]==TCh::CrCh)&&((BfC+1<BfL)&&(Bf[BfC+1]==TCh::LfCh))){return true;}}
898  return false;
899 }
int BfL
Definition: fl.h:498
static const char LfCh
Definition: dt.h:1038
static const char CrCh
Definition: dt.h:1039
char * Bf
Definition: fl.h:497
bool TMOut::IsEolnLn ( ) const

Definition at line 915 of file fl.cpp.

915  {
916  for (int BfC=0; BfC<BfL; BfC++){
917  if ((Bf[BfC]==TCh::CrCh)||(Bf[BfC]==TCh::LfCh)){return true;}
918  }
919  return false;
920 }
int BfL
Definition: fl.h:498
static const char LfCh
Definition: dt.h:1038
static const char CrCh
Definition: dt.h:1039
char * Bf
Definition: fl.h:497
int TMOut::Len ( ) const
inline

Definition at line 517 of file fl.h.

517 {return BfL;}
int BfL
Definition: fl.h:498
void TMOut::MkEolnLn ( )

Definition at line 947 of file fl.cpp.

947  {
948  if (!IsEolnLn()){
950 }
int PutCh(const char &Ch)
Definition: fl.h:511
bool IsEolnLn() const
Definition: fl.cpp:915
static const char LfCh
Definition: dt.h:1038
static const char CrCh
Definition: dt.h:1039
static PSOut TMOut::New ( const int &  MxBfL = 1024)
inlinestatic

Definition at line 506 of file fl.h.

506  {
507  return PSOut(new TMOut(MxBfL));}
TMOut(const TMOut &)
int MxBfL
Definition: fl.h:498
TPt< TSOut > PSOut
Definition: fl.h:211
TMOut& TMOut::operator= ( const TMOut )
private
int TMOut::PutBf ( const void *  LBf,
const TSize LBfL 
)
virtual

Implements TSOut.

Definition at line 857 of file fl.cpp.

857  {
858  int LBfS=0;
859  if (TSize(BfL+LBfL)>TSize(MxBfL)){
860  for (TSize LBfC=0; LBfC<LBfL; LBfC++){
861  LBfS+=PutCh(((char*)LBf)[LBfC]);}
862  } else {
863  for (TSize LBfC=0; LBfC<LBfL; LBfC++){
864  LBfS+=(Bf[BfL++]=((char*)LBf)[LBfC]);}
865  }
866  return LBfS;
867 }
int BfL
Definition: fl.h:498
int PutCh(const char &Ch)
Definition: fl.h:511
size_t TSize
Definition: bd.h:58
int MxBfL
Definition: fl.h:498
char * Bf
Definition: fl.h:497
int TMOut::PutCh ( const char &  Ch)
inlinevirtual

Implements TSOut.

Definition at line 511 of file fl.h.

511  {if (BfL==MxBfL){
512  Resize();} return Bf[BfL++]=Ch;}
int BfL
Definition: fl.h:498
int MxBfL
Definition: fl.h:498
void Resize(const int &ReqLen=-1)
Definition: fl.cpp:825
char * Bf
Definition: fl.h:497
void TMOut::Resize ( const int &  ReqLen = -1)
private

Definition at line 825 of file fl.cpp.

825  {
826  IAssert(OwnBf&&(BfL==MxBfL || ReqLen >= 0));
827  if (Bf==NULL){
828  IAssert(MxBfL==0);
829  if (ReqLen < 0) Bf=new char[MxBfL=1024];
830  else Bf=new char[MxBfL=ReqLen];
831  } else {
832  if (ReqLen < 0){ MxBfL*=2; }
833  else if (ReqLen < MxBfL){ return; } // nothing to do
834  else { MxBfL=(2*MxBfL < ReqLen ? ReqLen : 2*MxBfL); }
835  char* NewBf=new char[MxBfL];
836  memmove(NewBf, Bf, BfL); delete[] Bf; Bf=NewBf;
837  }
838 }
#define IAssert(Cond)
Definition: bd.h:262
int BfL
Definition: fl.h:498
int MxBfL
Definition: fl.h:498
bool OwnBf
Definition: fl.h:499
char * Bf
Definition: fl.h:497

Member Data Documentation

char* TMOut::Bf
private

Definition at line 497 of file fl.h.

int TMOut::BfL
private

Definition at line 498 of file fl.h.

int TMOut::MxBfL
private

Definition at line 498 of file fl.h.

bool TMOut::OwnBf
private

Definition at line 499 of file fl.h.


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