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
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 315 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 322 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 334 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 356 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 380 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 315 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 338 of file fl.h.

References FileId.

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

Definition at line 347 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 351 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 368 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 363 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 319 of file fl.h.

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

TSize TFOut::BfL [private]

Definition at line 320 of file fl.h.

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

Definition at line 318 of file fl.h.

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

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

Definition at line 317 of file fl.h.

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


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