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

#include <fl.h>

Inheritance diagram for TFOut:
Collaboration diagram for TFOut:

List of all members.

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

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

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

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

                                               :
  TSBase(FNm.CStr()), TSOut(FNm), FileId(NULL), Bf(NULL), BfL(0){
  if (FNm.GetUc()=="CON"){
    FileId=stdout;
  } else {
    if (Append){FileId=fopen(FNm.CStr(), "a+b");}
    else {FileId=fopen(FNm.CStr(), "w+b");}
    EAssertR(FileId!=NULL, "Can not open file '"+FNm+"'.");
    Bf=new char[MxBfL]; BfL=0;
  }
}

Here is the call graph for this function:

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

Definition at line 422 of file fl.cpp.

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

                                                              :
  TSBase(FNm.CStr()), TSOut(FNm), FileId(NULL), Bf(NULL), BfL(0){
  if (FNm.GetUc()=="CON"){
    FileId=stdout;
  } else {
    if (Append){FileId=fopen(FNm.CStr(), "a+b");}
    else {FileId=fopen(FNm.CStr(), "w+b");}
    OpenedP=(FileId!=NULL);
    if (OpenedP){
      Bf=new char[MxBfL]; BfL=0;}
  }
}

Here is the call graph for this function:

Definition at line 444 of file fl.cpp.

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

             {
  if (FileId!=NULL){FlushBf();}
  if (Bf!=NULL){delete[] Bf;}
  if (FileId!=NULL){
    EAssertR(fclose(FileId)==0, "Can not close file '"+GetSNm()+"'.");}
}

Here is the call graph for this function:


Member Function Documentation

void TFOut::Flush ( ) [virtual]

Implements TSOut.

Definition at line 468 of file fl.cpp.

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

                 {
  FlushBf();
  EAssertR(fflush(FileId)==0, "Can not flush file '"+GetSNm()+"'.");
}

Here is the call graph for this function:

void TFOut::FlushBf ( ) [private]

Definition at line 403 of file fl.cpp.

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

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

                   {
  EAssertR(
   fwrite(Bf, 1, BfL, FileId)==BfL,
   "Error writting to the file '"+GetSNm()+"'.");
  BfL=0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

TFileId TFOut::GetFileId ( ) const [inline, virtual]

Reimplemented from TSOut.

Definition at line 342 of file fl.h.

References FileId.

{return FileId;}
PSOut TFOut::New ( const TStr FNm,
const bool &  Append = false 
) [static]

Definition at line 435 of file fl.cpp.

References TFOut().

Referenced by TStrPool::Save(), TUniChDb::SaveBin(), TLAMisc::SaveMatlabTFltV(), TLAMisc::SaveMatlabTFltVV(), TLAMisc::SaveMatlabTFltVVCol(), TLAMisc::SaveMatlabTFltVVMjrSubMtrx(), TLAMisc::SaveMatlabTIntV(), TXmlDoc::SaveTxt(), TStr::SaveTxt(), TUniChDb::Test(), and TPreproc::TPreproc().

                                                   {
  return PSOut(new TFOut(FNm, Append));
}

Here is the call graph for this function:

Here is the caller graph for this function:

PSOut TFOut::New ( const TStr FNm,
const bool &  Append,
bool &  OpenedP 
) [static]

Definition at line 439 of file fl.cpp.

References TFOut().

                                                                  {
  PSOut SOut=PSOut(new TFOut(FNm, Append, OpenedP));
  if (OpenedP){return SOut;} else {return NULL;}
}

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

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

                                                  {
  int LBfS=0;
  if (BfL+LBfL>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 TFOut::PutCh ( const char &  Ch) [virtual]

Implements TSOut.

Definition at line 451 of file fl.cpp.

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

Referenced by PutBf().

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

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().

Definition at line 322 of file fl.h.

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

const TSize TFOut::MxBfL = 16*1024 [static, private]

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: