4 SkipLeadBlanks(_SkipLeadBlanks), SkipCmt(_SkipCmt), SkipEmptyFld(_SkipEmptyFld), LineCnt(0), SplitCh(
'\t'), LineStr(), FldV(), FInPt(NULL) {
27 while (*cur &&
TCh::IsWs(*cur)) { cur++; }
32 else {
while (*cur && *cur!=
SplitCh) { cur++; } }
33 if (*cur == 0) {
break; }
44 for (
int f = 0; f <
FldV.
Len(); f++) {
45 for (
char *c =
FldV[f]; *c; c++) {
54 const char *c =
GetFld(FldN);
56 if (*c==
'-') { Minus=
true; c++; }
63 if (Minus) { _Val = -_Val; }
64 if (*c != 0) {
return false; }
71 const char *c =
GetFld(FldN);
73 if (*c==
'+' || *c==
'-') { c++; }
74 if (!
TCh::IsNum(*c) && *c!=
'.') {
return false; }
80 if (*c==
'e' || *c ==
'E') {
82 if (*c ==
'+' || *c ==
'-' ) { c++; }
86 if (*c != 0) {
return false; }
92 static TChA ChA(10*1024);
94 for (
int i = 0; i <
FldV.
Len(); i++) {
117 if (Lb <= EndPos && EndPos < Ub) {
136 while (*cur &&
TCh::IsWs(*cur)) { cur++; }
139 while (*cur != 0 && *cur !=
'\n') {
141 else {
while (*cur && *cur!=
SplitCh && (*cur !=
'\n')) { cur++; } }
142 if (*cur == 0) {
break; }
143 if (*cur ==
'\n') {
break; }
146 FieldsV.
Add(last); last = cur;
156 const char *c = FieldsV[FldN];
158 if (*c==
'-') { Minus=
true; c++; }
165 if (Minus) { _Val = -_Val; }
166 if (*c != 0 && !
TCh::IsWs(*c)) {
return -1; }
172 const char *c = FieldsV[FldN];
176 if (*c==
'+' || *c==
'-') { c++; }
178 if (!
TCh::IsNum(*c) && *c!=
'.') {
return -1; }
186 if (*c==
'e' || *c ==
'E') {
188 if (*c ==
'+' || *c ==
'-' ) { c++; }
192 if (*c != 0 && !
TCh::IsWs(*c)) {
return -1; }
193 return atof(FieldsV[FldN]);
bool Next()
Loads next line from the input file.
bool GetFlt(const int &FldN, double &Val) const
If the field FldN is a float its value is returned in Val and the function returns true...
TVec< uint64 > GetStartPosV(uint64 Lb, uint64 Ub) const
Finds start positions of all lines ending somewhere in [Lb, Ub)
const char * DumpStr() const
static bool IsNum(const char &Ch)
TSsParserMP(const TStr &FNm, const TSsFmt _SsFmt=ssfTabSep, const bool &_SkipLeadBlanks=false, const bool &_SkipCmt=true, const bool &_SkipEmptyFld=false)
Constructor.
TChA LineStr
Current line.
TSizeTy Len() const
Returns the number of elements in the vector.
uint64 LineCnt
Number of processed lines so far.
bool GetInt(const int &FldN, int &Val) const
If the field FldN is an integer its value is returned in Val and the function returns true...
bool SkipLeadBlanks
Ignore leading whitespace characters in a line.
bool SkipEmptyFld
Skip empty fields (i.e., multiple consecutive separators are considered as one).
bool GetNextLnBf(TChA &LnChA)
bool Empty() const
Tests whether the vector is empty.
void SkipCommentLines()
Skips lines that begin with a comment character.
void SkipCommentLines()
Move stream pointer along until a non commented line is found.
static bool IsWs(const char &Ch)
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
TPt< TMIn > FInPt
Pointer to the input file stream.
unsigned long long uint64
TVec< char * > FldV
Pointers to fields of the current line.
const char * GetFld(const int &FldN) const
Returns the contents of the field at index FldN.
static int GetNum(const char &Ch)
Whitespace (space or tab) separated.
uint64 CountNewLinesInRange(uint64 Lb, uint64 Ub)
Finds number of new line chars in interval [Lb, Ub)
const TVal & Last() const
Returns a reference to the last element of the vector.
static PSIn New(const void *_Bf, const uint64 &_BfL, const bool &TakeBf=false)
void ToLc()
Transforms the current line to lower case.
uint64 GetLineEndPos(uint64 Ind)
Finds end of line in which Ind is present.
uint64 GetLineStartPos(uint64 Ind)
Finds beginning of line in which Ind is present.
uint64 CountNewLinesInRange(uint64 Lb, uint64 Ub) const
Counts number of occurences of ' ' in [Lb, Ub)
int GetIntFromFldV(TVec< char * > &FieldsV, const int &FldN)
Gets integer at field FldN.
void NextFromIndex(uint64 Index, TVec< char * > &FieldsV)
Loads next line starting from a given position.
char * GetLine(uint64 Ind)
static TStr Fmt(const char *FmtStr,...)
bool SkipCmt
Skip comments (lines starting with #).
char SplitCh
Separator character (if one of the non-started separators is used)
TSsFmt SsFmt
Separator type.
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
void DelLast()
Removes the last element of the vector.
uint64 GetStreamLen() const
Returns length of stream.
Vector is a sequence TVal objects representing an array that can change in size.
double GetFltFromFldV(TVec< char * > &FieldsV, const int &FldN)
Gets float at field FldN.