SNAP Library , Developer Reference
2013-01-07 14:03:36
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <fl.h>
Public Member Functions | |
TFIn (const TStr &FNm) | |
TFIn (const TStr &FNm, bool &OpenedP) | |
~TFIn () | |
bool | Eof () |
int | Len () const |
char | GetCh () |
char | PeekCh () |
int | GetBf (const void *LBf, const TSize &LBfL) |
void | Reset () |
Static Public Member Functions | |
static PSIn | New (const TStr &FNm) |
static PSIn | New (const TStr &FNm, bool &OpenedP) |
Private Member Functions | |
void | SetFPos (const int &FPos) const |
int | GetFPos () const |
int | GetFLen () const |
void | FillBf () |
TFIn () | |
TFIn (const TFIn &) | |
TFIn & | operator= (const TFIn &) |
Private Attributes | |
TFileId | FileId |
char * | Bf |
int | BfC |
int | BfL |
Static Private Attributes | |
static const int | MxBfL = 16*1024 |
TFIn::TFIn | ( | ) | [private] |
TFIn::TFIn | ( | const TFIn & | ) | [private] |
TFIn::TFIn | ( | const TStr & | FNm | ) |
Definition at line 267 of file fl.cpp.
References Bf, BfC, BfL, TStr::CStr(), EAssertR, TStr::Empty(), FileId, FillBf(), and MxBfL.
: TSBase(FNm.CStr()), TSIn(FNm), FileId(NULL), Bf(NULL), BfC(0), BfL(0){ EAssertR(!FNm.Empty(), "Empty file-name."); FileId=fopen(FNm.CStr(), "rb"); EAssertR(FileId!=NULL, "Can not open file '"+FNm+"'."); Bf=new char[MxBfL]; BfC=BfL=-1; FillBf(); }
TFIn::TFIn | ( | const TStr & | FNm, |
bool & | OpenedP | ||
) |
Definition at line 275 of file fl.cpp.
References Bf, BfC, BfL, TStr::CStr(), EAssertR, TStr::Empty(), FileId, FillBf(), and MxBfL.
: TSBase(FNm.CStr()), TSIn(FNm), FileId(NULL), Bf(NULL), BfC(0), BfL(0){ EAssertR(!FNm.Empty(), "Empty file-name."); FileId=fopen(FNm.CStr(), "rb"); OpenedP=(FileId!=NULL); if (OpenedP){ Bf=new char[MxBfL]; BfC=BfL=-1; FillBf();} }
TFIn::~TFIn | ( | ) |
bool TFIn::Eof | ( | ) | [inline, virtual] |
void TFIn::FillBf | ( | ) | [private] |
Definition at line 258 of file fl.cpp.
References Bf, BfC, BfL, EAssertR, FileId, TSBase::GetSNm(), and MxBfL.
Referenced by Eof(), GetBf(), Reset(), and TFIn().
{ EAssertR( (BfC==BfL)&&((BfL==-1)||(BfL==MxBfL)), "Error reading file '"+GetSNm()+"'."); BfL=int(fread(Bf, 1, MxBfL, FileId)); EAssertR((BfC!=0)||(BfL!=0), "Error reading file '"+GetSNm()+"'."); BfC=0; }
int TFIn::GetBf | ( | const void * | LBf, |
const TSize & | LBfL | ||
) | [virtual] |
Implements TSIn.
Definition at line 298 of file fl.cpp.
References Bf, BfC, BfL, and FillBf().
{ int LBfS=0; if (TSize(BfC+LBfL)>TSize(BfL)){ for (TSize LBfC=0; LBfC<LBfL; LBfC++){ if (BfC==BfL){FillBf();} LBfS+=((char*)LBf)[LBfC]=Bf[BfC++];} } else { for (TSize LBfC=0; LBfC<LBfL; LBfC++){ LBfS+=(((char*)LBf)[LBfC]=Bf[BfC++]);} } return LBfS; }
char TFIn::GetCh | ( | ) | [inline, virtual] |
int TFIn::GetFLen | ( | ) | const [private] |
Definition at line 249 of file fl.cpp.
References EAssertR, FileId, GetFPos(), TSBase::GetSNm(), SEEK_END, and SetFPos().
Referenced by Len().
{ const int FPos=GetFPos(); EAssertR( fseek(FileId, 0, SEEK_END)==0, "Error seeking into file '"+GetSNm()+"'."); const int FLen=GetFPos(); SetFPos(FPos); return FLen; }
int TFIn::GetFPos | ( | ) | const [private] |
Definition at line 243 of file fl.cpp.
References EAssertR, FileId, and TSBase::GetSNm().
Referenced by GetFLen(), and Len().
{ const int FPos=(int)ftell(FileId); EAssertR(FPos!=-1, "Error seeking into file '"+GetSNm()+"'."); return FPos; }
int TFIn::Len | ( | ) | const [inline, virtual] |
Definition at line 284 of file fl.cpp.
References TFIn().
Referenced by TUniChDb::LoadBin(), TSnap::LoadDyNet(), TSnap::LoadDyNetGraphV(), TLAMisc::LoadMatlabTFltVV(), THtmlDoc::LoadTxt(), TStr::LoadTxt(), TExpHelp::LoadXml(), TBigStrPool::New(), TStrPool::New(), TUniChDb::Test(), and TPreproc::TPreproc().
char TFIn::PeekCh | ( | ) | [inline, virtual] |
void TFIn::Reset | ( | ) | [inline, virtual] |
void TFIn::SetFPos | ( | const int & | FPos | ) | const [private] |
char* TFIn::Bf [private] |
int TFIn::BfC [private] |
int TFIn::BfL [private] |
TFileId TFIn::FileId [private] |
const int TFIn::MxBfL = 16*1024 [static, private] |