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

#include <fl.h>

Inheritance diagram for TFOut:
Collaboration diagram for TFOut:

Public Member Functions

 TFOut (const TStr &_FNm, const bool &Append=false)
 
 TFOut (const TStr &_FNm, const bool &Append, bool &OpenedP)
 
 ~TFOut ()
 
int PutCh (const char &Ch)
 
int PutBf (const void *LBf, const TSize &LBfL)
 
void Flush ()
 
TFileId GetFileId () const
 
- Public Member Functions inherited from TSOut
 TSOut ()
 
 TSOut (const TStr &Str)
 
virtual ~TSOut ()
 
void EnableLnTrunc (const int &_MxLnLen)
 
void DisableLnTrunc ()
 
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 TStr &FNm, const bool &Append=false)
 
static PSOut New (const TStr &FNm, const bool &Append, bool &OpenedP)
 

Private Member Functions

void FlushBf ()
 
 TFOut ()
 
 TFOut (const TFOut &)
 
TFOutoperator= (const TFOut &)
 

Private Attributes

TFileId FileId
 
char * Bf
 
TSize BfL
 

Static Private Attributes

static const TSize MxBfL =16*1024
 

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

Constructor & Destructor Documentation

TFOut::TFOut ( )
private

Referenced by New().

Here is the caller graph for this function:

TFOut::TFOut ( const TFOut )
private
TFOut::TFOut ( const TStr _FNm,
const bool &  Append = false 
)

Definition at line 417 of file fl.cpp.

References Bf, BfL, TStr::CStr(), EAssertR, FileId, TStr::GetUc(), and MxBfL.

417  :
418  TSBase(FNm.CStr()), TSOut(FNm), FileId(NULL), Bf(NULL), BfL(0){
419  if (FNm.GetUc()=="CON"){
420  FileId=stdout;
421  } else {
422  if (Append){FileId=fopen(FNm.CStr(), "a+b");}
423  else {FileId=fopen(FNm.CStr(), "w+b");}
424  EAssertR(FileId!=NULL, "Can not open file '"+FNm+"'.");
425  Bf=new char[MxBfL]; BfL=0;
426  }
427 }
TSBase(const TSStr &Nm)
Definition: fl.h:50
char * Bf
Definition: fl.h:323
TFileId FileId
Definition: fl.h:322
static const TSize MxBfL
Definition: fl.h:321
#define EAssertR(Cond, MsgStr)
Definition: bd.h:283
TSOut()
Definition: fl.h:136
TSize BfL
Definition: fl.h:324

Here is the call graph for this function:

TFOut::TFOut ( const TStr _FNm,
const bool &  Append,
bool &  OpenedP 
)

Definition at line 429 of file fl.cpp.

References Bf, BfL, TStr::CStr(), FileId, TStr::GetUc(), and MxBfL.

429  :
430  TSBase(FNm.CStr()), TSOut(FNm), FileId(NULL), Bf(NULL), BfL(0){
431  if (FNm.GetUc()=="CON"){
432  FileId=stdout;
433  } else {
434  if (Append){FileId=fopen(FNm.CStr(), "a+b");}
435  else {FileId=fopen(FNm.CStr(), "w+b");}
436  OpenedP=(FileId!=NULL);
437  if (OpenedP){
438  Bf=new char[MxBfL]; BfL=0;}
439  }
440 }
TSBase(const TSStr &Nm)
Definition: fl.h:50
char * Bf
Definition: fl.h:323
TFileId FileId
Definition: fl.h:322
static const TSize MxBfL
Definition: fl.h:321
TSOut()
Definition: fl.h:136
TSize BfL
Definition: fl.h:324

Here is the call graph for this function:

TFOut::~TFOut ( )

Definition at line 451 of file fl.cpp.

References Bf, EAssertR, FileId, FlushBf(), and TSBase::GetSNm().

451  {
452  if (FileId!=NULL){FlushBf();}
453  if (Bf!=NULL){delete[] Bf;}
454  if (FileId!=NULL){
455  EAssertR(fclose(FileId)==0, "Can not close file '"+GetSNm()+"'.");}
456 }
char * Bf
Definition: fl.h:323
void FlushBf()
Definition: fl.cpp:410
TFileId FileId
Definition: fl.h:322
#define EAssertR(Cond, MsgStr)
Definition: bd.h:283
virtual TStr GetSNm() const
Definition: fl.cpp:20

Here is the call graph for this function:

Member Function Documentation

void TFOut::Flush ( )
virtual

Implements TSOut.

Definition at line 475 of file fl.cpp.

References EAssertR, FileId, FlushBf(), and TSBase::GetSNm().

475  {
476  FlushBf();
477  EAssertR(fflush(FileId)==0, "Can not flush file '"+GetSNm()+"'.");
478 }
void FlushBf()
Definition: fl.cpp:410
TFileId FileId
Definition: fl.h:322
#define EAssertR(Cond, MsgStr)
Definition: bd.h:283
virtual TStr GetSNm() const
Definition: fl.cpp:20

Here is the call graph for this function:

void TFOut::FlushBf ( )
private

Definition at line 410 of file fl.cpp.

References Bf, BfL, EAssertR, FileId, and TSBase::GetSNm().

Referenced by Flush(), PutCh(), and ~TFOut().

410  {
411  EAssertR(
412  fwrite(Bf, 1, BfL, FileId)==BfL,
413  "Error writting to the file '"+GetSNm()+"'.");
414  BfL=0;
415 }
char * Bf
Definition: fl.h:323
TFileId FileId
Definition: fl.h:322
#define EAssertR(Cond, MsgStr)
Definition: bd.h:283
virtual TStr GetSNm() const
Definition: fl.cpp:20
TSize BfL
Definition: fl.h:324

Here is the call graph for this function:

Here is the caller graph for this function:

TFileId TFOut::GetFileId ( ) const
inlinevirtual

Reimplemented from TSOut.

Definition at line 342 of file fl.h.

References FileId.

342 {return FileId;}
TFileId FileId
Definition: fl.h:322
PSOut TFOut::New ( const TStr FNm,
const bool &  Append = false 
)
static
PSOut TFOut::New ( const TStr FNm,
const bool &  Append,
bool &  OpenedP 
)
static

Definition at line 446 of file fl.cpp.

References TFOut().

446  {
447  PSOut SOut=PSOut(new TFOut(FNm, Append, OpenedP));
448  if (OpenedP){return SOut;} else {return NULL;}
449 }
Definition: bd.h:196
TPt< TSOut > PSOut
Definition: fl.h:211

Here is the call graph for this function:

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

Implements TSOut.

Definition at line 463 of file fl.cpp.

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

463  {
464  int LBfS=0;
465  if (BfL+LBfL>MxBfL){
466  for (TSize LBfC=0; LBfC<LBfL; LBfC++){
467  LBfS+=PutCh(((char*)LBf)[LBfC]);}
468  } else {
469  for (TSize LBfC=0; LBfC<LBfL; LBfC++){
470  LBfS+=(Bf[BfL++]=((char*)LBf)[LBfC]);}
471  }
472  return LBfS;
473 }
int PutCh(const char &Ch)
Definition: fl.cpp:458
char * Bf
Definition: fl.h:323
size_t TSize
Definition: bd.h:58
static const TSize MxBfL
Definition: fl.h:321
TSize BfL
Definition: fl.h:324

Here is the call graph for this function:

int TFOut::PutCh ( const char &  Ch)
virtual

Implements TSOut.

Definition at line 458 of file fl.cpp.

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

Referenced by PutBf().

458  {
459  if (BfL==TSize(MxBfL)){FlushBf();}
460  return Bf[BfL++]=Ch;
461 }
char * Bf
Definition: fl.h:323
void FlushBf()
Definition: fl.cpp:410
size_t TSize
Definition: bd.h:58
static const TSize MxBfL
Definition: fl.h:321
TSize BfL
Definition: fl.h:324

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

char* TFOut::Bf
private

Definition at line 323 of file fl.h.

Referenced by FlushBf(), PutBf(), PutCh(), TFOut(), and ~TFOut().

TSize TFOut::BfL
private

Definition at line 324 of file fl.h.

Referenced by FlushBf(), PutBf(), PutCh(), and TFOut().

TFileId TFOut::FileId
private

Definition at line 322 of file fl.h.

Referenced by Flush(), FlushBf(), GetFileId(), TFOut(), and ~TFOut().

const TSize TFOut::MxBfL =16*1024
staticprivate

Definition at line 321 of file fl.h.

Referenced by PutBf(), PutCh(), and TFOut().


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