SNAP Library 2.3, Developer Reference
2014-06-16 11:58:46
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <ss.h>
Public Member Functions | |
TSsParser (const TStr &FNm, const TSsFmt _SsFmt=ssfTabSep, const bool &_SkipLeadBlanks=false, const bool &_SkipCmt=true, const bool &_SkipEmptyFld=false) | |
Constructor. More... | |
TSsParser (const TStr &FNm, const char &Separator, const bool &_SkipLeadBlanks=false, const bool &_SkipCmt=true, const bool &_SkipEmptyFld=false) | |
Constructor. More... | |
~TSsParser () | |
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... | |
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... | |
const char * | DumpStr () const |
Static Public Member Functions | |
static PSsParser | New (const TStr &FNm, const TSsFmt SsFmt) |
Private Member Functions | |
UndefDefaultCopyAssign (TSsParser) | |
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... | |
PSIn | FInPt |
Pointer to the input file stream. More... | |
Friends | |
class | TPt< TSsParser > |
TSsParser::TSsParser | ( | 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. |
Definition at line 351 of file ss.cpp.
References FailR, FInPt, TStr::GetFExt(), TZipIn::IsZipExt(), TZipIn::New(), TFIn::New(), SplitCh, ssfCommaSep, SsFmt, ssfSemicolonSep, ssfSpaceSep, ssfTabSep, ssfVBar, and ssfWhiteSep.
TSsParser::TSsParser | ( | 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 367 of file ss.cpp.
References FInPt, TStr::GetFExt(), TZipIn::IsZipExt(), TZipIn::New(), TFIn::New(), and SplitCh.
TSsParser::~TSsParser | ( | ) |
const char * TSsParser::DumpStr | ( | ) | const |
Definition at line 484 of file ss.cpp.
References TChA::Clr(), TChA::CStr(), FldV, TStr::Fmt(), and TVec< TVal, TSizeTy >::Len().
|
inline |
Checks for end of file.
Definition at line 122 of file ss.h.
Referenced by TSnap::LoadPajek().
|
inline |
Returns the contents of the field at index FldN
.
Definition at line 129 of file ss.h.
Referenced by GetFlt(), GetInt(), TAGMUtil::LoadCmtyVV(), TTimeNENet::LoadEdgeTm(), and TCesnaUtil::LoadNIDAttrHFromNIDKH().
|
inline |
|
inline |
Returns the number of fields in the current line.
Definition at line 116 of file ss.h.
Referenced by TAGMUtil::LoadCmtyVV(), and TNcpGraphsBase::TNcpGraphsBase().
bool TSsParser::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 462 of file ss.cpp.
References GetFld(), TCh::IsNum(), and TCh::IsWs().
Referenced by TNcpGraphsBase::TNcpGraphsBase().
|
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 148 of file ss.h.
References IAssert.
bool TSsParser::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 443 of file ss.cpp.
References GetFld(), TCh::GetNum(), TCh::IsNum(), and TCh::IsWs().
Referenced by TAGMUtil::LoadCmtyVV(), TSnap::LoadConnList(), TSnap::LoadEdgeList(), TTimeNENet::LoadFlickr(), TCesnaUtil::LoadNIDAttrHFromNIDKH(), and TSnap::LoadPajek().
|
inline |
Assumes FldN
is an integer its value is returned. If FldN
is not an integer an exception is thrown.
Definition at line 139 of file ss.h.
References TStr::Fmt(), and IAssertR.
|
inline |
Returns the line number of the current line.
Definition at line 118 of file ss.h.
Referenced by TTimeNENet::LoadFlickr(), and TCesnaUtil::LoadNIDAttrHFromNIDKH().
|
inline |
|
inline |
Checks whether the current line is a comment (starts with '#').
Definition at line 120 of file ss.h.
Referenced by TTimeNENet::LoadEdgeTm().
|
inline |
Checks whether fields FldN
is a float.
Definition at line 146 of file ss.h.
Referenced by TNcpGraphsBase::TNcpGraphsBase().
|
inline |
Checks whether fields FldN
is an integer.
Definition at line 142 of file ss.h.
Referenced by TAGMUtil::LoadCmtyVV(), TSnap::LoadConnList(), and TSnap::LoadPajek().
|
inline |
Returns the number of fields in the current line.
Definition at line 114 of file ss.h.
Referenced by TSnap::LoadConnList(), TSnap::LoadConnListStr(), TTimeNENet::LoadEdgeTm(), and TSnap::LoadPajek().
Definition at line 102 of file ss.h.
bool TSsParser::Next | ( | ) |
Loads next line from the input file.
If end of file is reached, return value is false
.
Definition at line 410 of file ss.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, TSIn::GetNextLnBf(), TCh::IsWs(), TVec< TVal, TSizeTy >::Last(), LineCnt, LineStr, SkipCmt, SkipEmptyFld, SkipLeadBlanks, SplitCh, SsFmt, and ssfWhiteSep.
Referenced by TAGMUtil::LoadCmtyVV(), TSnap::LoadConnList(), TSnap::LoadConnListStr(), TSnap::LoadEdgeList(), TSnap::LoadEdgeListStr(), TAGMUtil::LoadEdgeListStr(), TTimeNENet::LoadEdgeTm(), TTimeNENet::LoadFlickr(), TCesnaUtil::LoadNIDAttrHFromNIDKH(), TSnap::LoadPajek(), and TNcpGraphsBase::TNcpGraphsBase().
bool TSsParser::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.
Definition at line 382 of file ss.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, TSIn::GetNextLn(), TCh::IsWs(), TVec< TVal, TSizeTy >::Last(), LineCnt, LineStr, SkipCmt, SkipEmptyFld, SkipLeadBlanks, SplitCh, SsFmt, and ssfWhiteSep.
|
inline |
|
inline |
void TSsParser::ToLc | ( | ) |
Transforms the current line to lower case.
Definition at line 436 of file ss.cpp.
References FldV, and TVec< TVal, TSizeTy >::Len().
Referenced by TSnap::LoadPajek().
|
private |
|
private |
Pointer to the input file stream.
Definition at line 82 of file ss.h.
Referenced by Next(), NextSlow(), and TSsParser().
|
private |
|
private |
Number of processed lines so far.
Definition at line 78 of file ss.h.
Referenced by Next(), and NextSlow().
|
private |
|
private |
Skip comments (lines starting with #).
Definition at line 76 of file ss.h.
Referenced by Next(), and NextSlow().
|
private |
Skip empty fields (i.e., multiple consecutive separators are considered as one).
Definition at line 77 of file ss.h.
Referenced by Next(), and NextSlow().
|
private |
Ignore leading whitespace characters in a line.
Definition at line 75 of file ss.h.
Referenced by Next(), and NextSlow().
|
private |
Separator character (if one of the non-started separators is used)
Definition at line 79 of file ss.h.
Referenced by Next(), NextSlow(), and TSsParser().
|
private |
Separator type.
Definition at line 74 of file ss.h.
Referenced by Next(), NextSlow(), and TSsParser().