SNAP Library 2.4, User Reference  2015-05-11 19:40:56
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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  FldV.Add(last); // add last field
404  if (SkipEmptyFld && FldV.Empty()) { return NextSlow(); } // skip empty lines
405  return true;
406 }
407 
408 // Gets and parses the next line, quick version, works with buffers, not chars.
409 
410 bool TSsParser::Next() { // split on SplitCh
411  FldV.Clr(false);
412  LineStr.Clr();
413  FldV.Clr();
414  LineCnt++;
415  if (! FInPt->GetNextLnBf(LineStr)) { return false; }
416  if (SkipCmt && !LineStr.Empty() && LineStr[0]=='#') { return Next(); }
417 
418  char* cur = LineStr.CStr();
419  if (SkipLeadBlanks) { // skip leading blanks
420  while (*cur && TCh::IsWs(*cur)) { cur++; }
421  }
422  char *last = cur;
423  while (*cur) {
424  if (SsFmt == ssfWhiteSep) { while (*cur && ! TCh::IsWs(*cur)) { cur++; } }
425  else { while (*cur && *cur!=SplitCh) { cur++; } }
426  if (*cur == 0) { break; }
427  *cur = 0; cur++;
428  FldV.Add(last); last = cur;
429  if (SkipEmptyFld && strlen(FldV.Last())==0) { FldV.DelLast(); } // skip empty fields
430  }
431  FldV.Add(last); // add last field
432  if (SkipEmptyFld && FldV.Empty()) { return Next(); } // skip empty lines
433  return true;
434 }
435 
437  for (int f = 0; f < FldV.Len(); f++) {
438  for (char *c = FldV[f]; *c; c++) {
439  *c = tolower(*c); }
440  }
441 }
442 
443 bool TSsParser::GetInt(const int& FldN, int& Val) const {
444  // parsing format {ws} [+/-] +{ddd}
445  int _Val = -1;
446  bool Minus=false;
447  const char *c = GetFld(FldN);
448  while (TCh::IsWs(*c)) { c++; }
449  if (*c=='-') { Minus=true; c++; }
450  if (! TCh::IsNum(*c)) { return false; }
451  _Val = TCh::GetNum(*c); c++;
452  while (TCh::IsNum(*c)){
453  _Val = 10 * _Val + TCh::GetNum(*c);
454  c++;
455  }
456  if (Minus) { _Val = -_Val; }
457  if (*c != 0) { return false; }
458  Val = _Val;
459  return true;
460 }
461 
462 bool TSsParser::GetFlt(const int& FldN, double& Val) const {
463  // parsing format {ws} [+/-] +{d} ([.]{d}) ([E|e] [+/-] +{d})
464  const char *c = GetFld(FldN);
465  while (TCh::IsWs(*c)) { c++; }
466  if (*c=='+' || *c=='-') { c++; }
467  if (! TCh::IsNum(*c) && *c!='.') { return false; }
468  while (TCh::IsNum(*c)) { c++; }
469  if (*c == '.') {
470  c++;
471  while (TCh::IsNum(*c)) { c++; }
472  }
473  if (*c=='e' || *c == 'E') {
474  c++;
475  if (*c == '+' || *c == '-' ) { c++; }
476  if (! TCh::IsNum(*c)) { return false; }
477  while (TCh::IsNum(*c)) { c++; }
478  }
479  if (*c != 0) { return false; }
480  Val = atof(GetFld(FldN));
481  return true;
482 }
483 
484 const char* TSsParser::DumpStr() const {
485  static TChA ChA(10*1024);
486  ChA.Clr();
487  for (int i = 0; i < FldV.Len(); i++) {
488  ChA += TStr::Fmt(" %d: '%s'\n", i, FldV[i]);
489  }
490  return ChA.CStr();
491 }
492 
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
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:972
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:782
#define forever
Definition: bd.h:6
static int GetMx(const int &Int1, const int &Int2)
Definition: dt.h:1090
bool Empty() const
Definition: dt.h:260
#define Fail
Definition: bd.h:238
static const char NullCh
Definition: dt.h:943
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:535
uint64 LineCnt
Number of processed lines so far.
Definition: ss.h:78
void ToLc()
Transforms the current line to lower case.
Definition: ss.cpp:436
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:443
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:124
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:530
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:968
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:953
char * CStr()
Definition: dt.h:255
~TSsParser()
Definition: ss.cpp:374
virtual bool Eof()=0
Definition: ut.h:28
int SearchY(const int &X, const TStr &Str) const
Definition: ss.cpp:55
const char * DumpStr() const
Definition: ss.cpp:484
static int GetNum(const char &Ch)
Definition: dt.h:974
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:539
Tab separated.
Definition: ss.h:6
TStr GetLc() const
Definition: dt.h:499
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:462
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:201
void DelY(const int &Y)
Definition: ss.cpp:69
Definition: dt.h:201
TStr GetTrunc() const
Definition: dt.h:506
TVec< PStrV > CellStrVV
Definition: ss.h:20
Definition: dt.h:412
bool Empty() const
Definition: dt.h:488
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:410
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:2070
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:559
void DelLast()
Removes the last element of the vector.
Definition: ds.h:609
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