|
SNAP Library, User 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.
Classes | |
| class | TXmlObjSer |
| class | TXmlObjSerTagNm |
| class | TXmlLx |
| class | TXmlParser |
Typedefs | |
| typedef TPt< TXmlParser > | PXmlParser |
Enumerations | |
| enum | TXmlLxSym { xsyUndef, xsyWs, xsyComment, xsyXmlDecl, xsyPI, xsyDocTypeDecl, xsyElement, xsyAttList, xsyEntity, xsyNotation, xsyTag, xsySTag, xsyETag, xsySETag, xsyStr, xsyQStr, xsyEof } |
| enum | TXmlSpacing { xspIntact, xspPreserve, xspSeparate, xspTruncate } |
Functions | |
| void | SetChTy (TBSet &ChSet, const int &MnCh, const int &MxCh=-1) |
| void | SetChTy (TBSet &ChSet, const TStr &Str) |
| void | SetEntityVal (const TStr &Nm, const TStr &Val) |
| TXmlChDef () | |
| TXmlChDef (TSIn &SIn) | |
| static PXmlChDef | Load (TSIn &SIn) |
| void | Save (TSOut &SOut) |
| TXmlChDef & | operator= (const TXmlChDef &) |
| bool | IsChar (const uchar &Ch) const |
| bool | IsComb (const uchar &Ch) const |
| bool | IsExt (const uchar &Ch) const |
| bool | IsLetter (const uchar &Ch) const |
| bool | IsDigit (const uchar &Ch) const |
| bool | IsName (const uchar &Ch) const |
| bool | IsPubid (const uchar &Ch) const |
| bool | IsWs (const uchar &Ch) const |
| bool | IsFirstNameCh (const uchar &Ch) const |
| bool | IsEoln (const uchar &Ch) const |
| bool | IsEntityNm (const TStr &EntityNm, TStr &EntityVal) const |
| TXmlTok () | |
| TXmlTok (const TXmlLxSym &_Sym) | |
| TXmlTok (const TXmlLxSym &_Sym, const TStr &_Str) | |
| TXmlTok (const TXmlLxSym &_Sym, const TStr &_Str, const TStrKdV &_ArgNmValV) | |
| 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) |
| TXmlTok (TSIn &) | |
| 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 TStr | GetTokVStr (const TXmlTokV &TokV, const bool &XmlP=true) |
| static PXmlTok | GetTok (TXmlLx &Lx) |
| static void | LoadTxtMiscStar (TXmlLx &Lx) |
| static PXmlTok | LoadTxtElement (TXmlLx &Lx) |
| TXmlDoc () | |
| TXmlDoc (const PXmlTok &_Tok) | |
| static PXmlDoc | New (const PXmlTok &Tok) |
| TXmlDoc (TSIn &) | |
| TXmlDoc & | operator= (const TXmlDoc &) |
| bool | IsOk () const |
| TStr | GetMsgStr () const |
| PXmlTok | GetTok () const |
| void | PutTagTokStr (const TStr &TagPath, const TStr &TokStr) const |
| bool | GetTagTokBoolArgVal (const TStr &TagPath, const TStr &ArgNm, const bool &DfVal=false) const |
| int | GetTagTokIntArgVal (const TStr &TagPath, const TStr &ArgNm, const int &DfVal=0) const |
| double | GetTagTokFltArgVal (const TStr &TagPath, const TStr &ArgNm, const double &DfVal=0) const |
| TStr | GetTagTokStrArgVal (const TStr &TagPath, const TStr &ArgNm, const TStr &DfVal=TStr()) const |
| static TStr | GetXmlStr (const TStr &Str) |
| static bool | SkipTopTag (const PSIn &SIn) |
| static PXmlDoc | LoadTxt (TXmlLx &Lx) |
| static PXmlDoc | LoadTxt (const PSIn &SIn, const TXmlSpacing &Spacing=xspIntact) |
| static PXmlDoc | LoadTxt (const TStr &FNm, const TXmlSpacing &Spacing=xspIntact) |
| static void | LoadTxt (const TStr &FNm, TXmlDocV &XmlDocV, const TXmlSpacing &Spacing=xspIntact) |
| void | SaveTxt (const PSOut &SOut) |
| void | SaveTxt (const TStr &FNm, const bool &Append=false) |
| static PXmlDoc | LoadStr (const TStr &Str) |
| void | SaveStr (TStr &Str) |
Variables | |
| ClassTP(TXmlChDef, PXmlChDef) private TBSet | CharChSet |
| ClassTP(TXmlChDef, PXmlChDef) private TBSet | CombChSet |
| ClassTP(TXmlChDef, PXmlChDef) private TBSet | ExtChSet |
| TBSet | LetterChSet |
| TBSet | DigitChSet |
| TBSet | NameChSet |
| TBSet | PubidChSet |
| TStrStrH | EntityNmToValH |
| ClassTPV(TXmlTok, PXmlTok, TXmlTokV) private TStr | Str |
| TStrKdV | ArgNmValV |
| TXmlTokV | SubTokV |
| ClassTPV(TXmlDoc, PXmlDoc, TXmlDocV) private TStr | MsgStr |
| PXmlTok | Tok |
| typedef TPt<TXmlParser> PXmlParser |
| enum TXmlLxSym |
| xsyUndef | |
| xsyWs | |
| xsyComment | |
| xsyXmlDecl | |
| xsyPI | |
| xsyDocTypeDecl | |
| xsyElement | |
| xsyAttList | |
| xsyEntity | |
| xsyNotation | |
| xsyTag | |
| xsySTag | |
| xsyETag | |
| xsySETag | |
| xsyStr | |
| xsyQStr | |
| xsyEof |
Definition at line 87 of file xml.h.
{
xsyUndef, xsyWs, xsyComment,
xsyXmlDecl, xsyPI,
xsyDocTypeDecl, xsyElement, xsyAttList, xsyEntity, xsyNotation,
xsyTag, xsySTag, xsyETag, xsySETag, xsyStr, xsyQStr,
xsyEof} TXmlLxSym;
| enum TXmlSpacing |
| void TXmlTok::AddTokToChA | ( | const bool & | XmlP, |
| TChA & | ChA | ||
| ) | const |
Definition at line 1179 of file xml.cpp.
{
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;
}
}
| bool TXmlTok::GetBoolArgVal | ( | const TStr & | ArgNm, |
| const bool & | DfVal = false |
||
| ) | const |
Definition at line 1083 of file xml.cpp.
{
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 |
| bool TXmlTok::GetBoolArgVal | ( | const TStr & | ArgNm, |
| const TStr & | TrueVal, | ||
| const TStr & | FalseVal, | ||
| const bool & | DfVal = false |
||
| ) | const |
| double TXmlTok::GetFltArgVal | ( | const TStr & | ArgNm, |
| const double & | DfVal = 0 |
||
| ) | const |
| int TXmlTok::GetIntArgVal | ( | const TStr & | ArgNm, |
| const int & | DfVal = 0 |
||
| ) | const |
| TStr TXmlTok::GetStrArgVal | ( | const TStr & | ArgNm, |
| const TStr & | DfVal = TStr() |
||
| ) | const |
| int GetSubToks | ( | ) | const |
Definition at line 240 of file xml.h.
{return TXmlLx::GetXmlLxSymStr(Sym);}
Definition at line 1136 of file xml.cpp.
{
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);}
}
}
| bool TXmlDoc::GetTagTokBoolArgVal | ( | const TStr & | TagPath, |
| const TStr & | ArgNm, | ||
| const bool & | DfVal = false |
||
| ) | const |
| double TXmlDoc::GetTagTokFltArgVal | ( | const TStr & | TagPath, |
| const TStr & | ArgNm, | ||
| const double & | DfVal = 0 |
||
| ) | const |
| int TXmlDoc::GetTagTokIntArgVal | ( | const TStr & | TagPath, |
| const TStr & | ArgNm, | ||
| const int & | DfVal = 0 |
||
| ) | const |
| TStr GetTagTokStr | ( | const TStr & | TagPath | ) | const |
| TStr GetTagTokStrOrDf | ( | const TStr & | TagPath, |
| const TStr & | DfVal = TStr() |
||
| ) | const |
| void GetTagTokV | ( | const TStr & | TagPath, |
| TXmlTokV & | XmlTokV | ||
| ) | const |
Definition at line 1152 of file xml.cpp.
{
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);}
}
}
}
| void GetTagValV | ( | const TStr & | TagNm, |
| const bool & | XmlP, | ||
| TStrV & | ValV | ||
| ) | const |
Definition at line 314 of file xml.h.
{
TChA ChA; AddTokToChA(XmlP, ChA); return ChA;}
| TStr TXmlTok::GetTokVStr | ( | const TXmlTokV & | TokV, |
| const bool & | XmlP = true |
||
| ) | [static] |
| TStr TXmlDoc::GetXmlStr | ( | const TStr & | Str | ) | [static] |
Definition at line 1358 of file xml.cpp.
{
TChA ChA=Str;
TChA XmlChA;
for (int ChN=0; ChN<ChA.Len(); ChN++){
uchar Ch=ChA[ChN];
if ((' '<=Ch)&&(Ch<='~')){
if (Ch=='&'){XmlChA+="&";}
else if (Ch=='>'){XmlChA+="<";}
else if (Ch=='<'){XmlChA+=">";}
else if (Ch=='\''){XmlChA+="'";}
else if (Ch=='\"'){XmlChA+=""";}
else {XmlChA+=Ch;}
} else {
XmlChA+="&#"; XmlChA+=TUInt::GetStr(Ch); XmlChA+=";";
}
}
return XmlChA;
}
Definition at line 263 of file xml.h.
{
return ArgNmValV.SearchForw(TStrKd(ArgNm))!=-1;}
Definition at line 70 of file xml.h.
{return DigitChSet.GetBit(Ch);}
| bool IsEntityNm | ( | const TStr & | EntityNm, |
| TStr & | EntityVal | ||
| ) | const |
Definition at line 81 of file xml.h.
{
return EntityNmToValH.IsKeyGetDat(EntityNm, EntityVal);}
| bool IsFirstNameCh | ( | const uchar & | Ch | ) | const |
Definition at line 69 of file xml.h.
{return LetterChSet.GetBit(Ch);}
Definition at line 72 of file xml.h.
{return PubidChSet.GetBit(Ch);}
Definition at line 74 of file xml.h.
{
return (Ch==' ')||(Ch==TCh::CrCh)||(Ch==TCh::LfCh)||(Ch==TCh::TabCh);}
| PXmlDoc TXmlDoc::LoadStr | ( | const TStr & | Str | ) | [static] |
Definition at line 1437 of file xml.cpp.
{
PSIn SIn=TStrIn::New(Str);
return LoadTxt(SIn);
}
| static PXmlDoc LoadTxt | ( | const PSIn & | SIn, |
| const TXmlSpacing & | Spacing = xspIntact |
||
| ) | [static] |
| static PXmlDoc LoadTxt | ( | const TStr & | FNm, |
| const TXmlSpacing & | Spacing = xspIntact |
||
| ) | [static] |
| static void LoadTxt | ( | const TStr & | FNm, |
| TXmlDocV & | XmlDocV, | ||
| const TXmlSpacing & | Spacing = xspIntact |
||
| ) | [static] |
| PXmlTok TXmlDoc::LoadTxtElement | ( | TXmlLx & | Lx | ) | [static] |
Definition at line 1243 of file xml.cpp.
{
// [39] element ::= EmptyElemTag | STag content ETag
PXmlTok Tok;
if (Lx.Sym==xsySETag){
Tok=TXmlTok::GetTok(Lx);
} else
if (Lx.Sym==xsySTag){
Tok=TXmlTok::GetTok(Lx);
forever {
Lx.GetSym();
if (Lx.Sym==xsyETag){
if (Tok->GetStr()==Lx.TagNm){
break;
} else {
TStr MsgStr=TStr("Invalid End-Tag '")+Lx.TagNm+
"' ('"+Tok->GetStr()+"' expected).";
Lx.EThrow(MsgStr);
}
} else {
PXmlTok SubTok;
switch (Lx.Sym){
case xsySTag:
SubTok=LoadTxtElement(Lx); break;
case xsySETag:
case xsyStr:
case xsyQStr:
case xsyWs:
SubTok=TXmlTok::GetTok(Lx); break;
case xsyPI:
case xsyComment:
break;
default: Lx.EThrow("Content or End-Tag expected.");
}
if (!SubTok.Empty()){
Tok->AddSubTok(SubTok);}
}
}
} else
if (Lx.Sym==xsyETag){
TStr MsgStr=
TStr("Xml-Element (Start-Tag or Empty-Element-Tag) required.")+
TStr::GetStr(Lx.TagNm, " End-Tag </%s> encountered.");
Lx.EThrow(MsgStr);
} else {
Lx.EThrow("Xml-Element (Start-Tag or Empty-Element-Tag) required.");
}
return Tok;
}
| void TXmlDoc::LoadTxtMiscStar | ( | TXmlLx & | Lx | ) | [static] |
| void TXmlTok::PutSubTok | ( | const PXmlTok & | Tok, |
| const int & | SubTokN = -1 |
||
| ) |
| void TXmlDoc::PutTagTokStr | ( | const TStr & | TagPath, |
| const TStr & | TokStr | ||
| ) | const |
Definition at line 57 of file xml.h.
{
Chs.Save(SOut);
CharChSet.Save(SOut); CombChSet.Save(SOut); ExtChSet.Save(SOut);
LetterChSet.Save(SOut); DigitChSet.Save(SOut); NameChSet.Save(SOut);
PubidChSet.Save(SOut);
EntityNmToValH.Save(SOut);}
| void TXmlDoc::SaveStr | ( | TStr & | Str | ) |
Definition at line 383 of file xml.h.
{
PSOut SOut=TFOut::New(FNm, Append); SaveTxt(SOut);}
| void TXmlChDef::SetEntityVal | ( | const TStr & | Nm, |
| const TStr & | Val | ||
| ) |
Definition at line 204 of file xml.cpp.
{
EntityNmToValH.AddDat(Nm, Val);
}
| bool TXmlDoc::SkipTopTag | ( | const PSIn & | SIn | ) | [static] |
Definition at line 1377 of file xml.cpp.
{
bool Ok=true;
TXmlLx Lx(SIn, xspIntact);
try {
Lx.GetSym();
// [22] prolog ::= XMLDecl? Misc* (doctypedecl Misc*)?
if (Lx.Sym==xsyXmlDecl){Lx.GetSym();}
LoadTxtMiscStar(Lx);
if (Lx.Sym==xsyDocTypeDecl){Lx.GetSym();}
LoadTxtMiscStar(Lx);
Ok=true;
}
catch (PExcept Except){
Ok=false;
}
return Ok;
}
Definition at line 208 of file xml.cpp.
: Chs(TUCh::Vals), CharChSet(), CombChSet(), ExtChSet(), LetterChSet(), DigitChSet(), NameChSet(), PubidChSet(), EntityNmToValH(100){ // Character-Sets // Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | ... CharChSet.Gen(Chs); // ... because of DMoz (temporary patch) SetChTy(CharChSet, 0x1); SetChTy(CharChSet, 0x3); SetChTy(CharChSet, 0x6); SetChTy(CharChSet, 11); SetChTy(CharChSet, 24); SetChTy(CharChSet, 27); // regular characters SetChTy(CharChSet, 0x9); SetChTy(CharChSet, 0xA); SetChTy(CharChSet, 0xD); SetChTy(CharChSet, 0x20, TUCh::Mx); // BaseChar ::= [#x0041-#x005A] | [#x0061-#x007A] | [#x00C0-#x00D6] | // [#x00D8-#x00F6] | [#x00F8-#x00FF] | ... TBSet BaseChSet(Chs); SetChTy(BaseChSet, 0x41, 0x5A); SetChTy(BaseChSet, 0x61, 0x7A); SetChTy(BaseChSet, 0xC0, 0xD6); SetChTy(BaseChSet, 0xD8, 0xF6); SetChTy(BaseChSet, 0xF8, 0xFF); // Ideographic ::= ... TBSet IdeoChSet(Chs); // CombiningChar ::= ... CombChSet.Gen(Chs); // Extender ::= #x00B7 | ... ExtChSet.Gen(Chs); SetChTy(ExtChSet, 0xB7); // Letter ::= BaseChar | Ideographic LetterChSet=BaseChSet|IdeoChSet; // Digit ::= [#x0030-#x0039] | ... DigitChSet.Gen(Chs); SetChTy(DigitChSet, 0x30, 0x39); // NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar NameChSet=LetterChSet|DigitChSet| uchar('.')|uchar('-')|uchar('_')|uchar(':')|CombChSet; // PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%] PubidChSet.Gen(Chs); SetChTy(PubidChSet, 0x20); SetChTy(PubidChSet, 0xD); SetChTy(PubidChSet, 0xA); SetChTy(PubidChSet, 'a', 'z'); SetChTy(PubidChSet, 'A', 'Z'); SetChTy(PubidChSet, '0', '9'); SetChTy(PubidChSet, "-'()+,./:=?;!*#@$_%"); // Standard-Entity-Sequences SetEntityVal("amp", "&"); SetEntityVal("lt", "<"); SetEntityVal("gt", ">"); SetEntityVal("apos", "'"); SetEntityVal("quot", "\""); }
Definition at line 51 of file xml.h.
:
Chs(SIn),
CharChSet(SIn), CombChSet(SIn), ExtChSet(SIn),
LetterChSet(SIn), DigitChSet(SIn), NameChSet(SIn), PubidChSet(SIn),
EntityNmToValH(SIn){}