SNAP Library 6.0, Developer Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
xml.h
Go to the documentation of this file.
1 #include "bd.h"
2 
4 // Xml-Object-Serialization
5 class TXmlObjSer{
6 private:
8 public:
9  static TStr GetTagNm(const TStr& TypeNm);
10  static void AssertXmlHd(
11  const PXmlTok& XmlTok, const TStr& Nm, const TStr& TypeNm);
12  static bool GetBoolArg(const PXmlTok& XmlTok, const TStr& Nm);
13  static int GetIntArg(const PXmlTok& XmlTok, const TStr& Nm);
14  static int64 GetInt64Arg(const PXmlTok& XmlTok, const TStr& Nm);
15  static double GetFltArg(const PXmlTok& XmlTok, const TStr& Nm);
16 };
17 
19 // Xml-Object-Serialization-Tag-Name
21 private:
25 public:
27  TSOut& _SOut, const bool& ETagP,
28  const TStr& Nm, const TStr& TypeNm,
29  const TStr& ArgNm="", const TStr& ArgVal="");
31  TSOut& _SOut, const bool& ETagP,
32  const TStr& Nm, const TStr& TypeNm,
33  const TStr& ArgNm1, const TStr& ArgVal1,
34  const TStr& ArgNm2, const TStr& ArgVal2,
35  const TStr& ArgNm3="", const TStr& ArgVal3="",
36  const TStr& ArgNm4="", const TStr& ArgVal4="");
38 };
39 
41 // Xml-Char-Definition
43 private:
44  TInt Chs;
45  TBSet CharChSet, CombChSet, ExtChSet;
46  TBSet LetterChSet, DigitChSet, NameChSet, PubidChSet;
47  TStrStrH EntityNmToValH;
48  void SetChTy(TBSet& ChSet, const int& MnCh, const int& MxCh=-1);
49  void SetChTy(TBSet& ChSet, const TStr& Str);
50  void SetEntityVal(const TStr& Nm, const TStr& Val);
51 public:
52  TXmlChDef();
53  TXmlChDef(TSIn& SIn):
54  Chs(SIn),
55  CharChSet(SIn), CombChSet(SIn), ExtChSet(SIn),
56  LetterChSet(SIn), DigitChSet(SIn), NameChSet(SIn), PubidChSet(SIn),
57  EntityNmToValH(SIn){}
58  static PXmlChDef Load(TSIn& SIn){return new TXmlChDef(SIn);}
59  void Save(TSOut& SOut){
60  Chs.Save(SOut);
61  CharChSet.Save(SOut); CombChSet.Save(SOut); ExtChSet.Save(SOut);
62  LetterChSet.Save(SOut); DigitChSet.Save(SOut); NameChSet.Save(SOut);
63  PubidChSet.Save(SOut);
64  EntityNmToValH.Save(SOut);}
65 
66  TXmlChDef& operator=(const TXmlChDef&){Fail; return *this;}
67 
68  bool IsChar(const uchar& Ch) const {return CharChSet.GetBit(Ch);}
69  bool IsComb(const uchar& Ch) const {return CombChSet.GetBit(Ch);}
70  bool IsExt(const uchar& Ch) const {return ExtChSet.GetBit(Ch);}
71  bool IsLetter(const uchar& Ch) const {return LetterChSet.GetBit(Ch);}
72  bool IsDigit(const uchar& Ch) const {return DigitChSet.GetBit(Ch);}
73  bool IsName(const uchar& Ch) const {return NameChSet.GetBit(Ch);}
74  bool IsPubid(const uchar& Ch) const {return PubidChSet.GetBit(Ch);}
75 
76  bool IsWs(const uchar& Ch) const {
77  return (Ch==' ')||(Ch==TCh::CrCh)||(Ch==TCh::LfCh)||(Ch==TCh::TabCh);}
78  bool IsFirstNameCh(const uchar& Ch) const {
79  return IsLetter(Ch)||(Ch=='_')||(Ch==':');}
80  bool IsEoln(const uchar& Ch) const {
81  return (Ch==TCh::CrCh)||(Ch==TCh::LfCh);}
82 
83  bool IsEntityNm(const TStr& EntityNm, TStr& EntityVal) const {
84  return EntityNmToValH.IsKeyGetDat(EntityNm, EntityVal);}
85 };
86 
88 // Xml-Lexical
89 typedef enum {
95 
97 
98 class TXmlLx{
99 private: // character level functions
100  static TXmlChDef ChDef;
105  int LnN, LnChN, ChN;
107  uchar GetCh();
108  void PutCh(const uchar& _Ch){ChStack.Push(Ch); Ch=_Ch;}
109  void PutStr(const TStr& Str){
110  for (int ChN=Str.Len()-1; ChN>=0; ChN--){PutCh(Str[ChN]);}}
111  void ToNrSpacing();
112 private: // part-of-symbol level functions
114  void GetWs(const bool& IsRq);
115  TStr GetReference();
116  void GetEq();
117  TStr GetName();
118  TStr GetName(const TStr& RqNm);
119  void GetComment();
120  TStr GetAttValue();
122  TStr GetEncName();
123  TStr GetStalVal();
124  void GetXmlDecl();
125  void GetPI();
129  void GetExternalId();
130  void GetNData();
131  void GetDocTypeDecl();
132  void GetElement();
133  void GetAttList();
135  void GetEntity();
136  void GetNotation();
137  void GetCDSect();
138 public: // symbol state
143  void SkipWs();
144 public:
145  TXmlLx(const PSIn& _SIn, const TXmlSpacing& _Spacing=xspIntact):
146  SIn(_SIn), RSIn(*SIn),
147  ChStack(), PrevCh(' '), Ch(' '),
148  LnN(1), LnChN(0), ChN(0), Spacing(_Spacing),
149  EntityNmToValH(100), PEntityNmToValH(100),
150  Sym(xsyUndef), TxtChA(), TagNm(), ArgNmValKdV(10){GetCh();}
151 
152  TXmlLx& operator=(const TXmlLx&){Fail; return *this;}
153 
154  TXmlLxSym GetSym();
155  TStr GetSymStr() const;
156  void EThrow(const TStr& MsgStr) const;
157  TStr GetFPosStr() const;
158 
159  // tag arguments
160  void ClrArgV(){ArgNmValKdV.Clr();}
161  void AddArg(const TStr& ArgNm, const TStr& ArgVal){
162  ArgNmValKdV.Add(TStrKd(ArgNm, ArgVal));}
163  bool IsArgNm(const TStr& ArgNm) const {
164  return ArgNmValKdV.IsIn(TStrKd(ArgNm));}
165  int GetArgs() const {return ArgNmValKdV.Len();}
166  void GetArg(const int& ArgN, TStr& ArgNm, TStr& ArgVal) const {
167  ArgNm=ArgNmValKdV[ArgN].Key; ArgVal=ArgNmValKdV[ArgN].Dat;}
168  TStr GetArgVal(const TStr& ArgNm, const TStr& DfVal=TStr()) const {
169  int ArgN=ArgNmValKdV.SearchForw(TStrKd(ArgNm));
170  if (ArgN==-1){return DfVal;} else {return ArgNmValKdV[ArgN].Dat;}}
171  static char GetArgValQCh(const TStr& ArgVal){
172  if (ArgVal.IsChIn('\"')){return '\'';} else {return '\"';}}
173 
174  // entities
175  bool IsEntityNm(const TStr& EntityNm, TStr& EntityVal) const {
176  return EntityNmToValH.IsKeyGetDat(EntityNm, EntityVal);}
177  void PutEntityVal(const TStr& Nm, const TStr& Val){
178  EntityNmToValH.AddDat(Nm, Val);}
179  bool IsPEntityNm(const TStr& EntityNm, TStr& EntityVal) const {
180  return PEntityNmToValH.IsKeyGetDat(EntityNm, EntityVal);}
181  void PutPEntityVal(const TStr& Nm, const TStr& Val){
182  PEntityNmToValH.AddDat(Nm, Val);}
183 
184  // symbol to string conversion
185  static TStr GetXmlLxSymStr(const TXmlLxSym& XmlLxSym);
186 
187  // string conversion
188  static bool IsTagNm(const TStr& Str);
189  static TStr GetXmlStrFromPlainMem(const TMem& PlainMem);
190  static TStr GetXmlStrFromPlainStr(const TChA& PlainChA);
191  static TStr GetPlainStrFromXmlStr(const TStr& XmlStr);
192  static TStr GetUsAsciiStrFromXmlStr(const TStr& EntRefStr);
193  static TStr GetChRefFromYuEntRef(const TStr& YuEntRefStr);
194 };
195 
197 // Xml-Token
199 private:
201  TStr Str;
202  TStrKdV ArgNmValV;
203  TXmlTokV SubTokV;
204 public:
205  TXmlTok(): Sym(xsyUndef), Str(), ArgNmValV(), SubTokV(){}
206  TXmlTok(const TXmlLxSym& _Sym):
207  Sym(_Sym), Str(), ArgNmValV(), SubTokV(){}
208  TXmlTok(const TXmlLxSym& _Sym, const TStr& _Str):
209  Sym(_Sym), Str(_Str), ArgNmValV(), SubTokV(){}
210  TXmlTok(const TXmlLxSym& _Sym, const TStr& _Str, const TStrKdV& _ArgNmValV):
211  Sym(_Sym), Str(_Str), ArgNmValV(_ArgNmValV){}
212  static PXmlTok New(){return PXmlTok(new TXmlTok());}
213  static PXmlTok New(const TXmlLxSym& Sym){return PXmlTok(new TXmlTok(Sym));}
214  static PXmlTok New(const TXmlLxSym& Sym, const TStr& Str){
215  return PXmlTok(new TXmlTok(Sym, Str));}
216  static PXmlTok New(
217  const TXmlLxSym& Sym, const TStr& Str, const TStrKdV& ArgNmValV){
218  return PXmlTok(new TXmlTok(Sym, Str, ArgNmValV));}
219  static PXmlTok New(
220  const TStr& TagNm, const TStrKdV& ArgNmValV){
221  return PXmlTok(new TXmlTok(xsyTag, TagNm, ArgNmValV));}
222  static PXmlTok New(const TStr& TagNm){
223  return PXmlTok(new TXmlTok(xsyTag, TagNm));}
224  static PXmlTok New(const TStr& TagNm, const TStr& ValStr){
225  PXmlTok TagXmlTok=PXmlTok(new TXmlTok(xsyTag, TagNm));
226  PXmlTok StrXmlTok=PXmlTok(new TXmlTok(xsyStr, ValStr));
227  TagXmlTok->AddSubTok(StrXmlTok); return TagXmlTok;}
228  static PXmlTok New(const TStr& TagNm,
229  const PXmlTok& XmlTok1, const PXmlTok& XmlTok2=NULL){
230  PXmlTok TagXmlTok=PXmlTok(new TXmlTok(xsyTag, TagNm));
231  if (!XmlTok1.Empty()){TagXmlTok->AddSubTok(XmlTok1);}
232  if (!XmlTok2.Empty()){TagXmlTok->AddSubTok(XmlTok2);}
233  return TagXmlTok;}
235  static PXmlTok Load(TSIn&){Fail; return NULL;}
236  void Save(TSOut&){Fail;}
237 
238  TXmlTok& operator=(const TXmlTok&){Fail; return *this;}
239 
240  // type-of-token and text value (xsyWs, xsyStr, xsyQStr, xsyTag)
241  TXmlLxSym GetSym() const {return Sym;}
242  TStr GetSymStr() const {return TXmlLx::GetXmlLxSymStr(Sym);}
243  void PutStr(const TStr& _Str){Str=_Str;}
244  TStr GetStr() const {return Str;}
245 
246  // tags
247  bool IsTag() const {return (Sym==xsyTag);}
248  bool IsTag(const TStr& TagNm) const {return (Sym==xsyTag)&&(Str==TagNm);}
249  TStr GetTagNm() const {IAssert(Sym==xsyTag); return Str;}
250 
251  // tag argument
252  void AddArg(const TStr& ArgNm, const bool& ArgVal){
253  ArgNmValV.Add(TStrKd(ArgNm, TBool::GetStr(ArgVal)));}
254  void AddArg(const TStr& ArgNm, const int& ArgVal){
255  ArgNmValV.Add(TStrKd(ArgNm, TInt::GetStr(ArgVal)));}
256  void AddArg(const TStr& ArgNm, const uint64& ArgVal){
257  ArgNmValV.Add(TStrKd(ArgNm, TUInt64::GetStr(ArgVal)));}
258  void AddArg(const TStr& ArgNm, const double& ArgVal){
259  ArgNmValV.Add(TStrKd(ArgNm, TFlt::GetStr(ArgVal)));}
260  void AddArg(const TStr& ArgNm, const TStr& ArgVal){
261  ArgNmValV.Add(TStrKd(ArgNm, ArgVal));}
262  int GetArgs() const {return ArgNmValV.Len();}
263  void GetArg(const int& ArgN, TStr& ArgNm, TStr& ArgVal) const {
264  ArgNm=ArgNmValV[ArgN].Key; ArgVal=ArgNmValV[ArgN].Dat;}
265  bool IsArg(const TStr& ArgNm) const {
266  return ArgNmValV.SearchForw(TStrKd(ArgNm))!=-1;}
267  bool IsArg(const TStr& ArgNm, TStr& ArgVal) const {
268  int ArgN=ArgNmValV.SearchForw(TStrKd(ArgNm));
269  if (ArgN!=-1){ArgVal=ArgNmValV[ArgN].Dat;}
270  return ArgN!=-1;}
271  void PutArgVal(const TStr& ArgNm, const TStr& ArgVal){
272  ArgNmValV[ArgNmValV.SearchForw(TStrKd(ArgNm))].Dat=ArgVal;}
273  TStr GetArgVal(const TStr& ArgNm) const {
274  return ArgNmValV[ArgNmValV.SearchForw(TStrKd(ArgNm))].Dat;}
275  TStr GetArgVal(const TStr& ArgNm, const TStr& DfArgVal) const {
276  int ArgN=ArgNmValV.SearchForw(TStrKd(ArgNm));
277  return (ArgN==-1) ? DfArgVal : ArgNmValV[ArgN].Dat;}
278  bool GetBoolArgVal(const TStr& ArgNm, const bool& DfVal=false) const;
279  bool GetBoolArgVal(
280  const TStr& ArgNm, const TStr& TrueVal, const bool& DfVal=false) const;
281  bool GetBoolArgVal(const TStr& ArgNm,
282  const TStr& TrueVal, const TStr& FalseVal, const bool& DfVal=false) const;
283  int GetIntArgVal(const TStr& ArgNm, const int& DfVal=0) const;
284  double GetFltArgVal(const TStr& ArgNm, const double& DfVal=0) const;
285  TStr GetStrArgVal(const TStr& ArgNm, const TStr& DfVal=TStr()) const;
286 
287  // sub tokens
288  bool IsSubTag(const TStr& TagNm) const {
289  return !GetTagTok(TagNm).Empty();}
290  bool IsSubTag(const TStr& TagNm, PXmlTok& Tok) const {
291  Tok=GetTagTok(TagNm); return !Tok.Empty();}
292  void AddSubTok(const PXmlTok& Tok){SubTokV.Add(Tok);}
293  int GetSubToks() const {return SubTokV.Len();}
294  PXmlTok GetSubTok(const int& SubTokN) const {return SubTokV[SubTokN];}
295  void ClrSubTok(){SubTokV.Clr();}
296  void PutSubTok(const PXmlTok& Tok, const int& SubTokN=-1);
297 
298  // value retrieval
299  bool IsTagTok(const TStr& TagPath, PXmlTok& TagTok) const {
300  TagTok=GetTagTok(TagPath); return !TagTok.Empty();}
301  bool IsTagTok(const TStr& TagPath) const {
302  PXmlTok TagTok; return IsTagTok(TagPath, TagTok);}
303  PXmlTok GetTagTok(const TStr& TagPath) const;
304  void GetTagTokV(const TStr& TagPath, TXmlTokV& XmlTokV) const;
305  void GetTagValV(const TStr& TagNm, const bool& XmlP, TStrV& ValV) const;
306  TStr GetTagVal(const TStr& TagNm, const bool& XmlP) const;
307  TStr GetTagTokStr(const TStr& TagPath) const {
308  return GetTagTok(TagPath)->GetTokStr(false);}
309  TStr GetTagTokStrOrDf(const TStr& TagPath, const TStr& DfVal=TStr()) const {
310  PXmlTok TagTok;
311  if (IsTagTok(TagPath, TagTok)){return TagTok->GetTokStr(false);}
312  else {return DfVal;}}
313 
314  // string representation for the token
315  void AddTokToChA(const bool& XmlP, TChA& ChA) const;
316  TStr GetTokStr(const bool& XmlP=true) const {
317  TChA ChA; AddTokToChA(XmlP, ChA); return ChA;}
318  static TStr GetTokVStr(const TXmlTokV& TokV, const bool& XmlP=true);
319 
320  // convert current lexical symbol to token
321  static PXmlTok GetTok(TXmlLx& Lx);
322 };
323 
325 // Xml-Document
327 private:
328  bool Ok;
329  TStr MsgStr;
330  PXmlTok Tok;
331  static void LoadTxtMiscStar(TXmlLx& Lx);
332  static PXmlTok LoadTxtElement(TXmlLx& Lx);
333 public:
334  TXmlDoc(): Ok(false), MsgStr(), Tok(){}
335  static PXmlDoc New(){return PXmlDoc(new TXmlDoc());}
336  TXmlDoc(const PXmlTok& _Tok): Ok(!_Tok.Empty()), MsgStr(), Tok(_Tok){}
337  static PXmlDoc New(const PXmlTok& Tok){return PXmlDoc(new TXmlDoc(Tok));}
339  static PXmlDoc Load(TSIn& SIn){return new TXmlDoc(SIn);}
340  void Save(TSOut&){Fail;}
341 
342  TXmlDoc& operator=(const TXmlDoc&){Fail; return *this;}
343 
344  // component retrieval
345  bool IsOk() const {return Ok;}
346  TStr GetMsgStr() const {return MsgStr;}
347  PXmlTok GetTok() const {IAssert(Ok); return Tok;}
348 
349  // value retrieval
350  bool IsTagTok(const TStr& TagPath, PXmlTok& TagTok) const {
351  IAssert(Ok); TagTok=GetTagTok(TagPath); return !TagTok.Empty();}
352  bool IsTagTok(const TStr& TagPath) const {
353  PXmlTok TagTok; return IsTagTok(TagPath, TagTok);}
354  PXmlTok GetTagTok(const TStr& TagPath) const;
355  void PutTagTokStr(const TStr& TagPath, const TStr& TokStr) const;
356  TStr GetTagTokStr(const TStr& TagPath) const {
357  return GetTagTok(TagPath)->GetTokStr(false);}
358  void GetTagTokV(const TStr& TagPath, TXmlTokV& XmlTokV) const;
359  void GetTagValV(const TStr& TagNm, const bool& XmlP, TStrV& ValV) const {
360  IAssert(Ok); Tok->GetTagValV(TagNm, XmlP, ValV);}
361  TStr GetTagVal(const TStr& TagNm, const bool& XmlP) const {
362  TStrV ValV; GetTagValV(TagNm, XmlP, ValV);
363  if (ValV.Len()>0){return ValV[0];} else {return "";}}
364  bool GetTagTokBoolArgVal(
365  const TStr& TagPath, const TStr& ArgNm, const bool& DfVal=false) const;
366  int GetTagTokIntArgVal(
367  const TStr& TagPath, const TStr& ArgNm, const int& DfVal=0) const;
368  double GetTagTokFltArgVal(
369  const TStr& TagPath, const TStr& ArgNm, const double& DfVal=0) const;
370  TStr GetTagTokStrArgVal(
371  const TStr& TagPath, const TStr& ArgNm, const TStr& DfVal=TStr()) const;
372 
373  // string representation
374  static TStr GetXmlStr(const TStr& Str);
375 
376  // loading/saving document
377  static bool SkipTopTag(const PSIn& SIn);
378  static PXmlDoc LoadTxt(TXmlLx& Lx);
379  static PXmlDoc LoadTxt(const PSIn& SIn, const TXmlSpacing& Spacing=xspIntact);
380  static PXmlDoc LoadTxt(const TStr& FNm, const TXmlSpacing& Spacing=xspIntact);
381  static void LoadTxt(
382  const TStr& FNm, TXmlDocV& XmlDocV, const TXmlSpacing& Spacing=xspIntact);
383  void SaveTxt(const PSOut& SOut){
384  SOut->PutStr(GetTok()->GetTokStr());}
385  void SaveTxt(const TStr& FNm, const bool& Append=false){
386  PSOut SOut=TFOut::New(FNm, Append); SaveTxt(SOut);}
387  static PXmlDoc LoadStr(const TStr& Str);
388  void SaveStr(TStr& Str);
389 };
390 
392 // Fast and dirty XML parser
393 // very basic it does only <item>string</item>, no comments, no arguments
396 
397 class TXmlParser { //J:
398 private:
403 public:
406 private:
407  char GetCh() { return (! RSIn.Eof()) ? RSIn.GetCh() : TCh::EofCh; }
408 public:
409  TXmlParser(const PSIn& _SIn) : SIn(_SIn), RSIn(*SIn), Sym(xsyUndef), NextSym(xsyUndef) { }
410  static PXmlParser New(const PSIn& SIn) { return new TXmlParser(SIn); }
411 
412  TXmlLxSym GetSym();
413  TXmlLxSym GetSym(TChA& _SymStr);
414  TXmlLxSym PeekSym();
415  TXmlLxSym PeekSym(TChA& _SymStr);
416  void SkipTillTag(const TChA& _SymStr);
417 
418  TXmlLxSym GetTag(const TChA& TagStr);
419  void GetTagVal(const TChA& TagStr, TChA& TagVal);
420 
421  static void GetPlainStrFromXmlStr(const TChA& XmlStr, TChA& PlainChA);
422  friend class TPt<TXmlParser>;
423 };
void AddArg(const TStr &ArgNm, const int &ArgVal)
Definition: xml.h:254
Definition: bd.h:440
#define IAssert(Cond)
Definition: bd.h:262
void SaveTxt(const PSOut &SOut)
Definition: xml.h:383
TChA NextSymStr
Definition: xml.h:405
void SkipTillTag(const TChA &_SymStr)
Definition: xml.cpp:1510
TChA SymStr
Definition: xml.h:405
TXmlLxSym GetSym()
Definition: xml.cpp:757
int GetArgs() const
Definition: xml.h:262
TPt< TXmlTok > PXmlTok
Definition: xml.h:198
TStr TagNm
Definition: xml.h:141
bool IsChar(const uchar &Ch) const
Definition: xml.h:68
void GetXmlDecl()
Definition: xml.cpp:531
TChA TxtChA
Definition: xml.h:140
TXmlDoc(TSIn &)
Definition: xml.h:338
Definition: xml.h:93
void GetEntity()
Definition: xml.cpp:690
Definition: xml.h:91
TStr GetStr() const
Definition: dt.h:1200
void GetArg(const int &ArgN, TStr &ArgNm, TStr &ArgVal) const
Definition: xml.h:263
TCRef CRef
Definition: xml.h:399
static PSOut New(const TStr &FNm, const bool &Append=false)
Definition: fl.cpp:442
int Len() const
Definition: dt.h:490
Definition: xml.h:93
void GetArg(const int &ArgN, TStr &ArgNm, TStr &ArgVal) const
Definition: xml.h:166
static PXmlTok New(const TStr &TagNm, const PXmlTok &XmlTok1, const PXmlTok &XmlTok2=NULL)
Definition: xml.h:228
void GetNData()
Definition: xml.cpp:622
bool IsPEntityNm(const TStr &EntityNm, TStr &EntityVal) const
Definition: xml.h:179
TPt< TXmlDoc > PXmlDoc
Definition: xml.h:326
TXmlLxSym NextSym
Definition: xml.h:404
Definition: bits.h:313
static TStr GetChRefFromYuEntRef(const TStr &YuEntRefStr)
Definition: xml.cpp:1072
static TStr GetXmlLxSymStr(const TXmlLxSym &XmlLxSym)
Definition: xml.cpp:904
TXmlTok(TSIn &)
Definition: xml.h:234
TXmlTok(const TXmlLxSym &_Sym)
Definition: xml.h:206
TXmlDoc & operator=(const TXmlDoc &)
Definition: xml.h:342
PSIn SIn
Definition: xml.h:101
static TStr GetUsAsciiStrFromXmlStr(const TStr &EntRefStr)
Definition: xml.cpp:1056
Definition: xml.h:94
void AddArg(const TStr &ArgNm, const TStr &ArgVal)
Definition: xml.h:161
bool IsIn(const TVal &Val) const
Checks whether element Val is a member of the vector.
Definition: ds.h:828
TStr GetArgVal(const TStr &ArgNm, const TStr &DfVal=TStr()) const
Definition: xml.h:168
TStr GetTagTokStr(const TStr &TagPath) const
Definition: xml.h:307
void GetEq()
Definition: xml.cpp:408
void PutStr(const TStr &_Str)
Definition: xml.h:243
void AddArg(const TStr &ArgNm, const uint64 &ArgVal)
Definition: xml.h:256
#define Fail
Definition: bd.h:238
static PXmlParser New(const PSIn &SIn)
Definition: xml.h:410
static TStr GetTagNm(const TStr &TypeNm)
Definition: xml.cpp:5
void PutArgVal(const TStr &ArgNm, const TStr &ArgVal)
Definition: xml.h:271
bool IsComb(const uchar &Ch) const
Definition: xml.h:69
bool Empty() const
Definition: bd.h:501
TStr GetName()
Definition: xml.cpp:416
TXmlLxSym GetSym()
Definition: xml.cpp:1457
static PXmlTok New()
Definition: xml.h:212
TChA ChStack
Definition: xml.h:103
void AddArg(const TStr &ArgNm, const TStr &ArgVal)
Definition: xml.h:260
void GetWs(const bool &IsRq)
Definition: xml.cpp:331
TStr GetSymStr() const
Definition: xml.cpp:835
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TXmlTok(const TXmlLxSym &_Sym, const TStr &_Str)
Definition: xml.h:208
bool IsTagTok(const TStr &TagPath) const
Definition: xml.h:301
TSOut * SOut
Definition: xml.h:23
static TStr GetPlainStrFromXmlStr(const TStr &XmlStr)
Definition: xml.cpp:991
Definition: xml.h:90
bool IsDigit(const uchar &Ch) const
Definition: xml.h:72
static TStr GetXmlStrFromPlainMem(const TMem &PlainMem)
Definition: xml.cpp:945
TXmlChDef & operator=(const TXmlChDef &)
Definition: xml.h:66
TSIn & RSIn
Definition: xml.h:401
static PXmlTok New(const TStr &TagNm)
Definition: xml.h:222
bool IsEntityNm(const TStr &EntityNm, TStr &EntityVal) const
Definition: xml.h:83
bool IsFirstNameCh(const uchar &Ch) const
Definition: xml.h:78
PXmlTok GetSubTok(const int &SubTokN) const
Definition: xml.h:294
static int64 GetInt64Arg(const PXmlTok &XmlTok, const TStr &Nm)
Definition: xml.cpp:89
static PXmlTok Load(TSIn &)
Definition: xml.h:235
TStrStrH EntityNmToValH
Definition: xml.h:113
bool IsArg(const TStr &ArgNm, TStr &ArgVal) const
Definition: xml.h:267
static TXmlChDef ChDef
Definition: xml.h:100
void GetAttList()
Definition: xml.cpp:665
void GetPI()
Definition: xml.cpp:562
static PXmlTok New(const TXmlLxSym &Sym)
Definition: xml.h:213
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
TChA _SymStr
Definition: xml.h:402
static PXmlTok New(const TStr &TagNm, const TStrKdV &ArgNmValV)
Definition: xml.h:219
void ToNrSpacing()
Definition: xml.cpp:270
bool IsTagTok(const TStr &TagPath, PXmlTok &TagTok) const
Definition: xml.h:350
Definition: xml.h:96
Definition: fl.h:58
TStr GetTokStr(const bool &XmlP=true) const
Definition: xml.h:316
Definition: xml.h:5
void PutEntityVal(const TStr &Nm, const TStr &Val)
Definition: xml.h:177
Definition: dt.h:77
uchar PrevCh
Definition: xml.h:104
TStr GetStalVal()
Definition: xml.cpp:513
static const char EofCh
Definition: dt.h:1040
#define ClassTP(TNm, PNm)
Definition: bd.h:126
uchar GetCh()
Definition: xml.cpp:260
static bool GetBoolArg(const PXmlTok &XmlTok, const TStr &Nm)
Definition: xml.cpp:59
#define ClassTPV(TNm, PNm, TNmV)
Definition: bd.h:162
TStr GetArgVal(const TStr &ArgNm) const
Definition: xml.h:273
TSIn & RSIn
Definition: xml.h:102
bool IsPubid(const uchar &Ch) const
Definition: xml.h:74
bool IsTagTok(const TStr &TagPath, PXmlTok &TagTok) const
Definition: xml.h:299
static PXmlTok New(const TStr &TagNm, const TStr &ValStr)
Definition: xml.h:224
TXmlLx(const PSIn &_SIn, const TXmlSpacing &_Spacing=xspIntact)
Definition: xml.h:145
char GetCh()
Definition: xml.h:407
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:1022
TXmlLxSym GetTag(const TChA &TagStr)
Definition: xml.cpp:1524
bool IsTag(const TStr &TagNm) const
Definition: xml.h:248
void AddSubTok(const PXmlTok &Tok)
Definition: xml.h:292
virtual bool Eof()=0
Definition: xml.h:98
unsigned long long uint64
Definition: bd.h:38
static const char TabCh
Definition: dt.h:1037
Definition: xml.h:93
void GetExternalId()
Definition: xml.cpp:609
TStrKdV ArgNmValKdV
Definition: xml.h:142
bool IsKeyGetDat(const TKey &Key, TDat &Dat) const
Definition: hash.h:274
bool IsOk() const
Definition: xml.h:345
Definition: xml.h:92
int LnChN
Definition: xml.h:105
TXmlObjSerTagNm(TSOut &_SOut, const bool &ETagP, const TStr &Nm, const TStr &TypeNm, const TStr &ArgNm="", const TStr &ArgVal="")
Definition: xml.cpp:121
static double GetFltArg(const PXmlTok &XmlTok, const TStr &Nm)
Definition: xml.cpp:104
void AddArg(const TStr &ArgNm, const bool &ArgVal)
Definition: xml.h:252
void PutPEntityVal(const TStr &Nm, const TStr &Val)
Definition: xml.h:181
Definition: xml.h:93
void SaveTxt(const TStr &FNm, const bool &Append=false)
Definition: xml.h:385
TStr GetSymStr() const
Definition: xml.h:242
static PXmlDoc Load(TSIn &SIn)
Definition: xml.h:339
TXmlLxSym Sym
Definition: xml.h:404
static char GetArgValQCh(const TStr &ArgVal)
Definition: xml.h:171
unsigned char uchar
Definition: bd.h:10
void PutStr(const TStr &Str)
Definition: xml.h:109
Definition: xml.h:90
bool IsArg(const TStr &ArgNm) const
Definition: xml.h:265
TXmlSpacing
Definition: xml.h:96
Definition: fl.h:128
TStr GetVersionNum()
Definition: xml.cpp:473
TXmlLx & operator=(const TXmlLx &)
Definition: xml.h:152
Definition: xml.h:93
void GetTagValV(const TStr &TagNm, const bool &XmlP, TStrV &ValV) const
Definition: xml.h:359
bool IsArgNm(const TStr &ArgNm) const
Definition: xml.h:163
TXmlParser(const PSIn &_SIn)
Definition: xml.h:409
static const char LfCh
Definition: dt.h:1038
bool IsTag() const
Definition: xml.h:247
static PXmlTok New(const TXmlLxSym &Sym, const TStr &Str, const TStrKdV &ArgNmValV)
Definition: xml.h:216
Definition: dt.h:1137
int GetArgs() const
Definition: xml.h:165
Definition: xml.h:198
TStr GetReference()
Definition: xml.cpp:340
TStr GetTagTokStr(const TStr &TagPath) const
Definition: xml.h:356
TStr GetMsgStr() const
Definition: xml.h:346
void ClrSubTok()
Definition: xml.h:295
static int GetIntArg(const PXmlTok &XmlTok, const TStr &Nm)
Definition: xml.cpp:74
Definition: xml.h:93
Definition: dt.h:201
void Save(TSOut &)
Definition: xml.h:236
bool IsName(const uchar &Ch) const
Definition: xml.h:73
void AddArg(const TStr &ArgNm, const double &ArgVal)
Definition: xml.h:258
TStr GetEncName()
Definition: xml.cpp:493
TXmlDoc(const PXmlTok &_Tok)
Definition: xml.h:336
bool IsTagTok(const TStr &TagPath) const
Definition: xml.h:352
TStr GetStr() const
Definition: xml.h:244
void GetNotation()
Definition: xml.cpp:722
void PutCh(const uchar &_Ch)
Definition: xml.h:108
bool IsSubTag(const TStr &TagNm, PXmlTok &Tok) const
Definition: xml.h:290
TStr GetStr() const
Definition: dt.h:1363
long long int64
Definition: bd.h:27
TStr GetFPosStr() const
Definition: xml.cpp:895
TXmlLxSym
Definition: xml.h:89
static bool IsTagNm(const TStr &Str)
Definition: xml.cpp:927
bool IsLetter(const uchar &Ch) const
Definition: xml.h:71
Definition: dt.h:412
TXmlLxSym PeekSym()
Definition: xml.cpp:1493
bool IsChIn(const char &Ch) const
Definition: dt.h:556
TStr TagNm
Definition: xml.h:22
Definition: xml.h:92
void GetCDSect()
Definition: xml.cpp:733
TXmlSpacing Spacing
Definition: xml.h:106
int PutStr(const char *CStr)
Definition: fl.cpp:117
void Save(TSOut &SOut)
Definition: xml.h:59
TSizeTy SearchForw(const TVal &Val, const TSizeTy &BValN=0) const
Returns the position of an element with value Val.
Definition: ds.h:1552
Definition: xml.h:92
TStr GetTagTokStrOrDf(const TStr &TagPath, const TStr &DfVal=TStr()) const
Definition: xml.h:309
static const char CrCh
Definition: dt.h:1039
static void GetPlainStrFromXmlStr(const TChA &XmlStr, TChA &PlainChA)
Definition: xml.cpp:1531
static TStr GetStr(const bool &Val)
Definition: dt.h:1011
TStr GetAttValue()
Definition: xml.cpp:457
TStr GetTagNm() const
Definition: xml.h:249
TStr GetPEReference()
Definition: xml.cpp:397
Definition: xml.h:326
void Push(const char &Ch)
Definition: dt.h:264
void GetElement()
Definition: xml.cpp:656
void ClrArgV()
Definition: xml.h:160
TStr GetTagVal(const TStr &TagNm, const bool &XmlP) const
Definition: xml.h:361
Definition: xml.h:90
UndefDefaultCopyAssign(TXmlObjSerTagNm)
void SkipWs()
Definition: xml.cpp:752
TXmlLxSym GetSym() const
Definition: xml.h:241
bool IsExt(const uchar &Ch) const
Definition: xml.h:70
TStr GetStr() const
Definition: dt.h:1462
bool IsSubTag(const TStr &TagNm) const
Definition: xml.h:288
int LnN
Definition: xml.h:105
bool IsEntityNm(const TStr &EntityNm, TStr &EntityVal) const
Definition: xml.h:175
TXmlLxSym Sym
Definition: xml.h:139
void GetDocTypeDecl()
Definition: xml.cpp:627
virtual char GetCh()=0
int ChN
Definition: xml.h:105
void GetComment()
Definition: xml.cpp:436
static PXmlChDef Load(TSIn &SIn)
Definition: xml.h:58
static PXmlDoc New(const PXmlTok &Tok)
Definition: xml.h:337
~TXmlObjSerTagNm()
Definition: xml.cpp:182
PXmlTok GetTok() const
Definition: xml.h:347
TStrStrH PEntityNmToValH
Definition: xml.h:113
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
static void AssertXmlHd(const PXmlTok &XmlTok, const TStr &Nm, const TStr &TypeNm)
Definition: xml.cpp:22
TStr GetSystemLiteral()
Definition: xml.cpp:583
bool IsWs(const uchar &Ch) const
Definition: xml.h:76
bool IsEoln(const uchar &Ch) const
Definition: xml.h:80
TXmlTok & operator=(const TXmlTok &)
Definition: xml.h:238
TStr GetPubidLiteral()
Definition: xml.cpp:596
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
void Save(TSOut &)
Definition: xml.h:340
static PXmlDoc New()
Definition: xml.h:335
TPt< TXmlParser > PXmlParser
Definition: xml.h:394
Definition: xml.h:42
uchar Ch
Definition: xml.h:104
TStr GetEntityValue()
Definition: xml.cpp:674
Definition: xml.h:91
static PXmlTok New(const TXmlLxSym &Sym, const TStr &Str)
Definition: xml.h:214
static TStrStrH TypeNmToTagNmH
Definition: xml.h:7
TKeyDat< TStr, TStr > TStrKd
Definition: ds.h:405
PSIn SIn
Definition: xml.h:400
int GetSubToks() const
Definition: xml.h:293
void GetTagVal(const TChA &TagStr, TChA &TagVal)
Definition: xml.cpp:1518
TXmlTok(const TXmlLxSym &_Sym, const TStr &_Str, const TStrKdV &_ArgNmValV)
Definition: xml.h:210
TStr GetArgVal(const TStr &ArgNm, const TStr &DfArgVal) const
Definition: xml.h:275
static TStr GetXmlStrFromPlainStr(const TChA &PlainChA)
Definition: xml.cpp:968