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
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TXmlParser Class Reference

#include <xml.h>

Collaboration diagram for TXmlParser:

List of all members.

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
TSInRSIn
TChA _SymStr

Friends

class TPt< TXmlParser >

Detailed Description

Definition at line 397 of file xml.h.


Constructor & Destructor Documentation

TXmlParser::TXmlParser ( const PSIn _SIn) [inline]

Definition at line 409 of file xml.h.

Referenced by New().

: SIn(_SIn), RSIn(*SIn), Sym(xsyUndef), NextSym(xsyUndef) { }

Here is the caller graph for this function:


Member Function Documentation

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

Here is the call graph for this function:

Here is the caller graph for this function:

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+='>';}
        }
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1487 of file xml.cpp.

References GetSym(), Sym, and SymStr.

                                          {
  GetSym();
  _SymStr = SymStr;
  return Sym;
}

Here is the call graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

static PXmlParser TXmlParser::New ( const PSIn SIn) [inline, static]

Definition at line 410 of file xml.h.

References TXmlParser().

{ return new TXmlParser(SIn); }

Here is the call graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1504 of file xml.cpp.

References NextSym, NextSymStr, and PeekSym().

                                           {
  PeekSym();
  _SymStr = NextSymStr;
  return NextSym;
}

Here is the call graph for this function:

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

Here is the call graph for this function:


Friends And Related Function Documentation

friend class TPt< TXmlParser > [friend]

Definition at line 422 of file xml.h.


Member Data Documentation

Definition at line 402 of file xml.h.

Referenced by GetSym().

Definition at line 399 of file xml.h.

Definition at line 404 of file xml.h.

Referenced by GetSym(), and PeekSym().

Definition at line 405 of file xml.h.

Referenced by GetSym(), PeekSym(), and SkipTillTag().

TSIn& TXmlParser::RSIn [private]

Definition at line 401 of file xml.h.

Referenced by GetCh(), and GetSym().

PSIn TXmlParser::SIn [private]

Definition at line 400 of file xml.h.

Definition at line 404 of file xml.h.

Referenced by GetSym(), GetTag(), and PeekSym().

Definition at line 405 of file xml.h.

Referenced by GetSym(), GetTag(), GetTagVal(), and PeekSym().


The documentation for this class was generated from the following files: