|
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
|
#include <fl.h>
Inherits TSIn.
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 () |
| bool | GetNextLnBf (TChA &LnChA) |
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 () |
| int | FindEol (int &BfN, bool &CrEnd) |
| 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 | ) |
| TFIn::TFIn | ( | const TStr & | FNm, |
| bool & | OpenedP | ||
| ) |
| TFIn::~TFIn | ( | ) |
| bool TFIn::Eof | ( | ) | [inline, virtual] |
| void TFIn::FillBf | ( | ) | [private] |
| int TFIn::FindEol | ( | int & | BfN, |
| bool & | CrEnd | ||
| ) | [private] |
Definition at line 360 of file fl.cpp.
{
char Ch;
if (BfC >= BfL) {
// read more data, check for eof
if (Eof()) {
return -1;
}
if (CrEnd && Bf[BfC]=='\n') {
BfC++;
BfN = BfC-1;
return 1;
}
}
CrEnd = false;
while (BfC < BfL) {
Ch = Bf[BfC++];
if (Ch=='\n') {
BfN = BfC-1;
return 1;
}
if (Ch=='\r') {
if (BfC == BfL) {
CrEnd = true;
BfN = BfC-1;
return 0;
} else if (Bf[BfC]=='\n') {
BfC++;
BfN = BfC-2;
return 1;
}
}
}
BfN = BfC;
return 0;
}
| int TFIn::GetBf | ( | const void * | LBf, |
| const TSize & | LBfL | ||
| ) | [virtual] |
Implements TSIn.
| char TFIn::GetCh | ( | ) | [inline, virtual] |
| int TFIn::GetFLen | ( | ) | const [private] |
| int TFIn::GetFPos | ( | ) | const [private] |
| bool TFIn::GetNextLnBf | ( | TChA & | LnChA | ) | [virtual] |
Implements TSIn.
Definition at line 321 of file fl.cpp.
{
int Status;
int BfN; // new pointer to the end of line
int BfP; // previous pointer to the line start
bool CrEnd; // last character in previous buffer was CR
LnChA.Clr();
CrEnd = false;
do {
if (BfC >= BfL) {
// reset the current pointer, FindEol() will read a new buffer
BfP = 0;
} else {
BfP = BfC;
}
Status = FindEol(BfN,CrEnd);
if (Status >= 0) {
if (BfN-BfP > 0) {
LnChA.AddBf(&Bf[BfP],BfN-BfP);
}
if (Status == 1) {
// got a complete line
return true;
}
}
// get more data, if the line is incomplete
} while (Status == 0);
// eof or the last line has no newline
return !LnChA.Empty();
}
| int TFIn::Len | ( | ) | const [inline, virtual] |
| char TFIn::PeekCh | ( | ) | [inline, virtual] |
| void TFIn::Reset | ( | ) | [inline, virtual] |
| void TFIn::SetFPos | ( | const int & | FPos | ) | const [private] |
TFileId TFIn::FileId [private] |
const int TFIn::MxBfL = 16*1024 [static, private] |