SNAP Library, Developer Reference
2012-10-15 15:06:59
SNAP, a general purpose network analysis and graph mining library
|
Go to the source code of this file.
Enumerations | |
enum | TSsFmt { ssfUndef, ssfTabSep, ssfCommaSep, ssfSemicolonSep, ssfVBar, ssfSpaceSep, ssfWhiteSep, ssfMx } |
Functions | |
TSs () | |
static PSs | New () |
~TSs () | |
TSs (TSIn &SIn) | |
static PSs | Load (TSIn &SIn) |
void | Save (TSOut &SOut) |
TSs & | operator= (const TSs &Ss) |
TStr & | At (const int &X, const int &Y) |
void | PutVal (const int &X, const int &Y, const TStr &Str) |
TStr | GetVal (const int &X, const int &Y) const |
int | GetXLen () const |
int | GetXLen (const int &Y) const |
int | GetYLen () const |
void | DelX (const int &X) |
void | DelY (const int &Y) |
int | SearchX (const int &Y, const TStr &Str) const |
int | SearchY (const int &X, const TStr &Str) const |
int | GetFlds () const |
int | GetFldX (const TStr &FldNm, const TStr &NewFldNm="", const int &Y=0) const |
int | GetFldY (const TStr &FldNm, const TStr &NewFldNm="", const int &X=0) const |
TStr | GetFldNm (const int &FldX) const |
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) |
void | SaveTxt (const TStr &FNm, const PNotify &Notify=NULL) const |
static void | LoadTxtFldV (const TSsFmt &SsFmt, const PSIn &SIn, char &Ch, TStrV &FldValV, const bool &IsExcelEoln=true, const bool &IsQStr=true) |
static TSsFmt | GetSsFmtFromStr (const TStr &SsFmtNm) |
static TStr | GetStrFromSsFmt (const TSsFmt &SsFmt) |
static TStr | GetSsFmtNmVStr () |
UndefDefaultCopyAssign (TSsParser) | |
TSsParser (const TStr &FNm, const TSsFmt _SsFmt=ssfTabSep, const bool &_SkipLeadBlanks=false, const bool &_SkipCmt=true, const bool &_SkipEmptyFld=false) | |
TSsParser (const TStr &FNm, const char &Separator, const bool &_SkipLeadBlanks=false, const bool &_SkipCmt=true, const bool &_SkipEmptyFld=false) | |
~TSsParser () | |
static PSsParser | New (const TStr &FNm, const TSsFmt SsFmt) |
bool | Next () |
int | Len () const |
uint64 | GetLineNo () const |
bool | IsCmt () const |
bool | Eof () const |
const TChA & | GetLnStr () const |
void | ToLc () |
const char * | GetFld (const int &FldN) const |
const char * | operator[] (const int &FldN) const |
bool | GetInt (const int &FldN, int &Val) const |
int | GetInt (const int &FldN) const |
bool | IsInt (const int &FldN) const |
bool | GetFlt (const int &FldN, double &Val) const |
bool | IsFlt (const int &FldN) const |
double | GetFlt (const int &FldN) const |
const char * | DumpStr () const |
Variables | |
ClassTP(TSsParser, PSsParser) private bool | SkipLeadBlanks |
ClassTP(TSsParser, PSsParser) private bool | SkipCmt |
ClassTP(TSsParser, PSsParser) private bool | SkipEmptyFld |
uint64 | LineCnt |
char | SplitCh |
TChA | LineStr |
TVec< char * > | FldV |
PSIn | FInPt |
enum TSsFmt |
Referenced by TMAGFitBern::ComputeJointAdjLL(), TMAGFitBern::ComputeJointOneLL(), TVVec< TVal >::CopyFrom(), TVVec< TVal >::DelX(), TVVec< TVal >::DelY(), TVVec< TVal >::GetCol(), TVVec< TVal >::GetRow(), TMAGFitBern::NormalizeAffMtxV(), TMAGFitBern::RandomInit(), TMAGFitBern::SaveTxt(), TVVec< TVal >::SwapX(), TVVec< TVal >::SwapY(), TMAGFitBern::UnNormalizeAffMtxV(), and TMAGFitBern::UpdateAffMtxV().
void DelX | ( | const int & | X | ) |
void DelY | ( | const int & | Y | ) |
const char * TSsParser::DumpStr | ( | ) | const |
Definition at line 452 of file ss.cpp.
References TChA::Clr(), TChA::CStr(), FldV, and TStr::Fmt().
Referenced by GetInt().
{ static TChA ChA(10*1024); ChA.Clr(); for (int i = 0; i < FldV.Len(); i++) { ChA += TStr::Fmt(" %d: '%s'\n", i, FldV[i]); } return ChA.CStr(); }
bool Eof | ( | ) | const |
char * GetFld | ( | const int & | FldN | ) | const |
int GetFlds | ( | ) | const |
int TSs::GetFldX | ( | const TStr & | FldNm, |
const TStr & | NewFldNm = "" , |
||
const int & | Y = 0 |
||
) | const |
Definition at line 73 of file ss.cpp.
References TStr::Empty(), GetVal(), GetXLen(), and GetYLen().
{ if (GetYLen()>Y){ int XLen=GetXLen(Y); for (int X=0; X<XLen; X++){ if (GetVal(X, Y).GetTrunc()==FldNm){ if (!NewFldNm.Empty()){GetVal(X, Y)=NewFldNm;} return X; } } return -1; } else { return -1; } }
int TSs::GetFldY | ( | const TStr & | FldNm, |
const TStr & | NewFldNm = "" , |
||
const int & | X = 0 |
||
) | const |
Definition at line 88 of file ss.cpp.
References TStr::Empty(), TStr::GetTrunc(), GetVal(), GetXLen(), and GetYLen().
{ for (int Y=0; Y<GetYLen(); Y++){ if (GetXLen(Y)>X){ if (GetVal(X, Y).GetTrunc()==FldNm){ if (!NewFldNm.Empty()){GetVal(X, Y)=NewFldNm;} return Y; } } } return -1; }
bool GetFlt | ( | const int & | FldN, |
double & | Val | ||
) | const |
Referenced by GetFlt(), TMAGAffMtx::GetMtx(), TKronMtx::GetMtx(), IsFlt(), and TNcpGraphsBase::TNcpGraphsBase().
double GetFlt | ( | const int & | FldN | ) | const |
bool GetInt | ( | const int & | FldN, |
int & | Val | ||
) | const |
int GetInt | ( | const int & | FldN | ) | const |
TSsFmt TSs::GetSsFmtFromStr | ( | const TStr & | SsFmtNm | ) | [static] |
Definition at line 315 of file ss.cpp.
References TStr::GetLc(), ssfCommaSep, ssfSemicolonSep, ssfSpaceSep, ssfTabSep, ssfUndef, ssfVBar, and ssfWhiteSep.
{ TStr LcSsFmtNm=SsFmtNm.GetLc(); if (LcSsFmtNm=="tab"){return ssfTabSep;} else if (LcSsFmtNm=="comma"){return ssfCommaSep;} else if (LcSsFmtNm=="semicolon"){return ssfSemicolonSep;} else if (LcSsFmtNm=="vbar"){return ssfVBar;} else if (LcSsFmtNm=="space"){return ssfSpaceSep;} else if (LcSsFmtNm=="white"){return ssfWhiteSep;} else {return ssfUndef;} }
TStr TSs::GetSsFmtNmVStr | ( | ) | [static] |
TStr TSs::GetStrFromSsFmt | ( | const TSsFmt & | SsFmt | ) | [static] |
Definition at line 326 of file ss.cpp.
References ssfCommaSep, ssfSemicolonSep, ssfSpaceSep, ssfTabSep, ssfVBar, and ssfWhiteSep.
{ switch (SsFmt){ case ssfTabSep: return "tab"; case ssfCommaSep: return "comma"; case ssfSemicolonSep: return "semicolon"; case ssfVBar: return "vbar"; case ssfSpaceSep: return "space"; case ssfWhiteSep: return "white"; default: return "undef"; } }
Definition at line 157 of file url.h.
References THash< TKey, TDat, THashFunc >::GetDat(), KeyNmToValH, and KeyNmV.
Referenced by TVec< TVal >::AddMerged(), TVec< TVal >::AddUnique(), TVec< TVal >::Diff(), GetFldNm(), GetFldX(), GetFldY(), TVec< TVal >::GetSubValV(), TGStatVec::GetValV(), TVec< TVal >::Intrs(), TVec< TVal >::IntrsLen(), TVec< TVal >::NextPerm(), TGnuPlot::PlotValMomH(), TVec< TVal >::PrevPerm(), TVec< TVal >::SearchVForw(), SearchY(), and TVec< TVal >::Union().
{ return KeyNmToValH.GetDat(KeyNmV[KeyN])[ValN];}
int GetXLen | ( | ) | const |
int GetXLen | ( | const int & | Y | ) | const |
int GetYLen | ( | ) | const |
bool IsCmt | ( | ) | const |
bool IsFlt | ( | const int & | FldN | ) | const |
bool IsInt | ( | const int & | FldN | ) | const |
Definition at line 90 of file ss.h.
References GetInt().
Referenced by TEnv::GetIfArgPrefixIntV(), TUInt::GetUIntFromIpStr(), and TUInt::IsIpStr().
{ int v; return GetInt(FldN, v); }
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 |
||
) | [static] |
void TSs::LoadTxtFldV | ( | const TSsFmt & | SsFmt, |
const PSIn & | SIn, | ||
char & | Ch, | ||
TStrV & | FldValV, | ||
const bool & | IsExcelEoln = true , |
||
const bool & | IsQStr = true |
||
) | [static] |
Definition at line 228 of file ss.cpp.
References TVec< TVal >::Add(), TChA::Clr(), TVec< TVal >::Clr(), TChA::Empty(), TSIn::Eof(), Fail, forever, TSIn::GetCh(), TChA::LastCh(), TCh::NullCh, TChA::Pop(), ssfCommaSep, ssfSemicolonSep, ssfTabSep, ssfVBar, and TChA::Trunc().
{ if (!SIn->Eof()){ FldValV.Clr(false); int X=0; if (Ch==TCh::NullCh){Ch=SIn->GetCh();} TChA ChA; while (!SIn->Eof()){ // compose value ChA.Clr(); if (IsQStr&&(Ch=='"')){ // quoted string ('""' sequence means '"') Ch=SIn->GetCh(); forever { while ((!SIn->Eof())&&(Ch!='"')){ ChA+=Ch; Ch=SIn->GetCh();} if (Ch=='"'){ Ch=SIn->GetCh(); if (Ch=='"'){ChA+=Ch; Ch=SIn->GetCh();} else {break;} } } } else { if (SsFmt==ssfTabSep){ while ((!SIn->Eof())&&(Ch!='\t')&&(Ch!='\r')&& ((Ch!='\n')||IsExcelEoln)){ ChA+=Ch; Ch=SIn->GetCh(); } if ((!ChA.Empty())&&(ChA.LastCh()=='\"')){ ChA.Pop();} } else if (SsFmt==ssfCommaSep){ while ((!SIn->Eof())&&(Ch!=',')&&(Ch!='\r')&& ((Ch!='\n')||IsExcelEoln)){ ChA+=Ch; Ch=SIn->GetCh(); } } else if (SsFmt==ssfSemicolonSep){ while ((!SIn->Eof())&&(Ch!=';')&&(Ch!='\r')&& ((Ch!='\n')||IsExcelEoln)){ ChA+=Ch; Ch=SIn->GetCh(); } } else if (SsFmt==ssfVBar){ while ((!SIn->Eof())&&(Ch!='|')&&(Ch!='\r')&& ((Ch!='\n')||IsExcelEoln)){ ChA+=Ch; Ch=SIn->GetCh(); } } else { Fail; } } // add value to spreadsheet ChA.Trunc(); FldValV.Add(ChA); // process delimiters if (SIn->Eof()){ break; } else if ((SsFmt==ssfTabSep)&&(Ch=='\t')){ X++; Ch=SIn->GetCh(); } else if ((SsFmt==ssfCommaSep)&&(Ch==',')){ X++; Ch=SIn->GetCh(); } else if ((SsFmt==ssfSemicolonSep)&&(Ch==';')){ X++; Ch=SIn->GetCh(); } else if ((SsFmt==ssfVBar)&&(Ch=='|')){ X++; Ch=SIn->GetCh(); } else if (Ch=='\r'){ Ch=SIn->GetCh(); if ((Ch=='\n')&&(!SIn->Eof())){Ch=SIn->GetCh();} break; } else if (Ch=='\n'){ X=0; Ch=SIn->GetCh(); if ((Ch=='\r')&&(!SIn->Eof())){Ch=SIn->GetCh();} break; } else { Fail; } } } }
static PSs New | ( | ) | [static] |
Definition at line 72 of file ss.h.
References TSsParser().
{ return new TSsParser(FNm, SsFmt); }
bool Next | ( | ) |
Definition at line 58 of file xfl.h.
Referenced by TBreathFS< PGraph >::GetRndPath(), Next(), TVec< TVal >::NextPerm(), TVec< TVal >::PrevPerm(), and THash< TKey, TDat, THashFunc >::Sort().
const char* operator[] | ( | const int & | FldN | ) | const |
int TSs::SearchX | ( | const int & | Y, |
const TStr & | Str | ||
) | const |
int TSs::SearchY | ( | const int & | X, |
const TStr & | Str | ||
) | const |
void ToLc | ( | ) |
TSs | ( | ) |
TSsParser::TSsParser | ( | const TStr & | FNm, |
const TSsFmt | _SsFmt = ssfTabSep , |
||
const bool & | _SkipLeadBlanks = false , |
||
const bool & | _SkipCmt = true , |
||
const bool & | _SkipEmptyFld = false |
||
) |
Definition at line 351 of file ss.cpp.
References FailR, FInPt, TStr::GetFExt(), TZipIn::IsZipExt(), TZipIn::New(), TFIn::New(), SplitCh, ssfCommaSep, ssfSemicolonSep, ssfSpaceSep, ssfTabSep, ssfVBar, and ssfWhiteSep.
Referenced by TSnap::LoadConnList(), TSnap::LoadConnListStr(), TSnap::LoadEdgeList(), TSnap::LoadEdgeListStr(), TTimeNENet::LoadEdgeTm(), TTimeNENet::LoadFlickr(), TSnap::LoadPajek(), New(), and TNcpGraphsBase::TNcpGraphsBase().
: SsFmt(_SsFmt), SkipLeadBlanks(_SkipLeadBlanks), SkipCmt(_SkipCmt), SkipEmptyFld(_SkipEmptyFld), LineCnt(0), /*Bf(NULL),*/ SplitCh('\t'), FldV(), FInPt(NULL) { if (TZipIn::IsZipExt(FNm.GetFExt())) { FInPt = TZipIn::New(FNm); } else { FInPt = TFIn::New(FNm); } //Bf = new char [BfLen]; switch(SsFmt) { case ssfTabSep : SplitCh = '\t'; break; case ssfCommaSep : SplitCh = ','; break; case ssfSemicolonSep : SplitCh = ';'; break; case ssfVBar : SplitCh = '|'; break; case ssfSpaceSep : SplitCh = ' '; break; case ssfWhiteSep: SplitCh = ' '; break; default: FailR("Unknown separator character."); } }
TSsParser::TSsParser | ( | const TStr & | FNm, |
const char & | Separator, | ||
const bool & | _SkipLeadBlanks = false , |
||
const bool & | _SkipCmt = true , |
||
const bool & | _SkipEmptyFld = false |
||
) |
Definition at line 367 of file ss.cpp.
References FInPt, TStr::GetFExt(), TZipIn::IsZipExt(), TZipIn::New(), TFIn::New(), and SplitCh.
: SsFmt(ssfSpaceSep), SkipLeadBlanks(_SkipLeadBlanks), SkipCmt(_SkipCmt), SkipEmptyFld(_SkipEmptyFld), LineCnt(0), /*Bf(NULL),*/ SplitCh('\t'), FldV(), FInPt(NULL) { if (TZipIn::IsZipExt(FNm.GetFExt())) { FInPt = TZipIn::New(FNm); } else { FInPt = TFIn::New(FNm); } SplitCh = Separator; }
Definition at line 65 of file ss.h.
Referenced by DumpStr(), TSecTm::GetDtTmFromStr(), GetFld(), Len(), and operator[]().
Definition at line 62 of file ss.h.
Referenced by GetLineNo(), and TTimeNENet::LoadEdgeTm().
Definition at line 64 of file ss.h.
Referenced by GetLnStr().
ClassTP (TSsParser, PSsParser) private bool SkipEmptyFld |
ClassTP (TSsParser, PSsParser) private bool SkipLeadBlanks |
char SplitCh |
Definition at line 63 of file ss.h.
Referenced by TUInt::IsIpStr(), and TSsParser().