SNAP Library, Developer Reference  2012-10-15 15:06:59
SNAP, a general purpose network analysis and graph mining library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ss.h File Reference
This graph shows which files directly or indirectly include this file:

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)
TSsoperator= (const TSs &Ss)
TStrAt (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 TChAGetLnStr () 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

Enumeration Type Documentation

enum TSsFmt
Enumerator:
ssfUndef 
ssfTabSep 
ssfCommaSep 
ssfSemicolonSep 
ssfVBar 
ssfSpaceSep 
ssfWhiteSep 
ssfMx 

Definition at line 3 of file ss.h.


Function Documentation

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();
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool Eof ( ) const

Definition at line 79 of file ss.h.

References TSIn::Eof(), and FInPt.

{ return FInPt->Eof(); }

Here is the call graph for this function:

char * GetFld ( const int &  FldN) const

Definition at line 83 of file ss.h.

References FldV.

Referenced by IsCmt().

{ return FldV[FldN]; }

Here is the caller graph for this function:

TStr GetFldNm ( const int &  FldX) const

Definition at line 38 of file ss.h.

References GetVal().

{return GetVal(FldX, 0);}

Here is the call graph for this function:

int GetFlds ( ) const

Definition at line 35 of file ss.h.

References GetXLen().

{return GetXLen(0);}

Here is the call graph for this function:

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;
  }
}

Here is the call graph for this function:

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;
}

Here is the call graph for this function:

bool GetFlt ( const int &  FldN,
double &  Val 
) const

Referenced by GetFlt(), TMAGAffMtx::GetMtx(), TKronMtx::GetMtx(), IsFlt(), and TNcpGraphsBase::TNcpGraphsBase().

Here is the caller graph for this function:

double GetFlt ( const int &  FldN) const

Definition at line 93 of file ss.h.

References GetFlt(), and IAssert.

                                       {
    double Val=0.0; IAssert(GetFlt(FldN, Val)); return Val; }

Here is the call graph for this function:

bool GetInt ( const int &  FldN,
int &  Val 
) const
int GetInt ( const int &  FldN) const

Definition at line 88 of file ss.h.

References DumpStr(), TStr::Fmt(), GetInt(), and IAssertR.

                                    {
    int Val=0; IAssertR(GetInt(FldN, Val), TStr::Fmt("Field %d not INT.\n%s", FldN, DumpStr()).CStr()); return Val; }

Here is the call graph for this function:

uint64 GetLineNo ( ) const

Definition at line 77 of file ss.h.

References LineCnt.

{ return LineCnt; }
const TChA& GetLnStr ( ) const

Definition at line 80 of file ss.h.

References LineStr.

{ return LineStr; }
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;}
}

Here is the call graph for this function:

TStr TSs::GetSsFmtNmVStr ( ) [static]

Definition at line 338 of file ss.cpp.

                        {
  TChA ChA;
  ChA+='(';
  ChA+="tab"; ChA+=", ";
  ChA+="comma"; ChA+=", ";
  ChA+="semicolon"; ChA+=", ";
  ChA+="space"; ChA+=", ";
  ChA+="white"; ChA+=")";
  return ChA;
}
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";
  }
}
int GetXLen ( ) const

Referenced by GetFlds(), GetFldX(), and GetFldY().

Here is the caller graph for this function:

int GetXLen ( const int &  Y) const
int GetYLen ( ) const

Referenced by GetFldX(), GetFldY(), and SearchY().

Here is the caller graph for this function:

bool IsCmt ( ) const

Definition at line 78 of file ss.h.

References GetFld(), and Len().

{ return Len()>0 && GetFld(0)[0] == '#'; }

Here is the call graph for this function:

bool IsFlt ( const int &  FldN) const

Definition at line 92 of file ss.h.

References GetFlt().

{ double v; return GetFlt(FldN, v); }

Here is the call graph for this function:

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); }

Here is the call graph for this function:

Here is the caller graph for this function:

int Len ( ) const

Definition at line 75 of file ss.h.

References FldV.

{ return FldV.Len(); }
static PSs Load ( TSIn SIn) [static]

Definition at line 14 of file ss.h.

References TSs().

{return new TSs(SIn);}

Here is the call graph for this function:

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;
      }
    }
  }
}

Here is the call graph for this function:

static PSs New ( ) [static]

Definition at line 11 of file ss.h.

References TSs().

{return PSs(new TSs());}

Here is the call graph for this function:

static PSsParser New ( const TStr FNm,
const TSsFmt  SsFmt 
) [static]

Definition at line 72 of file ss.h.

References TSsParser().

{ return new TSsParser(FNm, SsFmt); }

Here is the call graph for this function:

bool Next ( )

Definition at line 58 of file xfl.h.

References FNm, and Next().

Referenced by TBreathFS< PGraph >::GetRndPath(), Next(), TVec< TVal >::NextPerm(), TVec< TVal >::PrevPerm(), and THash< TKey, TDat, THashFunc >::Sort().

{TStr FNm; return Next(FNm);}

Here is the call graph for this function:

Here is the caller graph for this function:

TSs& operator= ( const TSs Ss)

Definition at line 17 of file ss.h.

                               {
    if (this!=&Ss){CellStrVV=Ss.CellStrVV;} return *this;}
const char* operator[] ( const int &  FldN) const

Definition at line 85 of file ss.h.

References FldV.

{ return FldV[FldN]; }
void PutVal ( const int &  X,
const int &  Y,
const TStr Str 
)

Referenced by TLocClust::ApproxPageRank().

Here is the caller graph for this function:

void Save ( TSOut SOut)

Definition at line 15 of file ss.h.

{CellStrVV.Save(SOut);}
void SaveTxt ( const TStr FNm,
const PNotify &  Notify = NULL 
) const
int TSs::SearchX ( const int &  Y,
const TStr Str 
) const

Definition at line 51 of file ss.cpp.

                                                    {
  return CellStrVV[Y]->V.SearchForw(Str);
}
int TSs::SearchY ( const int &  X,
const TStr Str 
) const

Definition at line 55 of file ss.cpp.

References GetVal(), and GetYLen().

                                                    {
  int YLen=GetYLen();
  for (int Y=0; Y<YLen; Y++){
     if (Str==GetVal(X, Y)){return Y;}}
  return -1;
}

Here is the call graph for this function:

void ToLc ( )

Referenced by TStrUtil::GetDomNm().

Here is the caller graph for this function:

TSs ( )

Definition at line 10 of file ss.h.

Referenced by Load(), and New().

: CellStrVV(){}

Here is the caller graph for this function:

TSs ( TSIn SIn)

Definition at line 13 of file ss.h.

: CellStrVV(SIn){}
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.");
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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;
}

Here is the call graph for this function:

~TSs ( )

Definition at line 12 of file ss.h.

{}

Definition at line 374 of file ss.cpp.

                      {
  //if (Bf != NULL) { delete [] Bf; }
}

Variable Documentation

Definition at line 66 of file ss.h.

Referenced by Eof(), and TSsParser().

TVec<char*> FldV

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 SkipCmt

Definition at line 58 of file ss.h.

ClassTP (TSsParser, PSsParser) private bool SkipEmptyFld

Definition at line 58 of file ss.h.

ClassTP (TSsParser, PSsParser) private bool SkipLeadBlanks

Fast Spread Sheet Parser.

Definition at line 58 of file ss.h.

char SplitCh

Definition at line 63 of file ss.h.

Referenced by TUInt::IsIpStr(), and TSsParser().