|
SNAP Library 4.1, Developer Reference
2018-07-26 16:30:42
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <ssmp.h>

Public Member Functions | |
| TSsParserMP (const TStr &FNm, const TSsFmt _SsFmt=ssfTabSep, const bool &_SkipLeadBlanks=false, const bool &_SkipCmt=true, const bool &_SkipEmptyFld=false) | |
| Constructor. More... | |
| TSsParserMP (const TStr &FNm, const char &Separator, const bool &_SkipLeadBlanks=false, const bool &_SkipCmt=true, const bool &_SkipEmptyFld=false) | |
| Constructor. More... | |
| ~TSsParserMP () | |
| bool | Next () |
| Loads next line from the input file. More... | |
| bool | NextSlow () |
| Loads next line from the input file (older, slow implementation - deprecated). More... | |
| int | Len () const |
| Returns the number of fields in the current line. More... | |
| int | GetFlds () const |
| Returns the number of fields in the current line. More... | |
| uint64 | GetLineNo () const |
| Returns the line number of the current line. More... | |
| bool | IsCmt () const |
| Checks whether the current line is a comment (starts with '#'). More... | |
| void | SkipCommentLines () |
| Skips lines that begin with a comment character. More... | |
| bool | Eof () const |
| Checks for end of file. More... | |
| TChA | GetLnStr () const |
| Returns the current line. More... | |
| void | ToLc () |
| Transforms the current line to lower case. More... | |
| const char * | GetFld (const int &FldN) const |
Returns the contents of the field at index FldN. More... | |
| char * | GetFld (const int &FldN) |
Returns the contents of the field at index FldN. More... | |
| const char * | operator[] (const int &FldN) const |
Returns the contents of the field at index FldN. More... | |
| char * | operator[] (const int &FldN) |
Returns the contents of the field at index FldN. More... | |
| 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. More... | |
| int | GetInt (const int &FldN) const |
Assumes FldN is an integer its value is returned. If FldN is not an integer an exception is thrown. More... | |
| bool | IsInt (const int &FldN) const |
Checks whether fields FldN is an integer. More... | |
| 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. More... | |
| bool | IsFlt (const int &FldN) const |
Checks whether fields FldN is a float. More... | |
| double | GetFlt (const int &FldN) const |
Assumes FldN is a floating point number its value is returned. If FldN is not an integer an exception is thrown. More... | |
| uint64 | GetStreamPos () const |
| Returns position of stream pointer. More... | |
| uint64 | GetStreamLen () const |
| Returns length of stream. More... | |
| void | SetStreamPos (uint64 Pos) |
| Sets position of stream pointer. More... | |
| uint64 | CountNewLinesInRange (uint64 Lb, uint64 Ub) const |
| Counts number of occurences of ' ' in [Lb, Ub) More... | |
| TVec< uint64 > | GetStartPosV (uint64 Lb, uint64 Ub) const |
| Finds start positions of all lines ending somewhere in [Lb, Ub) More... | |
| void | NextFromIndex (uint64 Index, TVec< char * > &FieldsV) |
| Loads next line starting from a given position. More... | |
| int | GetIntFromFldV (TVec< char * > &FieldsV, const int &FldN) |
Gets integer at field FldN. More... | |
| double | GetFltFromFldV (TVec< char * > &FieldsV, const int &FldN) |
Gets float at field FldN. More... | |
| const char * | DumpStr () const |
Static Public Member Functions | |
| static PSsParserMP | New (const TStr &FNm, const TSsFmt SsFmt) |
Private Member Functions | |
| UndefDefaultCopyAssign (TSsParserMP) | |
Private Attributes | |
| TCRef | CRef |
| TSsFmt | SsFmt |
| Separator type. More... | |
| bool | SkipLeadBlanks |
| Ignore leading whitespace characters in a line. More... | |
| bool | SkipCmt |
| Skip comments (lines starting with #). More... | |
| bool | SkipEmptyFld |
| Skip empty fields (i.e., multiple consecutive separators are considered as one). More... | |
| uint64 | LineCnt |
| Number of processed lines so far. More... | |
| char | SplitCh |
| Separator character (if one of the non-started separators is used) More... | |
| TChA | LineStr |
| Current line. More... | |
| TVec< char * > | FldV |
| Pointers to fields of the current line. More... | |
| TPt< TMIn > | FInPt |
| Pointer to the input file stream. More... | |
Friends | |
| class | TPt< TSsParserMP > |
| TSsParserMP::TSsParserMP | ( | const TStr & | FNm, |
| const TSsFmt | _SsFmt = ssfTabSep, |
||
| const bool & | _SkipLeadBlanks = false, |
||
| const bool & | _SkipCmt = true, |
||
| const bool & | _SkipEmptyFld = false |
||
| ) |
Constructor.
| FNm | Input filename. Can be a text file or a compressed file. |
| _SsFmt | Spread-sheet separator format. Each line will be broken in a set of fields, where the boundary between the fields is defined by the _SsFmt. |
| _SkipLeadBlanks | If true leading/trailing white-spaces of the line will be ignored. |
| _SkipCmt | If true lines starting with '#' will be considered as comments and will be skipped. |
| _SkipEmptyFld | If true then empty fields (consecutive occurrences of the separator) will be ignored. |
| TSsParserMP::TSsParserMP | ( | const TStr & | FNm, |
| const char & | Separator, | ||
| const bool & | _SkipLeadBlanks = false, |
||
| const bool & | _SkipCmt = true, |
||
| const bool & | _SkipEmptyFld = false |
||
| ) |
Constructor.
| FNm | Input filename. Can be a text file or a compressed file. |
| Separator | Spread-sheet separator character. Each line will be broken in a set of fields, where the boundary between the fields is the Separator character. |
| _SkipLeadBlanks | If true leading/trailing white-spaces of the line will be ignored. |
| _SkipCmt | If true lines starting with '#' will be considered as comments and will be skipped. |
| _SkipEmptyFld | If true then empty fields (consecutive occurrences of the separator) will be ignored. |
Definition at line 3 of file ssmp.cpp.
References FInPt, TMIn::New(), and SplitCh.

Counts number of occurences of '
' in [Lb, Ub)
Definition at line 102 of file ssmp.cpp.
References TMIn::CountNewLinesInRange(), and FInPt.
Referenced by TTable::LoadSSPar().


| const char * TSsParserMP::DumpStr | ( | ) | const |
Definition at line 91 of file ssmp.cpp.
References TChA::Clr(), TChA::CStr(), FldV, TStr::Fmt(), and TVec< TVal, TSizeTy >::Len().

|
inline |
|
inline |
|
inline |
|
inline |
Returns the number of fields in the current line.
Definition at line 51 of file ssmp.h.
Referenced by TTable::LoadSSPar().

| bool TSsParserMP::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 at line 69 of file ssmp.cpp.
References GetFld(), TCh::IsNum(), and TCh::IsWs().

|
inline |
Assumes FldN is a floating point number its value is returned. If FldN is not an integer an exception is thrown.
Definition at line 85 of file ssmp.h.
References IAssert.
| double TSsParserMP::GetFltFromFldV | ( | TVec< char * > & | FieldsV, |
| const int & | FldN | ||
| ) |
Gets float at field FldN.
Definition at line 170 of file ssmp.cpp.
References TCh::IsNum(), and TCh::IsWs().
Referenced by TTable::LoadSSPar().


| bool TSsParserMP::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 at line 50 of file ssmp.cpp.
References GetFld(), TCh::GetNum(), TCh::IsNum(), and TCh::IsWs().

|
inline |
Assumes FldN is an integer its value is returned. If FldN is not an integer an exception is thrown.
Definition at line 76 of file ssmp.h.
References TStr::Fmt(), and IAssertR.

| int TSsParserMP::GetIntFromFldV | ( | TVec< char * > & | FieldsV, |
| const int & | FldN | ||
| ) |
Gets integer at field FldN.
Definition at line 152 of file ssmp.cpp.
References TCh::GetNum(), TCh::IsNum(), and TCh::IsWs().
Referenced by TTable::LoadSSPar().


|
inline |
|
inline |
Returns the current line.
Definition at line 61 of file ssmp.h.
References TChA::DelLastCh(), and TChA::Len().

Finds start positions of all lines ending somewhere in [Lb, Ub)
Definition at line 106 of file ssmp.cpp.
References TVec< TVal, TSizeTy >::Add(), FInPt, TMIn::GetLineEndPos(), TMIn::GetLineStartPos(), and GetStreamLen().
Referenced by TTable::LoadSSPar().


|
inline |
Returns length of stream.
Definition at line 93 of file ssmp.h.
Referenced by GetStartPosV(), and TTable::LoadSSPar().

|
inline |
Returns position of stream pointer.
Definition at line 89 of file ssmp.h.
Referenced by TTable::LoadSSPar().

|
inline |
Checks whether the current line is a comment (starts with '#').
|
inline |
Checks whether fields FldN is a float.
Definition at line 83 of file ssmp.h.
|
inline |
Checks whether fields FldN is an integer.
Definition at line 79 of file ssmp.h.
|
inline |
Returns the number of fields in the current line.
|
inlinestatic |
| bool TSsParserMP::Next | ( | ) |
Loads next line from the input file.
If end of file is reached, return value is false.
Definition at line 17 of file ssmp.cpp.
References TVec< TVal, TSizeTy >::Add(), TChA::Clr(), TVec< TVal, TSizeTy >::Clr(), TChA::CStr(), TVec< TVal, TSizeTy >::DelLast(), TChA::Empty(), TVec< TVal, TSizeTy >::Empty(), FInPt, FldV, TMIn::GetNextLnBf(), TCh::IsWs(), TVec< TVal, TSizeTy >::Last(), LineCnt, LineStr, SkipCmt, SkipEmptyFld, SkipLeadBlanks, SplitCh, SsFmt, and ssfWhiteSep.
Referenced by TTable::LoadSSPar().


Loads next line starting from a given position.
Definition at line 128 of file ssmp.cpp.
References TVec< TVal, TSizeTy >::Add(), TVec< TVal, TSizeTy >::Clr(), TVec< TVal, TSizeTy >::DelLast(), FInPt, TMIn::GetLine(), TCh::IsWs(), TVec< TVal, TSizeTy >::Last(), SkipEmptyFld, SkipLeadBlanks, SplitCh, SsFmt, and ssfWhiteSep.
Referenced by TTable::LoadSSPar().


| bool TSsParserMP::NextSlow | ( | ) |
Loads next line from the input file (older, slow implementation - deprecated).
If end of file is reached, return value is false. This function is deprecated, use Next instead.
|
inline |
|
inline |
|
inline |
Sets position of stream pointer.
Definition at line 97 of file ssmp.h.
Referenced by TTable::LoadSSPar().

| void TSsParserMP::SkipCommentLines | ( | ) |
Skips lines that begin with a comment character.
Definition at line 12 of file ssmp.cpp.
References FInPt, and TMIn::SkipCommentLines().
Referenced by TTable::LoadSSPar().


| void TSsParserMP::ToLc | ( | ) |
Transforms the current line to lower case.
Definition at line 43 of file ssmp.cpp.
References FldV, and TVec< TVal, TSizeTy >::Len().

|
private |
|
friend |
Pointer to the input file stream.
Definition at line 17 of file ssmp.h.
Referenced by CountNewLinesInRange(), GetStartPosV(), Next(), NextFromIndex(), SkipCommentLines(), and TSsParserMP().
|
private |
|
private |
|
private |
|
private |
|
private |
Skip empty fields (i.e., multiple consecutive separators are considered as one).
Definition at line 12 of file ssmp.h.
Referenced by Next(), and NextFromIndex().
|
private |
Ignore leading whitespace characters in a line.
Definition at line 10 of file ssmp.h.
Referenced by Next(), and NextFromIndex().
|
private |
Separator character (if one of the non-started separators is used)
Definition at line 14 of file ssmp.h.
Referenced by Next(), NextFromIndex(), and TSsParserMP().
|
private |