SNAP Library 2.0, User Reference  2013-05-13 16:33:57
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
TXmlTok Class Reference

#include <xml.h>

List of all members.

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 &)
TXmlTokoperator= (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 >

Detailed Description

Definition at line 198 of file xml.h.


Constructor & Destructor Documentation

TXmlTok::TXmlTok ( ) [inline]

Definition at line 205 of file xml.h.

TXmlTok::TXmlTok ( const TXmlLxSym _Sym) [inline]

Definition at line 206 of file xml.h.

                                :
    Sym(_Sym), Str(), ArgNmValV(), SubTokV(){}
TXmlTok::TXmlTok ( const TXmlLxSym _Sym,
const TStr _Str 
) [inline]

Definition at line 208 of file xml.h.

                                                  :
    Sym(_Sym), Str(_Str), ArgNmValV(), SubTokV(){}
TXmlTok::TXmlTok ( const TXmlLxSym _Sym,
const TStr _Str,
const TStrKdV _ArgNmValV 
) [inline]

Definition at line 210 of file xml.h.

                                                                             :
    Sym(_Sym), Str(_Str), ArgNmValV(_ArgNmValV){}
TXmlTok::TXmlTok ( TSIn ) [inline]

Definition at line 234 of file xml.h.

{Fail;}

Member Function Documentation

void TXmlTok::AddArg ( const TStr ArgNm,
const bool &  ArgVal 
) [inline]

Definition at line 252 of file xml.h.

                                                    {
    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.

                                                   {
    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.

                                                      {
    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.

                                                      {
    ArgNmValV.Add(TStrKd(ArgNm, TFlt::GetStr(ArgVal)));}
void TXmlTok::AddArg ( const TStr ArgNm,
const TStr ArgVal 
) [inline]

Definition at line 260 of file xml.h.

                                                    {
    ArgNmValV.Add(TStrKd(ArgNm, ArgVal));}
void TXmlTok::AddSubTok ( const PXmlTok Tok) [inline]

Definition at line 292 of file xml.h.

{SubTokV.Add(Tok);}
void TXmlTok::AddTokToChA ( const bool &  XmlP,
TChA ChA 
) const

Definition at line 1185 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;
  }
}
void TXmlTok::ClrSubTok ( ) [inline]

Definition at line 295 of file xml.h.

{SubTokV.Clr();}
void TXmlTok::GetArg ( const int &  ArgN,
TStr ArgNm,
TStr ArgVal 
) const [inline]

Definition at line 263 of file xml.h.

                                                                {
    ArgNm=ArgNmValV[ArgN].Key; ArgVal=ArgNmValV[ArgN].Dat;}
int TXmlTok::GetArgs ( ) const [inline]

Definition at line 262 of file xml.h.

{return ArgNmValV.Len();}
TStr TXmlTok::GetArgVal ( const TStr ArgNm) const [inline]

Definition at line 273 of file xml.h.

                                          {
    return ArgNmValV[ArgNmValV.SearchForw(TStrKd(ArgNm))].Dat;}
TStr TXmlTok::GetArgVal ( const TStr ArgNm,
const TStr DfArgVal 
) const [inline]

Definition at line 275 of file xml.h.

                                                                {
    int ArgN=ArgNmValV.SearchForw(TStrKd(ArgNm));
    return (ArgN==-1) ? DfArgVal : ArgNmValV[ArgN].Dat;}
bool TXmlTok::GetBoolArgVal ( const TStr ArgNm,
const bool &  DfVal = false 
) const

Definition at line 1089 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

Definition at line 1094 of file xml.cpp.

                                                                  {
  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 1100 of file xml.cpp.

                                                                     {
  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 1119 of file xml.cpp.

                                                                         {
  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 1109 of file xml.cpp.

                                                                   {
  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.

{return Str;}
TStr TXmlTok::GetStrArgVal ( const TStr ArgNm,
const TStr DfVal = TStr() 
) const

Definition at line 1129 of file xml.cpp.

                                                                     {
  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.

{return SubTokV[SubTokN];}
int TXmlTok::GetSubToks ( ) const [inline]

Definition at line 293 of file xml.h.

{return SubTokV.Len();}
TXmlLxSym TXmlTok::GetSym ( ) const [inline]

Definition at line 241 of file xml.h.

{return Sym;}
TStr TXmlTok::GetSymStr ( ) const [inline]

Definition at line 242 of file xml.h.

TStr TXmlTok::GetTagNm ( ) const [inline]

Definition at line 249 of file xml.h.

{IAssert(Sym==xsyTag); return Str;}
PXmlTok TXmlTok::GetTagTok ( const TStr TagPath) const

Definition at line 1142 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);}
  }
}
TStr TXmlTok::GetTagTokStr ( const TStr TagPath) const [inline]

Definition at line 307 of file xml.h.

                                               {
    return GetTagTok(TagPath)->GetTokStr(false);}
TStr TXmlTok::GetTagTokStrOrDf ( const TStr TagPath,
const TStr DfVal = TStr() 
) const [inline]

Definition at line 309 of file xml.h.

                                                                             {
    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 1158 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 TXmlTok::GetTagVal ( const TStr TagNm,
const bool &  XmlP 
) const

Definition at line 1180 of file xml.cpp.

                                                                 {
  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 1171 of file xml.cpp.

                                                                               {
  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 1228 of file xml.cpp.

                                 {
  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.

                                              {
    TChA ChA; AddTokToChA(XmlP, ChA); return ChA;}
TStr TXmlTok::GetTokVStr ( const TXmlTokV TokV,
const bool &  XmlP = true 
) [static]

Definition at line 1219 of file xml.cpp.

                                                              {
  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.

                                      {
    return ArgNmValV.SearchForw(TStrKd(ArgNm))!=-1;}
bool TXmlTok::IsArg ( const TStr ArgNm,
TStr ArgVal 
) const [inline]

Definition at line 267 of file xml.h.

                                                    {
    int ArgN=ArgNmValV.SearchForw(TStrKd(ArgNm));
    if (ArgN!=-1){ArgVal=ArgNmValV[ArgN].Dat;}
    return ArgN!=-1;}
bool TXmlTok::IsSubTag ( const TStr TagNm) const [inline]

Definition at line 288 of file xml.h.

                                         {
    return !GetTagTok(TagNm).Empty();}
bool TXmlTok::IsSubTag ( const TStr TagNm,
PXmlTok Tok 
) const [inline]

Definition at line 290 of file xml.h.

                                                       {
    Tok=GetTagTok(TagNm); return !Tok.Empty();}
bool TXmlTok::IsTag ( ) const [inline]

Definition at line 247 of file xml.h.

{return (Sym==xsyTag);}
bool TXmlTok::IsTag ( const TStr TagNm) const [inline]

Definition at line 248 of file xml.h.

{return (Sym==xsyTag)&&(Str==TagNm);}
bool TXmlTok::IsTagTok ( const TStr TagPath,
PXmlTok TagTok 
) const [inline]

Definition at line 299 of file xml.h.

                                                            {
    TagTok=GetTagTok(TagPath); return !TagTok.Empty();}
bool TXmlTok::IsTagTok ( const TStr TagPath) const [inline]

Definition at line 301 of file xml.h.

                                           {
    PXmlTok TagTok; return IsTagTok(TagPath, TagTok);}
static PXmlTok TXmlTok::Load ( TSIn ) [inline, static]

Definition at line 235 of file xml.h.

{Fail; return NULL;}
static PXmlTok TXmlTok::New ( ) [inline, static]

Definition at line 212 of file xml.h.

{return PXmlTok(new TXmlTok());}
static PXmlTok TXmlTok::New ( const TXmlLxSym Sym) [inline, static]

Definition at line 213 of file xml.h.

{return PXmlTok(new TXmlTok(Sym));}
static PXmlTok TXmlTok::New ( const TXmlLxSym Sym,
const TStr Str 
) [inline, static]

Definition at line 214 of file xml.h.

                                                           {
    return PXmlTok(new TXmlTok(Sym, Str));}
static PXmlTok TXmlTok::New ( const TXmlLxSym Sym,
const TStr Str,
const TStrKdV ArgNmValV 
) [inline, static]

Definition at line 216 of file xml.h.

                                                                   {
    return PXmlTok(new TXmlTok(Sym, Str, ArgNmValV));}
static PXmlTok TXmlTok::New ( const TStr TagNm,
const TStrKdV ArgNmValV 
) [inline, static]

Definition at line 219 of file xml.h.

                                               {
    return PXmlTok(new TXmlTok(xsyTag, TagNm, ArgNmValV));}
static PXmlTok TXmlTok::New ( const TStr TagNm) [inline, static]

Definition at line 222 of file xml.h.

                                       {
    return PXmlTok(new TXmlTok(xsyTag, TagNm));}
static PXmlTok TXmlTok::New ( const TStr TagNm,
const TStr ValStr 
) [inline, static]

Definition at line 224 of file xml.h.

                                                           {
    PXmlTok TagXmlTok=PXmlTok(new TXmlTok(xsyTag, TagNm));
    PXmlTok StrXmlTok=PXmlTok(new TXmlTok(xsyStr, ValStr));
    TagXmlTok->AddSubTok(StrXmlTok); return TagXmlTok;}
static PXmlTok TXmlTok::New ( const TStr TagNm,
const PXmlTok XmlTok1,
const PXmlTok XmlTok2 = NULL 
) [inline, static]

Definition at line 228 of file xml.h.

                                                       {
    PXmlTok TagXmlTok=PXmlTok(new TXmlTok(xsyTag, TagNm));
    if (!XmlTok1.Empty()){TagXmlTok->AddSubTok(XmlTok1);}
    if (!XmlTok2.Empty()){TagXmlTok->AddSubTok(XmlTok2);}
    return TagXmlTok;}
TXmlTok& TXmlTok::operator= ( const TXmlTok ) [inline]

Definition at line 238 of file xml.h.

{Fail; return *this;}
void TXmlTok::PutArgVal ( const TStr ArgNm,
const TStr ArgVal 
) [inline]

Definition at line 271 of file xml.h.

                                                       {
    ArgNmValV[ArgNmValV.SearchForw(TStrKd(ArgNm))].Dat=ArgVal;}
void TXmlTok::PutStr ( const TStr _Str) [inline]

Definition at line 243 of file xml.h.

{Str=_Str;}
void TXmlTok::PutSubTok ( const PXmlTok Tok,
const int &  SubTokN = -1 
)

Definition at line 1134 of file xml.cpp.

                                                             {
  if (SubTokN==-1){
    ClrSubTok(); AddSubTok(Tok);
  } else {
    SubTokV[SubTokN]=Tok;
  }
}
void TXmlTok::Save ( TSOut ) [inline]

Definition at line 236 of file xml.h.

{Fail;}

Friends And Related Function Documentation

friend class TPt< TXmlTok > [friend]

Definition at line 198 of file xml.h.


Member Data Documentation

Definition at line 202 of file xml.h.

TCRef TXmlTok::CRef [private]

Definition at line 198 of file xml.h.

TStr TXmlTok::Str [private]

Definition at line 201 of file xml.h.

Definition at line 203 of file xml.h.

Definition at line 200 of file xml.h.


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