SNAP Library , Developer Reference
2013-01-07 14:03:36
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <xml.h>
Public Member Functions | |
TXmlTok () | |
TXmlTok (const TXmlLxSym &_Sym) | |
TXmlTok (const TXmlLxSym &_Sym, const TStr &_Str) | |
TXmlTok (const TXmlLxSym &_Sym, const TStr &_Str, const TStrKdV &_ArgNmValV) | |
TXmlTok (TSIn &) | |
void | Save (TSOut &) |
TXmlTok & | operator= (const TXmlTok &) |
TXmlLxSym | GetSym () const |
TStr | GetSymStr () const |
void | PutStr (const TStr &_Str) |
TStr | GetStr () const |
bool | IsTag () const |
bool | IsTag (const TStr &TagNm) const |
TStr | GetTagNm () const |
void | AddArg (const TStr &ArgNm, const bool &ArgVal) |
void | AddArg (const TStr &ArgNm, const int &ArgVal) |
void | AddArg (const TStr &ArgNm, const uint64 &ArgVal) |
void | AddArg (const TStr &ArgNm, const double &ArgVal) |
void | AddArg (const TStr &ArgNm, const TStr &ArgVal) |
int | GetArgs () const |
void | GetArg (const int &ArgN, TStr &ArgNm, TStr &ArgVal) const |
bool | IsArg (const TStr &ArgNm) const |
bool | IsArg (const TStr &ArgNm, TStr &ArgVal) const |
void | PutArgVal (const TStr &ArgNm, const TStr &ArgVal) |
TStr | GetArgVal (const TStr &ArgNm) const |
TStr | GetArgVal (const TStr &ArgNm, const TStr &DfArgVal) const |
bool | GetBoolArgVal (const TStr &ArgNm, const bool &DfVal=false) const |
bool | GetBoolArgVal (const TStr &ArgNm, const TStr &TrueVal, const bool &DfVal=false) const |
bool | GetBoolArgVal (const TStr &ArgNm, const TStr &TrueVal, const TStr &FalseVal, const bool &DfVal=false) const |
int | GetIntArgVal (const TStr &ArgNm, const int &DfVal=0) const |
double | GetFltArgVal (const TStr &ArgNm, const double &DfVal=0) const |
TStr | GetStrArgVal (const TStr &ArgNm, const TStr &DfVal=TStr()) const |
bool | IsSubTag (const TStr &TagNm) const |
bool | IsSubTag (const TStr &TagNm, PXmlTok &Tok) const |
void | AddSubTok (const PXmlTok &Tok) |
int | GetSubToks () const |
PXmlTok | GetSubTok (const int &SubTokN) const |
void | ClrSubTok () |
void | PutSubTok (const PXmlTok &Tok, const int &SubTokN=-1) |
bool | IsTagTok (const TStr &TagPath, PXmlTok &TagTok) const |
bool | IsTagTok (const TStr &TagPath) const |
PXmlTok | GetTagTok (const TStr &TagPath) const |
void | GetTagTokV (const TStr &TagPath, TXmlTokV &XmlTokV) const |
void | GetTagValV (const TStr &TagNm, const bool &XmlP, TStrV &ValV) const |
TStr | GetTagVal (const TStr &TagNm, const bool &XmlP) const |
TStr | GetTagTokStr (const TStr &TagPath) const |
TStr | GetTagTokStrOrDf (const TStr &TagPath, const TStr &DfVal=TStr()) const |
void | AddTokToChA (const bool &XmlP, TChA &ChA) const |
TStr | GetTokStr (const bool &XmlP=true) const |
Static Public Member Functions | |
static PXmlTok | New () |
static PXmlTok | New (const TXmlLxSym &Sym) |
static PXmlTok | New (const TXmlLxSym &Sym, const TStr &Str) |
static PXmlTok | New (const TXmlLxSym &Sym, const TStr &Str, const TStrKdV &ArgNmValV) |
static PXmlTok | New (const TStr &TagNm, const TStrKdV &ArgNmValV) |
static PXmlTok | New (const TStr &TagNm) |
static PXmlTok | New (const TStr &TagNm, const TStr &ValStr) |
static PXmlTok | New (const TStr &TagNm, const PXmlTok &XmlTok1, const PXmlTok &XmlTok2=NULL) |
static PXmlTok | Load (TSIn &) |
static TStr | GetTokVStr (const TXmlTokV &TokV, const bool &XmlP=true) |
static PXmlTok | GetTok (TXmlLx &Lx) |
Private Attributes | |
TCRef | CRef |
TXmlLxSym | Sym |
TStr | Str |
TStrKdV | ArgNmValV |
TXmlTokV | SubTokV |
Friends | |
class | TPt< TXmlTok > |
TXmlTok::TXmlTok | ( | ) | [inline] |
TXmlTok::TXmlTok | ( | const TXmlLxSym & | _Sym | ) | [inline] |
TXmlTok::TXmlTok | ( | const TXmlLxSym & | _Sym, |
const TStr & | _Str | ||
) | [inline] |
TXmlTok::TXmlTok | ( | const TXmlLxSym & | _Sym, |
const TStr & | _Str, | ||
const TStrKdV & | _ArgNmValV | ||
) | [inline] |
void TXmlTok::AddArg | ( | const TStr & | ArgNm, |
const bool & | ArgVal | ||
) | [inline] |
Definition at line 252 of file xml.h.
References TBool::GetStr().
Referenced by TSecTm::GetXmlTok().
{ ArgNmValV.Add(TStrKd(ArgNm, TBool::GetStr(ArgVal)));}
void TXmlTok::AddArg | ( | const TStr & | ArgNm, |
const int & | ArgVal | ||
) | [inline] |
Definition at line 254 of file xml.h.
References TInt::GetStr().
{ ArgNmValV.Add(TStrKd(ArgNm, TInt::GetStr(ArgVal)));}
void TXmlTok::AddArg | ( | const TStr & | ArgNm, |
const uint64 & | ArgVal | ||
) | [inline] |
Definition at line 256 of file xml.h.
References TUInt64::GetStr().
{ ArgNmValV.Add(TStrKd(ArgNm, TUInt64::GetStr(ArgVal)));}
void TXmlTok::AddArg | ( | const TStr & | ArgNm, |
const double & | ArgVal | ||
) | [inline] |
Definition at line 258 of file xml.h.
References TFlt::GetStr().
{ ArgNmValV.Add(TStrKd(ArgNm, TFlt::GetStr(ArgVal)));}
void TXmlTok::AddArg | ( | const TStr & | ArgNm, |
const TStr & | ArgVal | ||
) | [inline] |
void TXmlTok::AddSubTok | ( | const PXmlTok & | Tok | ) | [inline] |
Definition at line 292 of file xml.h.
Referenced by TXmlDoc::LoadTxtElement(), New(), PutSubTok(), and TXmlDoc::PutTagTokStr().
void TXmlTok::AddTokToChA | ( | const bool & | XmlP, |
TChA & | ChA | ||
) | const |
Definition at line 1179 of file xml.cpp.
References AddTokToChA(), Fail, GetArg(), GetArgs(), TXmlLx::GetArgValQCh(), GetSubTok(), GetSubToks(), TXmlLx::GetXmlStrFromPlainStr(), Str, Sym, xsyQStr, xsyStr, xsyTag, and xsyWs.
Referenced by AddTokToChA().
{ switch (Sym){ case xsyWs: ChA+=Str; break; case xsyStr: if (XmlP){ChA+=TXmlLx::GetXmlStrFromPlainStr(Str);} else {ChA+=Str;} break; case xsyQStr: if (XmlP){ChA+="<![CDATA[";} ChA+=Str; if (XmlP){ChA+="]]>";} break; case xsyTag: if (XmlP){ ChA+='<'; ChA+=Str; for (int ArgN=0; ArgN<GetArgs(); ArgN++){ TStr ArgNm; TStr ArgVal; GetArg(ArgN, ArgNm, ArgVal); if (XmlP){ArgVal=TXmlLx::GetXmlStrFromPlainStr(ArgVal);} char ArgValQCh=TXmlLx::GetArgValQCh(ArgVal); ChA+=' '; ChA+=ArgNm; ChA+='='; ChA+=ArgValQCh; ChA+=ArgVal; ChA+=ArgValQCh; } } if (GetSubToks()==0){ if (XmlP){ChA+="/>";} } else { if (XmlP){ChA+=">";} for (int SubTokN=0; SubTokN<GetSubToks(); SubTokN++){ GetSubTok(SubTokN)->AddTokToChA(XmlP, ChA);} if (XmlP){ChA+="</"; ChA+=Str; ChA+='>';} } break; default: Fail; } }
void TXmlTok::ClrSubTok | ( | ) | [inline] |
Definition at line 295 of file xml.h.
Referenced by PutSubTok(), and TXmlDoc::PutTagTokStr().
void TXmlTok::GetArg | ( | const int & | ArgN, |
TStr & | ArgNm, | ||
TStr & | ArgVal | ||
) | const [inline] |
Definition at line 263 of file xml.h.
Referenced by AddTokToChA().
int TXmlTok::GetArgs | ( | ) | const [inline] |
Definition at line 262 of file xml.h.
Referenced by AddTokToChA().
TStr TXmlTok::GetArgVal | ( | const TStr & | ArgNm | ) | const [inline] |
Definition at line 273 of file xml.h.
Referenced by TPreproc::TPreproc().
{ return ArgNmValV[ArgNmValV.SearchForw(TStrKd(ArgNm))].Dat;}
TStr TXmlTok::GetArgVal | ( | const TStr & | ArgNm, |
const TStr & | DfArgVal | ||
) | const [inline] |
bool TXmlTok::GetBoolArgVal | ( | const TStr & | ArgNm, |
const bool & | DfVal = false |
||
) | const |
Definition at line 1083 of file xml.cpp.
References ArgNmValV, TVec< TVal >::SearchForw(), and TBool::TrueStr.
Referenced by TXmlDoc::GetTagTokBoolArgVal().
{ int ArgN=ArgNmValV.SearchForw(TStrKd(ArgNm)); return (ArgN==-1) ? DfVal : (ArgNmValV[ArgN].Dat==TBool::TrueStr); }
bool TXmlTok::GetBoolArgVal | ( | const TStr & | ArgNm, |
const TStr & | TrueVal, | ||
const bool & | DfVal = false |
||
) | const |
Definition at line 1088 of file xml.cpp.
References ArgNmValV, and TVec< TVal >::SearchForw().
{ int ArgN=ArgNmValV.SearchForw(TStrKd(ArgNm)); return (ArgN==-1) ? DfVal : (ArgNmValV[ArgN].Dat==TrueVal); }
bool TXmlTok::GetBoolArgVal | ( | const TStr & | ArgNm, |
const TStr & | TrueVal, | ||
const TStr & | FalseVal, | ||
const bool & | DfVal = false |
||
) | const |
Definition at line 1094 of file xml.cpp.
References ArgNmValV, IAssert, and TVec< TVal >::SearchForw().
{ int ArgN=ArgNmValV.SearchForw(TStrKd(ArgNm)); if (ArgN==-1){return DfVal;} TStr ArgVal=ArgNmValV[ArgN].Dat; if (ArgVal==TrueVal){return true;} IAssert(ArgVal == FalseVal); return false; }
double TXmlTok::GetFltArgVal | ( | const TStr & | ArgNm, |
const double & | DfVal = 0 |
||
) | const |
Definition at line 1113 of file xml.cpp.
References ArgNmValV, and TVec< TVal >::SearchForw().
Referenced by TXmlDoc::GetTagTokFltArgVal().
{ int ArgN=ArgNmValV.SearchForw(TStrKd(ArgNm)); if (ArgN==-1){ return DfVal; } else { double Val; if (ArgNmValV[ArgN].Dat.IsFlt(Val)){return Val;} else {return DfVal;} } }
int TXmlTok::GetIntArgVal | ( | const TStr & | ArgNm, |
const int & | DfVal = 0 |
||
) | const |
Definition at line 1103 of file xml.cpp.
References ArgNmValV, and TVec< TVal >::SearchForw().
Referenced by TXmlDoc::GetTagTokIntArgVal(), and TSecTm::TSecTm().
{ int ArgN=ArgNmValV.SearchForw(TStrKd(ArgNm)); if (ArgN==-1){ return DfVal; } else { int Val; if (ArgNmValV[ArgN].Dat.IsInt(Val)){return Val;} else {return DfVal;} } }
TStr TXmlTok::GetStr | ( | ) | const [inline] |
Definition at line 244 of file xml.h.
Referenced by TXmlObjSer::AssertXmlHd(), GetTagTok(), TXmlDoc::GetTagTok(), GetTagTokV(), TXmlDoc::GetTagTokV(), and TXmlDoc::LoadTxtElement().
{return Str;}
TStr TXmlTok::GetStrArgVal | ( | const TStr & | ArgNm, |
const TStr & | DfVal = TStr() |
||
) | const |
Definition at line 1123 of file xml.cpp.
References ArgNmValV, and TVec< TVal >::SearchForw().
Referenced by TXmlObjSer::AssertXmlHd(), and TXmlDoc::GetTagTokStrArgVal().
{ int ArgN=ArgNmValV.SearchForw(TStrKd(ArgNm)); return (ArgN==-1) ? DfVal : ArgNmValV[ArgN].Dat; }
PXmlTok TXmlTok::GetSubTok | ( | const int & | SubTokN | ) | const [inline] |
Definition at line 294 of file xml.h.
Referenced by AddTokToChA(), GetTagTokV(), TXmlDoc::GetTagTokV(), and GetTagValV().
{return SubTokV[SubTokN];}
int TXmlTok::GetSubToks | ( | ) | const [inline] |
Definition at line 293 of file xml.h.
Referenced by AddTokToChA(), GetTagTokV(), TXmlDoc::GetTagTokV(), and GetTagValV().
TXmlLxSym TXmlTok::GetSym | ( | ) | const [inline] |
Definition at line 241 of file xml.h.
Referenced by GetTagTok(), TXmlDoc::GetTagTok(), GetTagTokV(), and TXmlDoc::GetTagTokV().
{return Sym;}
TStr TXmlTok::GetSymStr | ( | ) | const [inline] |
Definition at line 242 of file xml.h.
References TXmlLx::GetXmlLxSymStr().
Referenced by TXmlObjSer::AssertXmlHd().
{return TXmlLx::GetXmlLxSymStr(Sym);}
TStr TXmlTok::GetTagNm | ( | ) | const [inline] |
PXmlTok TXmlTok::GetTagTok | ( | const TStr & | TagPath | ) | const |
Definition at line 1136 of file xml.cpp.
References TStr::Empty(), TPt< TRec >::Empty(), GetStr(), GetSym(), GetTagTok(), TVec< TVal >::Len(), TStr::SplitOnCh(), SubTokV, and xsyTag.
Referenced by GetTagTok(), TXmlDoc::GetTagTok(), GetTagTokV(), and TExpHelp::LoadXml().
{ if (TagPath.Empty()){ return (TXmlTok*)this; } else { TStr TagNm; TStr RestTagPath; TagPath.SplitOnCh(TagNm, '|', RestTagPath); PXmlTok SubTok; for (int SubTokN=0; SubTokN<SubTokV.Len(); SubTokN++){ SubTok=SubTokV[SubTokN]; if ((SubTok->GetSym()==xsyTag)&&(SubTok->GetStr()==TagNm)){break;} else {SubTok=NULL;} } if ((SubTok.Empty())||(RestTagPath.Empty())){return SubTok;} else {return SubTok->GetTagTok(RestTagPath);} } }
TStr TXmlTok::GetTagTokStr | ( | const TStr & | TagPath | ) | const [inline] |
TStr TXmlTok::GetTagTokStrOrDf | ( | const TStr & | TagPath, |
const TStr & | DfVal = TStr() |
||
) | const [inline] |
Definition at line 309 of file xml.h.
References GetTokStr().
{ PXmlTok TagTok; if (IsTagTok(TagPath, TagTok)){return TagTok->GetTokStr(false);} else {return DfVal;}}
void TXmlTok::GetTagTokV | ( | const TStr & | TagPath, |
TXmlTokV & | XmlTokV | ||
) | const |
Definition at line 1152 of file xml.cpp.
References TVec< TVal >::Add(), TVec< TVal >::Clr(), TPt< TRec >::Empty(), GetStr(), GetSubTok(), GetSubToks(), GetSym(), GetTagTok(), TStr::SplitOnLastCh(), and xsyTag.
Referenced by TExpHelp::LoadXml(), and TPreproc::TPreproc().
{ XmlTokV.Clr(); TStr PreTagPath; TStr TagNm; TagPath.SplitOnLastCh(PreTagPath, '|', TagNm); PXmlTok Tok=GetTagTok(PreTagPath); if (!Tok.Empty()){ for (int SubTokN=0; SubTokN<Tok->GetSubToks(); SubTokN++){ PXmlTok SubTok=Tok->GetSubTok(SubTokN); if ((SubTok->GetSym()==xsyTag)&&(SubTok->GetStr()==TagNm)){ XmlTokV.Add(SubTok);} } } }
TStr TXmlTok::GetTagVal | ( | const TStr & | TagNm, |
const bool & | XmlP | ||
) | const |
Definition at line 1174 of file xml.cpp.
References GetTagValV(), and TVec< TVal >::Len().
{ TStrV ValV; GetTagValV(TagNm, XmlP, ValV); if (ValV.Len()>0){return ValV[0];} else {return "";} }
void TXmlTok::GetTagValV | ( | const TStr & | TagNm, |
const bool & | XmlP, | ||
TStrV & | ValV | ||
) | const |
Definition at line 1165 of file xml.cpp.
References TVec< TVal >::Add(), GetSubTok(), GetSubToks(), GetTagValV(), GetTokStr(), Str, Sym, and xsyTag.
Referenced by GetTagVal(), and GetTagValV().
{ if ((Sym==xsyTag)&&(Str==TagNm)){ ValV.Add(GetTokStr(XmlP)); } else { for (int SubTokN=0; SubTokN<GetSubToks(); SubTokN++){ GetSubTok(SubTokN)->GetTagValV(TagNm, XmlP, ValV);} } }
PXmlTok TXmlTok::GetTok | ( | TXmlLx & | Lx | ) | [static] |
Definition at line 1222 of file xml.cpp.
References TXmlLx::ArgNmValKdV, Fail, New(), TXmlLx::Sym, TXmlLx::TagNm, TXmlLx::TxtChA, xsyQStr, xsySETag, xsySTag, xsyStr, xsyTag, and xsyWs.
{ switch (Lx.Sym){ case xsyWs: case xsyStr: case xsyQStr: return TXmlTok::New(Lx.Sym, Lx.TxtChA); case xsySTag: case xsySETag: return TXmlTok::New(xsyTag, Lx.TagNm, Lx.ArgNmValKdV); default: Fail; return NULL; } }
TStr TXmlTok::GetTokStr | ( | const bool & | XmlP = true | ) | const [inline] |
Definition at line 316 of file xml.h.
Referenced by GetTagTokStrOrDf(), GetTagValV(), TExpHelp::LoadXml(), TStr::LoadXml(), and TPreproc::TPreproc().
{ TChA ChA; AddTokToChA(XmlP, ChA); return ChA;}
TStr TXmlTok::GetTokVStr | ( | const TXmlTokV & | TokV, |
const bool & | XmlP = true |
||
) | [static] |
Definition at line 1213 of file xml.cpp.
References TVec< TVal >::Len().
{ TChA TokVChA; for (int TokN=0; TokN<TokV.Len(); TokN++){ if (TokN>0){TokVChA+=' ';} TokVChA+=TokV[TokN]->GetTokStr(XmlP); } return TokVChA; }
bool TXmlTok::IsArg | ( | const TStr & | ArgNm | ) | const [inline] |
Definition at line 265 of file xml.h.
Referenced by TXmlObjSer::GetBoolArg(), TXmlObjSer::GetFltArg(), TXmlObjSer::GetInt64Arg(), and TXmlObjSer::GetIntArg().
{ return ArgNmValV.SearchForw(TStrKd(ArgNm))!=-1;}
bool TXmlTok::IsArg | ( | const TStr & | ArgNm, |
TStr & | ArgVal | ||
) | const [inline] |
bool TXmlTok::IsSubTag | ( | const TStr & | TagNm | ) | const [inline] |
bool TXmlTok::IsSubTag | ( | const TStr & | TagNm, |
PXmlTok & | Tok | ||
) | const [inline] |
Definition at line 290 of file xml.h.
References TPt< TRec >::Empty().
bool TXmlTok::IsTag | ( | ) | const [inline] |
bool TXmlTok::IsTag | ( | const TStr & | TagNm | ) | const [inline] |
bool TXmlTok::IsTagTok | ( | const TStr & | TagPath, |
PXmlTok & | TagTok | ||
) | const [inline] |
Definition at line 299 of file xml.h.
References TPt< TRec >::Empty().
bool TXmlTok::IsTagTok | ( | const TStr & | TagPath | ) | const [inline] |
static PXmlTok TXmlTok::Load | ( | TSIn & | ) | [inline, static] |
static PXmlTok TXmlTok::New | ( | ) | [inline, static] |
static PXmlTok TXmlTok::New | ( | const TXmlLxSym & | Sym | ) | [inline, static] |
static PXmlTok TXmlTok::New | ( | const TXmlLxSym & | Sym, |
const TStr & | Str | ||
) | [inline, static] |
static PXmlTok TXmlTok::New | ( | const TXmlLxSym & | Sym, |
const TStr & | Str, | ||
const TStrKdV & | ArgNmValV | ||
) | [inline, static] |
static PXmlTok TXmlTok::New | ( | const TStr & | TagNm, |
const TStrKdV & | ArgNmValV | ||
) | [inline, static] |
static PXmlTok TXmlTok::New | ( | const TStr & | TagNm | ) | [inline, static] |
static PXmlTok TXmlTok::New | ( | const TStr & | TagNm, |
const TStr & | ValStr | ||
) | [inline, static] |
static PXmlTok TXmlTok::New | ( | const TStr & | TagNm, |
const PXmlTok & | XmlTok1, | ||
const PXmlTok & | XmlTok2 = NULL |
||
) | [inline, static] |
Definition at line 228 of file xml.h.
References AddSubTok(), TPt< TRec >::Empty(), and xsyTag.
{ PXmlTok TagXmlTok=PXmlTok(new TXmlTok(xsyTag, TagNm)); if (!XmlTok1.Empty()){TagXmlTok->AddSubTok(XmlTok1);} if (!XmlTok2.Empty()){TagXmlTok->AddSubTok(XmlTok2);} return TagXmlTok;}
void TXmlTok::PutArgVal | ( | const TStr & | ArgNm, |
const TStr & | ArgVal | ||
) | [inline] |
void TXmlTok::PutStr | ( | const TStr & | _Str | ) | [inline] |
void TXmlTok::PutSubTok | ( | const PXmlTok & | Tok, |
const int & | SubTokN = -1 |
||
) |
Definition at line 1128 of file xml.cpp.
References AddSubTok(), ClrSubTok(), and SubTokV.
void TXmlTok::Save | ( | TSOut & | ) | [inline] |
TStrKdV TXmlTok::ArgNmValV [private] |
Definition at line 202 of file xml.h.
Referenced by GetBoolArgVal(), GetFltArgVal(), GetIntArgVal(), and GetStrArgVal().
TCRef TXmlTok::CRef [private] |
TStr TXmlTok::Str [private] |
Definition at line 201 of file xml.h.
Referenced by AddTokToChA(), and GetTagValV().
TXmlTokV TXmlTok::SubTokV [private] |
Definition at line 203 of file xml.h.
Referenced by GetTagTok(), and PutSubTok().
TXmlLxSym TXmlTok::Sym [private] |
Definition at line 200 of file xml.h.
Referenced by AddTokToChA(), and GetTagValV().