|
SNAP Library 2.1, User Reference
2013-09-25 10:47:25
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <xml.h>
Public Member Functions | |
| TXmlDoc () | |
| TXmlDoc (const PXmlTok &_Tok) | |
| TXmlDoc (TSIn &) | |
| void | Save (TSOut &) |
| TXmlDoc & | operator= (const TXmlDoc &) |
| bool | IsOk () const |
| TStr | GetMsgStr () const |
| PXmlTok | GetTok () const |
| bool | IsTagTok (const TStr &TagPath, PXmlTok &TagTok) const |
| bool | IsTagTok (const TStr &TagPath) const |
| PXmlTok | GetTagTok (const TStr &TagPath) const |
| void | PutTagTokStr (const TStr &TagPath, const TStr &TokStr) const |
| TStr | GetTagTokStr (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 |
| 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 |
| void | SaveTxt (const PSOut &SOut) |
| void | SaveTxt (const TStr &FNm, const bool &Append=false) |
| void | SaveStr (TStr &Str) |
Static Public Member Functions | |
| static PXmlDoc | New () |
| static PXmlDoc | New (const PXmlTok &Tok) |
| static PXmlDoc | Load (TSIn &SIn) |
| 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) |
| static PXmlDoc | LoadStr (const TStr &Str) |
Static Private Member Functions | |
| static void | LoadTxtMiscStar (TXmlLx &Lx) |
| static PXmlTok | LoadTxtElement (TXmlLx &Lx) |
Private Attributes | |
| TCRef | CRef |
| bool | Ok |
| TStr | MsgStr |
| PXmlTok | Tok |
Friends | |
| class | TPt< TXmlDoc > |
| TXmlDoc::TXmlDoc | ( | const PXmlTok & | _Tok | ) | [inline] |
| TXmlDoc::TXmlDoc | ( | TSIn & | ) | [inline] |
| TStr TXmlDoc::GetMsgStr | ( | ) | const [inline] |
| PXmlTok TXmlDoc::GetTagTok | ( | const TStr & | TagPath | ) | const |
| 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 TXmlDoc::GetTagTokStr | ( | const TStr & | TagPath | ) | const [inline] |
| void TXmlDoc::GetTagTokV | ( | const TStr & | TagPath, |
| TXmlTokV & | XmlTokV | ||
| ) | const |
Definition at line 1319 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);}
}
}
}
| TStr TXmlDoc::GetTagVal | ( | const TStr & | TagNm, |
| const bool & | XmlP | ||
| ) | const [inline] |
Definition at line 361 of file xml.h.
{
TStrV ValV; GetTagValV(TagNm, XmlP, ValV);
if (ValV.Len()>0){return ValV[0];} else {return "";}}
| void TXmlDoc::GetTagValV | ( | const TStr & | TagNm, |
| const bool & | XmlP, | ||
| TStrV & | ValV | ||
| ) | const [inline] |
| PXmlTok TXmlDoc::GetTok | ( | ) | const [inline] |
| TStr TXmlDoc::GetXmlStr | ( | const TStr & | Str | ) | [static] |
Definition at line 1364 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;
}
| bool TXmlDoc::IsOk | ( | ) | const [inline] |
| bool TXmlDoc::IsTagTok | ( | const TStr & | TagPath, |
| PXmlTok & | TagTok | ||
| ) | const [inline] |
| bool TXmlDoc::IsTagTok | ( | const TStr & | TagPath | ) | const [inline] |
| static PXmlDoc TXmlDoc::Load | ( | TSIn & | SIn | ) | [inline, static] |
| PXmlDoc TXmlDoc::LoadStr | ( | const TStr & | Str | ) | [static] |
Definition at line 1443 of file xml.cpp.
{
PSIn SIn=TStrIn::New(Str);
return LoadTxt(SIn);
}
| PXmlDoc TXmlDoc::LoadTxt | ( | TXmlLx & | Lx | ) | [static] |
Definition at line 1401 of file xml.cpp.
{
PXmlDoc Doc=TXmlDoc::New();
// [1] document ::= prolog element Misc*
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);
Doc->Tok=LoadTxtElement(Lx);
LoadTxtMiscStar(Lx);
Doc->Ok=true; Doc->MsgStr="Ok";
}
catch (PExcept& Except){
Doc->Ok=false; Doc->MsgStr=Except->GetMsgStr();
}
return Doc;
}
| PXmlDoc TXmlDoc::LoadTxt | ( | const PSIn & | SIn, |
| const TXmlSpacing & | Spacing = xspIntact |
||
| ) | [static] |
| PXmlDoc TXmlDoc::LoadTxt | ( | const TStr & | FNm, |
| const TXmlSpacing & | Spacing = xspIntact |
||
| ) | [static] |
| void TXmlDoc::LoadTxt | ( | const TStr & | FNm, |
| TXmlDocV & | XmlDocV, | ||
| const TXmlSpacing & | Spacing = xspIntact |
||
| ) | [static] |
| PXmlTok TXmlDoc::LoadTxtElement | ( | TXmlLx & | Lx | ) | [static, private] |
Definition at line 1249 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, private] |
| static PXmlDoc TXmlDoc::New | ( | ) | [inline, static] |
| static PXmlDoc TXmlDoc::New | ( | const PXmlTok & | Tok | ) | [inline, static] |
| void TXmlDoc::PutTagTokStr | ( | const TStr & | TagPath, |
| const TStr & | TokStr | ||
| ) | const |
| void TXmlDoc::Save | ( | TSOut & | ) | [inline] |
| void TXmlDoc::SaveStr | ( | TStr & | Str | ) |
| void TXmlDoc::SaveTxt | ( | const PSOut & | SOut | ) | [inline] |
| void TXmlDoc::SaveTxt | ( | const TStr & | FNm, |
| const bool & | Append = false |
||
| ) | [inline] |
Definition at line 385 of file xml.h.
{
PSOut SOut=TFOut::New(FNm, Append); SaveTxt(SOut);}
| bool TXmlDoc::SkipTopTag | ( | const PSIn & | SIn | ) | [static] |
Definition at line 1383 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;
}
TCRef TXmlDoc::CRef [private] |
TStr TXmlDoc::MsgStr [private] |
bool TXmlDoc::Ok [private] |
PXmlTok TXmlDoc::Tok [private] |