SNAP Library 2.0, User Reference  2013-05-13 16:33:57
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>

Inherits TSOut.

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]
TFOut::TFOut ( const TFOut ) [private]
TFOut::TFOut ( const TStr _FNm,
const bool &  Append = false 
)

Definition at line 410 of file fl.cpp.

                                               :
  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;
  }
}
TFOut::TFOut ( const TStr _FNm,
const bool &  Append,
bool &  OpenedP 
)

Definition at line 422 of file fl.cpp.

                                                              :
  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;}
  }
}

Definition at line 444 of file fl.cpp.

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

Member Function Documentation

void TFOut::Flush ( ) [virtual]

Implements TSOut.

Definition at line 468 of file fl.cpp.

                 {
  FlushBf();
  EAssertR(fflush(FileId)==0, "Can not flush file '"+GetSNm()+"'.");
}
void TFOut::FlushBf ( ) [private]

Definition at line 403 of file fl.cpp.

                   {
  EAssertR(
   fwrite(Bf, 1, BfL, FileId)==BfL,
   "Error writting to the file '"+GetSNm()+"'.");
  BfL=0;
}
TFileId TFOut::GetFileId ( ) const [inline, virtual]

Reimplemented from TSOut.

Definition at line 342 of file fl.h.

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

Definition at line 435 of file fl.cpp.

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

Definition at line 439 of file fl.cpp.

                                                                  {
  PSOut SOut=PSOut(new TFOut(FNm, Append, OpenedP));
  if (OpenedP){return SOut;} else {return NULL;}
}
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.

                                                  {
  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;
}
int TFOut::PutCh ( const char &  Ch) [virtual]

Implements TSOut.

Definition at line 451 of file fl.cpp.

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

Member Data Documentation

char* TFOut::Bf [private]

Definition at line 323 of file fl.h.

TSize TFOut::BfL [private]

Definition at line 324 of file fl.h.

Definition at line 322 of file fl.h.

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

Definition at line 321 of file fl.h.


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