SNAP Library 2.1, Developer 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 | |
TXmlParser (const PSIn &_SIn) | |
TXmlLxSym | GetSym () |
TXmlLxSym | GetSym (TChA &_SymStr) |
TXmlLxSym | PeekSym () |
TXmlLxSym | PeekSym (TChA &_SymStr) |
void | SkipTillTag (const TChA &_SymStr) |
TXmlLxSym | GetTag (const TChA &TagStr) |
void | GetTagVal (const TChA &TagStr, TChA &TagVal) |
Static Public Member Functions | |
static PXmlParser | New (const PSIn &SIn) |
static void | GetPlainStrFromXmlStr (const TChA &XmlStr, TChA &PlainChA) |
Public Attributes | |
TXmlLxSym | Sym |
TXmlLxSym | NextSym |
TChA | SymStr |
TChA | NextSymStr |
Private Member Functions | |
char | GetCh () |
Private Attributes | |
TCRef | CRef |
PSIn | SIn |
TSIn & | RSIn |
TChA | _SymStr |
Friends | |
class | TPt< TXmlParser > |
TXmlParser::TXmlParser | ( | const PSIn & | _SIn | ) | [inline] |
char TXmlParser::GetCh | ( | ) | [inline, private] |
Definition at line 407 of file xml.h.
References TSIn::Eof(), TCh::EofCh, TSIn::GetCh(), and RSIn.
Referenced by GetSym().
{ return (! RSIn.Eof()) ? RSIn.GetCh() : TCh::EofCh; }
void TXmlParser::GetPlainStrFromXmlStr | ( | const TChA & | XmlStr, |
TChA & | PlainChA | ||
) | [static] |
Definition at line 1531 of file xml.cpp.
References TChA::Clr(), TChA::CStr(), TChA::Empty(), forever, TCh::GetHex(), TCh::GetNum(), TCh::IsHex(), and TCh::IsNum().
Referenced by GetSym().
{ static TChA EntityNm; PlainChA.Clr(); const char *Ch = XmlStr.CStr(); while (*Ch){ if (*Ch!='&'){ PlainChA+=*Ch; Ch++; } else { if (*++Ch=='#'){ TChA RefChA; int RefCd=0; if (*++Ch=='x'){ forever { Ch++; if (TCh::IsHex(*Ch)){ RefChA+=*Ch; RefCd=RefCd*16+TCh::GetHex(*Ch); } else { break; } } } else { // decimal character code forever { if (TCh::IsNum(*Ch)){ RefChA+=*Ch; RefCd=RefCd*10+TCh::GetNum(*Ch); } else { break; } Ch++; } } if ((!RefChA.Empty())&&(*Ch==';')){ Ch++; const uchar RefCh=uchar(RefCd); PlainChA+=RefCh; } } else { EntityNm.Clr(); while ((*Ch)&&(*Ch!=';')){EntityNm+=*Ch; Ch++;} if ((!EntityNm.Empty())&&(*Ch==';')){ Ch++; if (EntityNm=="quot"){PlainChA+='"';} else if (EntityNm=="amp"){PlainChA+='&';} else if (EntityNm=="apos"){PlainChA+='\'';} else if (EntityNm=="lt"){PlainChA+='<';} else if (EntityNm=="gt"){PlainChA+='>';} } } } } }
Definition at line 1457 of file xml.cpp.
References _SymStr, TChA::Clr(), TChA::CStr(), TSIn::Eof(), TCh::EofCh, GetCh(), GetPlainStrFromXmlStr(), TCh::IsWs(), TChA::Len(), NextSym, NextSymStr, TSIn::PeekCh(), TChA::Push(), RSIn, Sym, SymStr, xsyEof, xsyETag, xsySTag, xsyStr, and xsyUndef.
Referenced by GetSym(), GetTag(), GetTagVal(), PeekSym(), and SkipTillTag().
{ if (NextSym != xsyUndef) { Sym = NextSym; NextSym=xsyUndef; SymStr=NextSymStr; NextSymStr.Clr(); return Sym; } SymStr.Clr(); char Ch; while (TCh::IsWs(Ch=GetCh())) { } if (Ch == TCh::EofCh) { Sym = xsyEof; return xsyEof; } if (Ch == '<') { // load tag Ch = GetCh(); if (Ch == '/') { Sym = xsyETag; } else { Sym = xsySTag; SymStr.Push(Ch); } while((Ch=GetCh())!='>' && Ch!=TCh::EofCh) { SymStr.Push(Ch); } const int StrLen = SymStr.Len(); if (StrLen > 1 && SymStr[StrLen-1] == '/') { Sym = xsyETag; SymStr[StrLen-1] = 0; for (char *c = SymStr.CStr()+StrLen-2; TCh::IsWs(*c); c--) { *c=0; } } } else { // load string _SymStr.Clr(); _SymStr.Push(Ch); while (! RSIn.Eof() && RSIn.PeekCh() != '<') { _SymStr.Push(GetCh()); } GetPlainStrFromXmlStr(_SymStr, SymStr); Sym = xsyStr; } if (Ch == TCh::EofCh) { SymStr.Clr(); Sym = xsyEof; return xsyEof; } return Sym; }
TXmlLxSym TXmlParser::GetSym | ( | TChA & | _SymStr | ) |
TXmlLxSym TXmlParser::GetTag | ( | const TChA & | TagStr | ) |
Definition at line 1524 of file xml.cpp.
References TChA::CStr(), EAssertR, TStr::Fmt(), GetSym(), Sym, and SymStr.
Referenced by GetTagVal().
{ GetSym(); EAssertR(TagStr==SymStr, TStr::Fmt("Expected xml symbol '%s'. Found '%s'", TagStr.CStr(), SymStr.CStr()).CStr()); return Sym; }
void TXmlParser::GetTagVal | ( | const TChA & | TagStr, |
TChA & | TagVal | ||
) |
Definition at line 1518 of file xml.cpp.
References TChA::CStr(), EAssertR, TStr::Fmt(), GetSym(), GetTag(), SymStr, xsyETag, xsySTag, and xsyStr.
{ EAssertR(GetTag(TagStr) == xsySTag, TStr::Fmt("Expected '<%s>'. Found '%s'", TagStr.CStr(), SymStr.CStr()).CStr()); EAssertR(GetSym(TagVal) == xsyStr, "Expected string tag."); EAssertR(GetTag(TagStr) == xsyETag, TStr::Fmt("Expected '</%s>'. Found '%s'", TagStr.CStr(), SymStr.CStr()).CStr()); }
static PXmlParser TXmlParser::New | ( | const PSIn & | SIn | ) | [inline, static] |
Definition at line 410 of file xml.h.
References TXmlParser().
{ return new TXmlParser(SIn); }
Definition at line 1493 of file xml.cpp.
References GetSym(), NextSym, NextSymStr, Sym, SymStr, and xsyUndef.
Referenced by PeekSym(), and SkipTillTag().
{ if (NextSym == xsyUndef) { const TXmlLxSym TmpSim=Sym; const TChA TmpSymStr=SymStr; NextSym=GetSym(NextSymStr); Sym=TmpSim; SymStr=TmpSymStr; } return NextSym; }
TXmlLxSym TXmlParser::PeekSym | ( | TChA & | _SymStr | ) |
Definition at line 1504 of file xml.cpp.
References NextSym, NextSymStr, and PeekSym().
{ PeekSym(); _SymStr = NextSymStr; return NextSym; }
void TXmlParser::SkipTillTag | ( | const TChA & | _SymStr | ) |
Definition at line 1510 of file xml.cpp.
References GetSym(), NextSymStr, PeekSym(), and xsyEof.
{ while(PeekSym() != xsyEof) { if (NextSymStr == _SymStr) { return; } GetSym(); } }
friend class TPt< TXmlParser > [friend] |
TChA TXmlParser::_SymStr [private] |
TCRef TXmlParser::CRef [private] |
Definition at line 405 of file xml.h.
Referenced by GetSym(), PeekSym(), and SkipTillTag().
TSIn& TXmlParser::RSIn [private] |
PSIn TXmlParser::SIn [private] |