SNAP Library 6.0, User Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
ss.cpp
Go to the documentation of this file.
1 //#//////////////////////////////////////////////
2 // Spread-Sheet
3 TStr& TSs::At(const int& X, const int& Y){
4 // Fail;
5  if (Y>=CellStrVV.Len()){CellStrVV.Reserve(Y+1, Y+1);}
6  if (X>=CellStrVV[Y]->Len()){CellStrVV[Y]->V.Reserve(X+1, X+1);}
7  return CellStrVV[Y]->V[X];
8 }
9 
10 void TSs::PutVal(const int& X, const int& Y, const TStr& Str){
11  if (Y>=CellStrVV.Len()){CellStrVV.Reserve(Y+1, Y+1);}
12  if (X>=CellStrVV[Y]->Len()){CellStrVV[Y]->V.Reserve(X+1, X+1);}
13  CellStrVV[Y]->V[X]=Str;
14 }
15 
16 TStr TSs::GetVal(const int& X, const int& Y) const {
17  if ((0<=Y)&&(Y<CellStrVV.Len())){
18  if ((0<=X)&&(X<CellStrVV[Y]->Len())){
19  return CellStrVV[Y]->V[X];
20  } else {
21  return TStr::GetNullStr();
22  }
23  } else {
24  return TStr::GetNullStr();
25  }
26 }
27 
28 int TSs::GetXLen() const {
29  if (CellStrVV.Len()==0){
30  return 0;
31  } else {
32  int MxXLen=CellStrVV[0]->Len();
33  for (int Y=1; Y<CellStrVV.Len(); Y++){
34  MxXLen=TInt::GetMx(MxXLen, CellStrVV[Y]->Len());}
35  return MxXLen;
36  }
37 }
38 
39 int TSs::GetXLen(const int& Y) const {
40  if ((0<=Y)&&(Y<CellStrVV.Len())){
41  return CellStrVV[Y]->Len();
42  } else {
43  return 0;
44  }
45 }
46 
47 int TSs::GetYLen() const {
48  return CellStrVV.Len();
49 }
50 
51 int TSs::SearchX(const int& Y, const TStr& Str) const {
52  return CellStrVV[Y]->V.SearchForw(Str);
53 }
54 
55 int TSs::SearchY(const int& X, const TStr& Str) const {
56  int YLen=GetYLen();
57  for (int Y=0; Y<YLen; Y++){
58  if (Str==GetVal(X, Y)){return Y;}}
59  return -1;
60 }
61 
62 void TSs::DelX(const int& X){
63  int YLen=GetYLen();
64  for (int Y=0; Y<YLen; Y++){
65  CellStrVV[Y]->V.Del(X);
66  }
67 }
68 
69 void TSs::DelY(const int& Y){
70  CellStrVV.Del(Y);
71 }
72 
73 int TSs::GetFldX(const TStr& FldNm, const TStr& NewFldNm, const int& Y) const {
74  if (GetYLen()>Y){
75  int XLen=GetXLen(Y);
76  for (int X=0; X<XLen; X++){
77  if (GetVal(X, Y).GetTrunc()==FldNm){
78  if (!NewFldNm.Empty()){GetVal(X, Y)=NewFldNm;}
79  return X;
80  }
81  }
82  return -1;
83  } else {
84  return -1;
85  }
86 }
87 
88 int TSs::GetFldY(const TStr& FldNm, const TStr& NewFldNm, const int& X) const {
89  for (int Y=0; Y<GetYLen(); Y++){
90  if (GetXLen(Y)>X){
91  if (GetVal(X, Y).GetTrunc()==FldNm){
92  if (!NewFldNm.Empty()){GetVal(X, Y)=NewFldNm;}
93  return Y;
94  }
95  }
96  }
97  return -1;
98 }
99 
101  const TSsFmt& SsFmt, const TStr& FNm,
102  const PNotify& Notify, const bool& IsExcelEoln,
103  const int& MxY, const TIntV& AllowedColNV, const bool& IsQStr){
104  TNotify::OnNotify(Notify, ntInfo, TStr("Loading File ")+FNm+" ...");
105  PSIn SIn=TFIn::New(FNm);
106  PSs Ss=TSs::New();
107  if (!SIn->Eof()){
108  int X=0; int Y=0; int PrevX=-1; int PrevY=-1;
109  char Ch=SIn->GetCh(); TChA ChA;
110  while (!SIn->Eof()){
111  // compose value
112  ChA.Clr();
113  if (IsQStr&&(Ch=='"')){
114  // quoted string ('""' sequence means '"')
115  Ch=SIn->GetCh();
116  forever {
117  while ((!SIn->Eof())&&(Ch!='"')){
118  ChA+=Ch; Ch=SIn->GetCh();}
119  if (Ch=='"'){
120  Ch=SIn->GetCh();
121  if (Ch=='"'){ChA+=Ch; Ch=SIn->GetCh();}
122  else {break;}
123  }
124  }
125  } else {
126  if (SsFmt==ssfTabSep){
127  while ((!SIn->Eof())&&(Ch!='\t')&&(Ch!='\r')&&((Ch!='\n')||IsExcelEoln)){
128  ChA+=Ch; Ch=SIn->GetCh();
129  }
130  } else
131  if (SsFmt==ssfCommaSep){
132  while ((!SIn->Eof())&&(Ch!=',')&&(Ch!='\r')&&((Ch!='\n')||IsExcelEoln)){
133  ChA+=Ch; Ch=SIn->GetCh();
134  }
135  } else
136  if (SsFmt==ssfSemicolonSep){
137  while ((!SIn->Eof())&&(Ch!=';')&&(Ch!='\r')&&((Ch!='\n')||IsExcelEoln)){
138  ChA+=Ch; Ch=SIn->GetCh();
139  }
140  } else
141  if (SsFmt==ssfVBar){
142  while ((!SIn->Eof())&&(Ch!='|')&&(Ch!='\r')&&((Ch!='\n')||IsExcelEoln)){
143  ChA+=Ch; Ch=SIn->GetCh();
144  }
145  } else
146  if (SsFmt==ssfSpaceSep){
147  while ((!SIn->Eof())&&(Ch!=' ')&&(Ch!='\r')&&((Ch!='\n')||IsExcelEoln)){
148  ChA+=Ch; Ch=SIn->GetCh();
149  }
150  } else {
151  Fail;
152  }
153  }
154  // add new line if neccessary
155  if (PrevY!=Y){
156  if ((MxY!=-1)&&(Ss->CellStrVV.Len()==MxY)){break;}
157  Ss->CellStrVV.Add(TStrVP::New()); PrevY=Y;
158  int Recs=Ss->CellStrVV.Len();
159  if (Recs%1000==0){
160  TNotify::OnStatus(Notify, TStr::Fmt(" %d\r", Recs));}
161  }
162  // add value to spreadsheet
163  if (AllowedColNV.Empty()||AllowedColNV.IsIn(X)){
164  Ss->CellStrVV[Y]->V.Add(ChA);
165  }
166  // process delimiters
167  if (SIn->Eof()){
168  break;
169  } else
170  if ((SsFmt==ssfTabSep)&&(Ch=='\t')){
171  X++; Ch=SIn->GetCh();
172  } else
173  if ((SsFmt==ssfCommaSep)&&(Ch==',')){
174  X++; Ch=SIn->GetCh();
175  } else
176  if ((SsFmt==ssfSemicolonSep)&&(Ch==';')){
177  X++; Ch=SIn->GetCh();
178  } else
179  if ((SsFmt==ssfVBar)&&(Ch=='|')){
180  X++; Ch=SIn->GetCh();
181  } else
182  if ((SsFmt==ssfSpaceSep)&&(Ch==' ')){
183  X++; Ch=SIn->GetCh();
184  } else
185  if (Ch=='\r'){
186  if ((PrevX!=-1)&&(X!=PrevX)){
187  TNotify::OnNotify(Notify, ntWarn, "Number of fields is not the same!");}
188  PrevX=X; X=0; Y++; Ch=SIn->GetCh();
189  if ((Ch=='\n')&&(!SIn->Eof())){Ch=SIn->GetCh();}
190  //if (Ss->CellStrVV.Len()%1000==0){Y--; break;}
191  } else
192  if (Ch=='\n'){
193  if ((PrevX!=-1)&&(X!=PrevX)){
194  TNotify::OnNotify(Notify, ntWarn, "Number of fields is not the same!");}
195  PrevX=X; X=0; Y++; Ch=SIn->GetCh();
196  if ((Ch=='\r')&&(!SIn->Eof())){Ch=SIn->GetCh();}
197  //if (Ss->CellStrVV.Len()%1000==0){Y--; break;}
198  } else {
199  Fail;
200  }
201  }
202  }
203  int Recs=Ss->CellStrVV.Len();
204  TNotify::OnNotify(Notify, ntInfo, TStr::Fmt(" %d records read.", Recs));
205  TNotify::OnNotify(Notify, ntInfo, "... Done.");
206  return Ss;
207 }
208 
209 void TSs::SaveTxt(const TStr& FNm, const PNotify&) const {
210  PSOut SOut=TFOut::New(FNm);
211  for (int Y=0; Y<CellStrVV.Len(); Y++){
212  for (int X=0; X<CellStrVV[Y]->Len(); X++){
213  if (X>0){SOut->PutCh('\t');}
214  TStr Str=CellStrVV[Y]->V[X];
215  TChA ChA(Str);
216  for (int ChN=0; ChN<ChA.Len(); ChN++){
217  char Ch=ChA[ChN];
218  if ((Ch=='\t')||(Ch=='\r')||(Ch=='\n')){
219  ChA.PutCh(ChN, ' ');
220  }
221  }
222  SOut->PutStr(ChA);
223  }
224  SOut->PutCh('\r'); SOut->PutCh('\n');
225  }
226 }
227 
229  const TSsFmt& SsFmt, const PSIn& SIn, char& Ch,
230  TStrV& FldValV, const bool& IsExcelEoln, const bool& IsQStr){
231  if (!SIn->Eof()){
232  FldValV.Clr(false); int X=0;
233  if (Ch==TCh::NullCh){Ch=SIn->GetCh();}
234  TChA ChA;
235  while (!SIn->Eof()){
236  // compose value
237  ChA.Clr();
238  if (IsQStr&&(Ch=='"')){
239  // quoted string ('""' sequence means '"')
240  Ch=SIn->GetCh();
241  forever {
242  while ((!SIn->Eof())&&(Ch!='"')){
243  ChA+=Ch; Ch=SIn->GetCh();}
244  if (Ch=='"'){
245  Ch=SIn->GetCh();
246  if (Ch=='"'){ChA+=Ch; Ch=SIn->GetCh();}
247  else {break;}
248  }
249  }
250  } else {
251  if (SsFmt==ssfTabSep){
252  while ((!SIn->Eof())&&(Ch!='\t')&&(Ch!='\r')&&
253  ((Ch!='\n')||IsExcelEoln)){
254  ChA+=Ch; Ch=SIn->GetCh();
255  }
256  if ((!ChA.Empty())&&(ChA.LastCh()=='\"')){
257  ChA.Pop();}
258  } else
259  if (SsFmt==ssfCommaSep){
260  while ((!SIn->Eof())&&(Ch!=',')&&(Ch!='\r')&&
261  ((Ch!='\n')||IsExcelEoln)){
262  ChA+=Ch; Ch=SIn->GetCh();
263  }
264  } else
265  if (SsFmt==ssfSemicolonSep){
266  while ((!SIn->Eof())&&(Ch!=';')&&(Ch!='\r')&&
267  ((Ch!='\n')||IsExcelEoln)){
268  ChA+=Ch; Ch=SIn->GetCh();
269  }
270  } else
271  if (SsFmt==ssfVBar){
272  while ((!SIn->Eof())&&(Ch!='|')&&(Ch!='\r')&&
273  ((Ch!='\n')||IsExcelEoln)){
274  ChA+=Ch; Ch=SIn->GetCh();
275  }
276  } else {
277  Fail;
278  }
279  }
280  // add value to spreadsheet
281  ChA.Trunc();
282  FldValV.Add(ChA);
283  // process delimiters
284  if (SIn->Eof()){
285  break;
286  } else
287  if ((SsFmt==ssfTabSep)&&(Ch=='\t')){
288  X++; Ch=SIn->GetCh();
289  } else
290  if ((SsFmt==ssfCommaSep)&&(Ch==',')){
291  X++; Ch=SIn->GetCh();
292  } else
293  if ((SsFmt==ssfSemicolonSep)&&(Ch==';')){
294  X++; Ch=SIn->GetCh();
295  } else
296  if ((SsFmt==ssfVBar)&&(Ch=='|')){
297  X++; Ch=SIn->GetCh();
298  } else
299  if (Ch=='\r'){
300  Ch=SIn->GetCh();
301  if ((Ch=='\n')&&(!SIn->Eof())){Ch=SIn->GetCh();}
302  break;
303  } else
304  if (Ch=='\n'){
305  X=0; Ch=SIn->GetCh();
306  if ((Ch=='\r')&&(!SIn->Eof())){Ch=SIn->GetCh();}
307  break;
308  } else {
309  Fail;
310  }
311  }
312  }
313 }
314 
316  TStr LcSsFmtNm=SsFmtNm.GetLc();
317  if (LcSsFmtNm=="tab"){return ssfTabSep;}
318  else if (LcSsFmtNm=="comma"){return ssfCommaSep;}
319  else if (LcSsFmtNm=="semicolon"){return ssfSemicolonSep;}
320  else if (LcSsFmtNm=="vbar"){return ssfVBar;}
321  else if (LcSsFmtNm=="space"){return ssfSpaceSep;}
322  else if (LcSsFmtNm=="white"){return ssfWhiteSep;}
323  else {return ssfUndef;}
324 }
325 
327  switch (SsFmt){
328  case ssfTabSep: return "tab";
329  case ssfCommaSep: return "comma";
330  case ssfSemicolonSep: return "semicolon";
331  case ssfVBar: return "vbar";
332  case ssfSpaceSep: return "space";
333  case ssfWhiteSep: return "white";
334  default: return "undef";
335  }
336 }
337 
339  TChA ChA;
340  ChA+='(';
341  ChA+="tab"; ChA+=", ";
342  ChA+="comma"; ChA+=", ";
343  ChA+="semicolon"; ChA+=", ";
344  ChA+="space"; ChA+=", ";
345  ChA+="white"; ChA+=")";
346  return ChA;
347 }
348 
349 //#//////////////////////////////////////////////
350 // Fast-Spread-Sheet-Parser
351 TSsParser::TSsParser(const TStr& FNm, const TSsFmt _SsFmt, const bool& _SkipLeadBlanks, const bool& _SkipCmt, const bool& _SkipEmptyFld) : SsFmt(_SsFmt),
352  SkipLeadBlanks(_SkipLeadBlanks), SkipCmt(_SkipCmt), SkipEmptyFld(_SkipEmptyFld), LineCnt(0), /*Bf(NULL),*/ SplitCh('\t'), LineStr(), FldV(), FInPt(NULL) {
353  if (TZipIn::IsZipExt(FNm.GetFExt())) { FInPt = TZipIn::New(FNm); }
354  else { FInPt = TFIn::New(FNm); }
355  //Bf = new char [BfLen];
356  switch(SsFmt) {
357  case ssfTabSep : SplitCh = '\t'; break;
358  case ssfCommaSep : SplitCh = ','; break;
359  case ssfSemicolonSep : SplitCh = ';'; break;
360  case ssfVBar : SplitCh = '|'; break;
361  case ssfSpaceSep : SplitCh = ' '; break;
362  case ssfWhiteSep: SplitCh = ' '; break;
363  default: FailR("Unknown separator character.");
364  }
365 }
366 
367 TSsParser::TSsParser(const TStr& FNm, const char& Separator, const bool& _SkipLeadBlanks, const bool& _SkipCmt, const bool& _SkipEmptyFld) : SsFmt(ssfSpaceSep),
368  SkipLeadBlanks(_SkipLeadBlanks), SkipCmt(_SkipCmt), SkipEmptyFld(_SkipEmptyFld), LineCnt(0), /*Bf(NULL),*/ SplitCh('\t'), LineStr(), FldV(), FInPt(NULL) {
369  if (TZipIn::IsZipExt(FNm.GetFExt())) { FInPt = TZipIn::New(FNm); }
370  else { FInPt = TFIn::New(FNm); }
371  SplitCh = Separator;
372 }
373 
375  //if (Bf != NULL) { delete [] Bf; }
376 }
377 
378 // Gets and parses the next line.
379 // This version of Next() is older, slower, works with chars.
380 // RS 01/22/13 obsolete, can be removed in the future
381 
382 bool TSsParser::NextSlow() { // split on SplitCh
383  FldV.Clr(false);
384  LineStr.Clr();
385  FldV.Clr();
386  LineCnt++;
387  if (! FInPt->GetNextLn(LineStr)) { return false; }
388  if (SkipCmt && !LineStr.Empty() && LineStr[0]=='#') { return NextSlow(); }
389 
390  char* cur = LineStr.CStr();
391  if (SkipLeadBlanks) { // skip leading blanks
392  while (*cur && TCh::IsWs(*cur)) { cur++; }
393  }
394  char *last = cur;
395  while (*cur) {
396  if (SsFmt == ssfWhiteSep) { while (*cur && ! TCh::IsWs(*cur)) { cur++; } }
397  else { while (*cur && *cur!=SplitCh) { cur++; } }
398  if (*cur == 0) { break; }
399  *cur = 0; cur++;
400  FldV.Add(last); last = cur;
401  if (SkipEmptyFld && strlen(FldV.Last())==0) { FldV.DelLast(); } // skip empty fields
402  }
403 
404  if (*last != 0) { FldV.Add(last); } // add last field
405  if (SkipEmptyFld && FldV.Empty()) { return NextSlow(); } // skip empty lines
406 
407  return true;
408 }
409 
410 // Gets and parses the next line, quick version, works with buffers, not chars.
411 
412 bool TSsParser::Next() { // split on SplitCh
413  FldV.Clr(false);
414  LineStr.Clr();
415  FldV.Clr();
416  LineCnt++;
417  if (! FInPt->GetNextLnBf(LineStr)) { return false; }
418  if (SkipCmt && !LineStr.Empty() && LineStr[0]=='#') { return Next(); }
419 
420  char* cur = LineStr.CStr();
421  if (SkipLeadBlanks) { // skip leading blanks
422  while (*cur && TCh::IsWs(*cur)) { cur++; }
423  }
424  char *last = cur;
425  while (*cur) {
426  if (SsFmt == ssfWhiteSep) { while (*cur && ! TCh::IsWs(*cur)) { cur++; } }
427  else { while (*cur && *cur!=SplitCh) { cur++; } }
428  if (*cur == 0) { break; }
429  *cur = 0; cur++;
430  FldV.Add(last); last = cur;
431  if (SkipEmptyFld && strlen(FldV.Last())==0) { FldV.DelLast(); } // skip empty fields
432  }
433 
434  if (*last != 0) { FldV.Add(last); } // add last field
435  if (SkipEmptyFld && FldV.Empty()) { return Next(); } // skip empty lines
436 
437  return true;
438 }
439 
441  for (int f = 0; f < FldV.Len(); f++) {
442  for (char *c = FldV[f]; *c; c++) {
443  *c = tolower(*c); }
444  }
445 }
446 
447 bool TSsParser::GetInt(const int& FldN, int& Val) const {
448  // parsing format {ws} [+/-] +{ddd}
449  if (FldN >= Len()) { return false; }
450  int _Val = -1;
451  bool Minus=false;
452  const char *c = GetFld(FldN);
453  while (TCh::IsWs(*c)) { c++; }
454  if (*c=='-') { Minus=true; c++; }
455  if (! TCh::IsNum(*c)) { return false; }
456  _Val = TCh::GetNum(*c); c++;
457  while (TCh::IsNum(*c)){
458  _Val = 10 * _Val + TCh::GetNum(*c);
459  c++;
460  }
461  if (Minus) { _Val = -_Val; }
462  if (*c != 0) { return false; }
463  Val = _Val;
464  return true;
465 }
466 
467 bool TSsParser::GetUInt64(const int& FldN, uint64& Val) const {
468  // parsing format {ws} [+]{ddd}
469  if (FldN >= Len()) { return false; }
470  uint64 _Val=0;
471  const char *c = GetFld(FldN);
472  while (TCh::IsWs(*c)){ c++; }
473  if (*c == '+'){ c++; }
474  if (! TCh::IsNum(*c)) { return false; }
475  _Val = TCh::GetNum(*c); c++;
476  while (TCh::IsNum(*c)) {
477  _Val = 10*_Val + TCh::GetNum(*c);
478  c++;
479  }
480  if (*c != 0) { return false; }
481  Val = _Val;
482  return true;
483 }
484 
485 bool TSsParser::GetFlt(const int& FldN, double& Val) const {
486  // parsing format {ws} [+/-] +{d} ([.]{d}) ([E|e] [+/-] +{d})
487  if (FldN >= Len()) { return false; }
488  const char *c = GetFld(FldN);
489  while (TCh::IsWs(*c)) { c++; }
490  if (*c=='+' || *c=='-') { c++; }
491  if (! TCh::IsNum(*c) && *c!='.') { return false; }
492  while (TCh::IsNum(*c)) { c++; }
493  if (*c == '.') {
494  c++;
495  while (TCh::IsNum(*c)) { c++; }
496  }
497  if (*c=='e' || *c == 'E') {
498  c++;
499  if (*c == '+' || *c == '-' ) { c++; }
500  if (! TCh::IsNum(*c)) { return false; }
501  while (TCh::IsNum(*c)) { c++; }
502  }
503  if (*c != 0) { return false; }
504  Val = atof(GetFld(FldN));
505  return true;
506 }
507 
508 const char* TSsParser::DumpStr() const {
509  static TChA ChA(10*1024);
510  ChA.Clr();
511  for (int i = 0; i < FldV.Len(); i++) {
512  ChA += TStr::Fmt(" %d: '%s'\n", i, FldV[i]);
513  }
514  return ChA.CStr();
515 }
516 
int GetYLen() const
Definition: ss.cpp:47
void DelX(const int &X)
Definition: ss.cpp:62
int GetXLen() const
Definition: ss.cpp:28
TSsFmt SsFmt
Separator type.
Definition: ss.h:74
int SearchX(const int &Y, const TStr &Str) const
Definition: ss.cpp:51
bool GetUInt64(const int &FldN, uint64 &Val) const
If the field FldN is a 64-bit unsigned integer its value is returned in Val and the function returns ...
Definition: ss.cpp:467
static PSOut New(const TStr &FNm, const bool &Append=false)
Definition: fl.cpp:442
static PSs LoadTxt(const TSsFmt &SsFmt, const TStr &FNm, const PNotify &Notify=NULL, const bool &IsExcelEoln=true, const int &MxY=-1, const TIntV &AllowedColNV=TIntV(), const bool &IsQStr=true)
Definition: ss.cpp:100
static bool IsNum(const char &Ch)
Definition: dt.h:1067
virtual int PutCh(const char &Ch)=0
bool IsIn(const TVal &Val) const
Checks whether element Val is a member of the vector.
Definition: ds.h:828
#define forever
Definition: bd.h:6
static int GetMx(const int &Int1, const int &Int2)
Definition: dt.h:1185
bool Empty() const
Definition: dt.h:260
#define Fail
Definition: bd.h:238
static const char NullCh
Definition: dt.h:1036
void PutCh(const int &ChN, const char &Ch)
Definition: dt.h:278
void Clr()
Definition: dt.h:258
bool NextSlow()
Loads next line from the input file (older, slow implementation - deprecated).
Definition: ss.cpp:382
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
uint64 LineCnt
Number of processed lines so far.
Definition: ss.h:78
void ToLc()
Transforms the current line to lower case.
Definition: ss.cpp:440
TSsParser(const TStr &FNm, const TSsFmt _SsFmt=ssfTabSep, const bool &_SkipLeadBlanks=false, const bool &_SkipCmt=true, const bool &_SkipEmptyFld=false)
Constructor.
Definition: ss.cpp:351
static TStr GetSsFmtNmVStr()
Definition: ss.cpp:338
int Len() const
Definition: dt.h:259
Semicolon separated.
Definition: ss.h:8
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...
Definition: ss.cpp:447
TStr GetFExt() const
Definition: dt.cpp:1421
Vertical bar separated.
Definition: ss.h:9
TStr GetVal(const int &X, const int &Y) const
Definition: ss.cpp:16
static PSIn New(const TStr &FNm)
Definition: zipfl.cpp:122
const char * GetFld(const int &FldN) const
Returns the contents of the field at index FldN.
Definition: ss.h:129
TSsFmt
Spread-Sheet Separator Format.
Definition: ss.h:5
bool Empty() const
Tests whether the vector is empty.
Definition: ds.h:570
void SaveTxt(const TStr &FNm, const PNotify &Notify=NULL) const
Definition: ss.cpp:209
static PSs New()
Definition: ss.h:23
TVec< char * > FldV
Pointers to fields of the current line.
Definition: ss.h:81
static TSsFmt GetSsFmtFromStr(const TStr &SsFmtNm)
Definition: ss.cpp:315
static PSIn New(const TStr &FNm)
Definition: fl.cpp:290
static bool IsWs(const char &Ch)
Definition: dt.h:1063
TChA LineStr
Current line.
Definition: ss.h:80
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:1022
char * CStr()
Definition: dt.h:255
~TSsParser()
Definition: ss.cpp:374
virtual bool Eof()=0
Definition: ut.h:28
unsigned long long uint64
Definition: bd.h:38
int SearchY(const int &X, const TStr &Str) const
Definition: ss.cpp:55
const char * DumpStr() const
Definition: ss.cpp:508
static int GetNum(const char &Ch)
Definition: dt.h:1069
Whitespace (space or tab) separated.
Definition: ss.h:11
char LastCh() const
Definition: dt.h:281
const TVal & Last() const
Returns a reference to the last element of the vector.
Definition: ds.h:579
Tab separated.
Definition: ss.h:6
TStr GetLc() const
Definition: dt.h:502
int Len() const
Returns the number of fields in the current line.
Definition: ss.h:114
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...
Definition: ss.cpp:485
static TStr GetNullStr()
Definition: dt.cpp:1626
#define FailR(Reason)
Definition: bd.h:240
virtual void OnNotify(const TNotifyType &, const TStr &)
Definition: ut.h:38
void Trunc()
Definition: dt.cpp:420
Space separated.
Definition: ss.h:10
PSIn FInPt
Pointer to the input file stream.
Definition: ss.h:82
static bool IsZipExt(const TStr &FNmExt)
Check whether the file extension FNmExt is that of a compressed file (.gz, .7z, .rar, .zip, .cab, .arj. bzip2).
Definition: zipfl.cpp:199
void DelY(const int &Y)
Definition: ss.cpp:69
Definition: dt.h:201
TStr GetTrunc() const
Definition: dt.h:509
TVec< PStrV > CellStrVV
Definition: ss.h:20
Definition: dt.h:412
bool Empty() const
Definition: dt.h:491
static void LoadTxtFldV(const TSsFmt &SsFmt, const PSIn &SIn, char &Ch, TStrV &FldValV, const bool &IsExcelEoln=true, const bool &IsQStr=true)
Definition: ss.cpp:228
virtual void OnStatus(const TStr &)
Definition: ut.h:39
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
Definition: ut.h:28
int PutStr(const char *CStr)
Definition: fl.cpp:117
bool SkipCmt
Skip comments (lines starting with #).
Definition: ss.h:76
bool SkipLeadBlanks
Ignore leading whitespace characters in a line.
Definition: ss.h:75
bool Next()
Loads next line from the input file.
Definition: ss.cpp:412
Definition: bd.h:196
virtual char GetCh()=0
char SplitCh
Separator character (if one of the non-started separators is used)
Definition: ss.h:79
static TStr GetStrFromSsFmt(const TSsFmt &SsFmt)
Definition: ss.cpp:326
static TPt< PVec< TVal > > New()
Definition: ds.h:2184
char Pop()
Definition: dt.h:265
TStr & At(const int &X, const int &Y)
Definition: ss.cpp:3
virtual bool GetNextLnBf(TChA &LnChA)=0
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
void DelLast()
Removes the last element of the vector.
Definition: ds.h:665
int GetFldY(const TStr &FldNm, const TStr &NewFldNm="", const int &X=0) const
Definition: ss.cpp:88
bool SkipEmptyFld
Skip empty fields (i.e., multiple consecutive separators are considered as one).
Definition: ss.h:77
Definition: ss.h:5
int GetFldX(const TStr &FldNm, const TStr &NewFldNm="", const int &Y=0) const
Definition: ss.cpp:73
Comma separated.
Definition: ss.h:7
bool GetNextLn(TStr &LnStr)
Definition: fl.cpp:43
void PutVal(const int &X, const int &Y, const TStr &Str)
Definition: ss.cpp:10