Cuberite
A lightweight, fast and extensible game server for Minecraft
XMLParser.h
Go to the documentation of this file.
1 
2 // XMLParser.h
3 
4 // Interfaces to the CXMLParser class representing the base class for XML parsing
5 
6 // To use, derive a class from this base and override its OnStartElement(), OnEndElement() and OnCharacters() functions
7 
8 
9 
10 
11 
12 #pragma once
13 
14 #include "expat/expat.h"
15 
16 
17 
18 
19 
21 {
22 public:
23  CXMLParser(void);
24  virtual ~CXMLParser();
25 
26  // The actual parsing, may be called several times; the last time needs iIsFinal == true (-> flush)
27  int Parse(const char * iData, size_t iLength, bool iIsFinal = false);
28 
29 private:
30  // LibExpat stuff:
31  XML_Parser mParser;
32 
33  static void StartElementHandler(void * iContext, const XML_Char * iElement, const XML_Char ** iAttributes)
34  {
35  ((CXMLParser *)iContext)->OnStartElement(iElement, iAttributes);
36  }
37 
38  static void EndElementHandler (void * iContext, const XML_Char * iElement)
39  {
40  ((CXMLParser *)iContext)->OnEndElement(iElement);
41  }
42 
43  static void CharacterDataHandler (void * iContext, const XML_Char * iData, int iLength)
44  {
45  ((CXMLParser *)iContext)->OnCharacters(iData, iLength);
46  }
47 
48 protected:
49  virtual void OnStartElement(const XML_Char * iElement, const XML_Char ** iAttributes) = 0;
50  virtual void OnEndElement (const XML_Char * iElement) = 0;
51  virtual void OnCharacters (const XML_Char * iCharacters, int iLength) = 0;
52 } ;
53 
54 
55 
56 
57 
59 // The following template has been modified from code available at
60 // https://www.codeproject.com/Articles/1847/C-Wrappers-for-the-Expat-XML-Parser
61 // It uses templates to remove the virtual function call penalty (both size and speed) for each callback
62 
63 /* Usage:
64 1, Declare a subclass:
65  class CMyParser : public CExpatImpl<CMyParser>
66 2, Declare handlers that you want in that subclass:
67  void CMyParser::OnEndElement(const XML_Char * iTagName);
68 3, Create an instance of your class:
69  CMyParser Parser;
70 4, Call Create():
71  Parser.Create(nullptr, nullptr);
72 4, Call Parse(), repeatedly:
73  Parser.Parse(Buffer, Length);
74 */
75 
76 template <class _T>
78 {
79 
80 // @access Constructors and destructors
81 public:
82 
83  // @cmember General constructor
84 
86  {
87  m_p = nullptr;
88  }
89 
90  // @cmember Destructor
91 
93  {
94  Destroy ();
95  }
96 
97 // @access Parser creation and deletion methods
98 public:
99 
100  // @cmember Create a parser
101 
102  bool Create (const XML_Char * pszEncoding = nullptr, const XML_Char * pszSep = nullptr)
103  {
104  // Destroy the old parser
105  Destroy ();
106 
107  // If the encoding or seperator are empty, then nullptr
108  if ((pszEncoding != nullptr) && (pszEncoding[0] == 0))
109  {
110  pszEncoding = nullptr;
111  }
112  if ((pszSep != nullptr) && (pszSep[0] == 0))
113  {
114  pszSep = nullptr;
115  }
116 
117  // Create the new parser
118  m_p = XML_ParserCreate_MM (pszEncoding, nullptr, pszSep);
119  if (m_p == nullptr)
120  {
121  return false;
122  }
123 
124  // Invoke the post create routine
125  _T * pThis = static_cast <_T *> (this);
126  pThis ->OnPostCreate ();
127 
128  // Set the user data used in callbacks
129  XML_SetUserData (m_p, (void *) this);
130  return true;
131  }
132 
133  // @cmember Destroy the parser
134 
135  void Destroy (void)
136  {
137  if (m_p != nullptr)
138  {
139  XML_ParserFree (m_p);
140  }
141  m_p = nullptr;
142  }
143 
144 
145  // @cmember Parse a block of data
146 
147  bool Parse (const char *pszBuffer, int nLength, bool fIsFinal = true)
148  {
149  assert (m_p != nullptr);
150  return (XML_Parse (m_p, pszBuffer, nLength, fIsFinal) != 0);
151  }
152 
153  // @cmember Parse internal buffer
154 
155  bool ParseBuffer (int nLength, bool fIsFinal = true)
156  {
157  assert (m_p != nullptr);
158  return XML_ParseBuffer (m_p, nLength, fIsFinal) != 0;
159  }
160 
161  // @cmember Get the internal buffer
162 
163  void *GetBuffer (int nLength)
164  {
165  assert (m_p != nullptr);
166  return XML_GetBuffer (m_p, nLength);
167  }
168 
169 
170 protected:
171  // Parser callback enable / disable methods:
172 
173  // @cmember Enable / Disable the start element handler
174 
175  void EnableStartElementHandler (bool fEnable = true)
176  {
177  assert (m_p != nullptr);
178  XML_SetStartElementHandler (m_p, fEnable ? StartElementHandler : nullptr);
179  }
180 
181  // @cmember Enable / Disable the end element handler
182 
183  void EnableEndElementHandler (bool fEnable = true)
184  {
185  assert (m_p != nullptr);
186  XML_SetEndElementHandler (m_p, fEnable ? EndElementHandler : nullptr);
187  }
188 
189  // @cmember Enable / Disable the element handlers
190 
191  void EnableElementHandler (bool fEnable = true)
192  {
193  assert (m_p != nullptr);
194  EnableStartElementHandler (fEnable);
195  EnableEndElementHandler (fEnable);
196  }
197 
198  // @cmember Enable / Disable the character data handler
199 
200  void EnableCharacterDataHandler (bool fEnable = true)
201  {
202  assert (m_p != nullptr);
203  XML_SetCharacterDataHandler (m_p, fEnable ? CharacterDataHandler : nullptr);
204  }
205 
206  // @cmember Enable / Disable the processing instruction handler
207 
208  void EnableProcessingInstructionHandler (bool fEnable = true)
209  {
210  assert (m_p != nullptr);
211  XML_SetProcessingInstructionHandler (m_p, fEnable ? ProcessingInstructionHandler : nullptr);
212  }
213 
214  // @cmember Enable / Disable the comment handler
215 
216  void EnableCommentHandler (bool fEnable = true)
217  {
218  assert (m_p != nullptr);
219  XML_SetCommentHandler (m_p, fEnable ? CommentHandler : nullptr);
220  }
221 
222  // @cmember Enable / Disable the start CDATA section handler
223 
224  void EnableStartCdataSectionHandler (bool fEnable = true)
225  {
226  assert (m_p != nullptr);
227  XML_SetStartCdataSectionHandler (m_p, fEnable ? StartCdataSectionHandler : nullptr);
228  }
229 
230  // @cmember Enable / Disable the end CDATA section handler
231 
232  void EnableEndCdataSectionHandler (bool fEnable = true)
233  {
234  assert (m_p != nullptr);
235  XML_SetEndCdataSectionHandler (m_p, fEnable ? EndCdataSectionHandler : nullptr);
236  }
237 
238  // @cmember Enable / Disable the CDATA section handlers
239 
240  void EnableCdataSectionHandler (bool fEnable = true)
241  {
242  assert (m_p != nullptr);
245  }
246 
247  // @cmember Enable / Disable default handler
248 
249  void EnableDefaultHandler (bool fEnable = true, bool fExpand = true)
250  {
251  assert (m_p != nullptr);
252  if (fExpand)
253  {
254  XML_SetDefaultHandlerExpand (m_p, fEnable ? DefaultHandler : nullptr);
255  }
256  else
257  {
258  XML_SetDefaultHandler (m_p, fEnable ? DefaultHandler : nullptr);
259  }
260  }
261 
262  // @cmember Enable / Disable external entity ref handler
263 
264  void EnableExternalEntityRefHandler (bool fEnable = true)
265  {
266  assert (m_p != nullptr);
267  XML_SetExternalEntityRefHandler (m_p, fEnable ? ExternalEntityRefHandler : nullptr);
268  }
269 
270  // @cmember Enable / Disable unknown encoding handler
271 
272  void EnableUnknownEncodingHandler (bool fEnable = true)
273  {
274  assert (m_p != nullptr);
275  XML_SetUnknownEncodingHandler (m_p, fEnable ? UnknownEncodingHandler : nullptr);
276  }
277 
278  // @cmember Enable / Disable start namespace handler
279 
280  void EnableStartNamespaceDeclHandler (bool fEnable = true)
281  {
282  assert (m_p != nullptr);
283  XML_SetStartNamespaceDeclHandler (m_p, fEnable ? StartNamespaceDeclHandler : nullptr);
284  }
285 
286  // @cmember Enable / Disable end namespace handler
287 
288  void EnableEndNamespaceDeclHandler (bool fEnable = true)
289  {
290  assert (m_p != nullptr);
291  XML_SetEndNamespaceDeclHandler (m_p, fEnable ? EndNamespaceDeclHandler : nullptr);
292  }
293 
294  // @cmember Enable / Disable namespace handlers
295 
296  void EnableNamespaceDeclHandler (bool fEnable = true)
297  {
300  }
301 
302  // @cmember Enable / Disable the XML declaration handler
303 
304  void EnableXmlDeclHandler (bool fEnable = true)
305  {
306  assert (m_p != nullptr);
307  XML_SetXmlDeclHandler (m_p, fEnable ? XmlDeclHandler : nullptr);
308  }
309 
310  // @cmember Enable / Disable the start DOCTYPE declaration handler
311 
312  void EnableStartDoctypeDeclHandler (bool fEnable = true)
313  {
314  assert (m_p != nullptr);
315  XML_SetStartDoctypeDeclHandler (m_p, fEnable ? StartDoctypeDeclHandler : nullptr);
316  }
317 
318  // @cmember Enable / Disable the end DOCTYPE declaration handler
319 
320  void EnableEndDoctypeDeclHandler (bool fEnable = true)
321  {
322  assert (m_p != nullptr);
323  XML_SetEndDoctypeDeclHandler (m_p,
324  fEnable ? EndDoctypeDeclHandler : nullptr);
325  }
326 
327  // @cmember Enable / Disable the DOCTYPE declaration handler
328 
329  void EnableDoctypeDeclHandler (bool fEnable = true)
330  {
331  assert (m_p != nullptr);
333  EnableEndDoctypeDeclHandler (fEnable);
334  }
335 
336 public:
337  // Parser error reporting methods
338 
339  // @cmember Get last error
340 
341  enum XML_Error GetErrorCode ()
342  {
343  assert (m_p != nullptr);
344  return XML_GetErrorCode (m_p);
345  }
346 
347  // @cmember Get the current byte index
348 
350  {
351  assert (m_p != nullptr);
352  return XML_GetCurrentByteIndex (m_p);
353  }
354 
355  // @cmember Get the current line number
356 
358  {
359  assert (m_p != nullptr);
360  return XML_GetCurrentLineNumber (m_p);
361  }
362 
363  // @cmember Get the current column number
364 
366  {
367  assert (m_p != nullptr);
368  return XML_GetCurrentColumnNumber (m_p);
369  }
370 
371  // @cmember Get the current byte count
372 
374  {
375  assert (m_p != nullptr);
376  return XML_GetCurrentByteCount (m_p);
377  }
378 
379  // @cmember Get the input context
380 
381  const char *GetInputContext (int *pnOffset, int *pnSize)
382  {
383  assert (m_p != nullptr);
384  return XML_GetInputContext (m_p, pnOffset, pnSize);
385  }
386 
387  // @cmember Get last error string
388 
389  const XML_LChar *GetErrorString ()
390  {
391  return XML_ErrorString (GetErrorCode ());
392  }
393 
394  // @cmember Return the version string
395 
396  static const XML_LChar *GetExpatVersion ()
397  {
398  return XML_ExpatVersion ();
399  }
400 
401  // @cmember Get the version information
402 
403  static void GetExpatVersion (int *pnMajor, int *pnMinor, int *pnMicro)
404  {
405  XML_expat_version v = XML_ExpatVersionInfo ();
406  if (pnMajor)
407  {
408  *pnMajor = v .major;
409  }
410  if (pnMinor)
411  {
412  *pnMinor = v .minor;
413  }
414  if (pnMicro)
415  {
416  *pnMicro = v .micro;
417  }
418  }
419 
420  // @cmember Get last error string
421 
422  static const XML_LChar *GetErrorString (enum XML_Error nError)
423  {
424  return XML_ErrorString (nError);
425  }
426 
427 
428  // Public handler methods:
429  // The template parameter should provide their own implementation for those handlers that they want
430 
431  // @cmember Start element handler
432 
433  void OnStartElement (const XML_Char *pszName, const XML_Char **papszAttrs)
434  {
435  return;
436  }
437 
438  // @cmember End element handler
439 
440  void OnEndElement (const XML_Char *pszName)
441  {
442  return;
443  }
444 
445  // @cmember Character data handler
446 
447  void OnCharacterData (const XML_Char *pszData, int nLength)
448  {
449  return;
450  }
451 
452  // @cmember Processing instruction handler
453 
454  void OnProcessingInstruction (const XML_Char *pszTarget,
455  const XML_Char *pszData)
456  {
457  return;
458  }
459 
460  // @cmember Comment handler
461 
462  void OnComment (const XML_Char *pszData)
463  {
464  return;
465  }
466 
467  // @cmember Start CDATA section handler
468 
470  {
471  return;
472  }
473 
474  // @cmember End CDATA section handler
475 
477  {
478  return;
479  }
480 
481  // @cmember Default handler
482 
483  void OnDefault (const XML_Char *pszData, int nLength)
484  {
485  return;
486  }
487 
488  // @cmember External entity ref handler
489 
490  bool OnExternalEntityRef (const XML_Char *pszContext,
491  const XML_Char *pszBase, const XML_Char *pszSystemID,
492  const XML_Char *pszPublicID)
493  {
494  return false;
495  }
496 
497  // @cmember Unknown encoding handler
498 
499  bool OnUnknownEncoding (const XML_Char *pszName, XML_Encoding *pInfo)
500  {
501  return false;
502  }
503 
504  // @cmember Start namespace declaration handler
505 
506  void OnStartNamespaceDecl (const XML_Char *pszPrefix,
507  const XML_Char *pszURI)
508  {
509  return;
510  }
511 
512  // @cmember End namespace declaration handler
513 
514  void OnEndNamespaceDecl (const XML_Char *pszPrefix)
515  {
516  return;
517  }
518 
519  // @cmember XML declaration handler
520 
521  void OnXmlDecl (const XML_Char *pszVersion, const XML_Char *pszEncoding,
522  bool fStandalone)
523  {
524  return;
525  }
526 
527  // @cmember Start DOCTYPE declaration handler
528 
529  void OnStartDoctypeDecl (const XML_Char *pszDoctypeName,
530  const XML_Char *pszSysID, const XML_Char *pszPubID,
531  bool fHasInternalSubset)
532  {
533  return;
534  }
535 
536  // @cmember End DOCTYPE declaration handler
537 
539  {
540  return;
541  }
542 
543 // @access Protected methods
544 protected:
545 
546  // @cmember Handle any post creation
547 
548  void OnPostCreate ()
549  {
550  }
551 
552 // @access Protected static methods
553 protected:
554 
555  // @cmember Start element handler wrapper
556 
557  static void __cdecl StartElementHandler (void *pUserData,
558  const XML_Char *pszName, const XML_Char **papszAttrs)
559  {
560  _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
561  pThis ->OnStartElement (pszName, papszAttrs);
562  }
563 
564  // @cmember End element handler wrapper
565 
566  static void __cdecl EndElementHandler (void *pUserData,
567  const XML_Char *pszName)
568  {
569  _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
570  pThis ->OnEndElement (pszName);
571  }
572 
573  // @cmember Character data handler wrapper
574 
575  static void __cdecl CharacterDataHandler (void *pUserData,
576  const XML_Char *pszData, int nLength)
577  {
578  _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
579  pThis ->OnCharacterData (pszData, nLength);
580  }
581 
582  // @cmember Processing instruction handler wrapper
583 
584  static void __cdecl ProcessingInstructionHandler (void *pUserData,
585  const XML_Char *pszTarget, const XML_Char *pszData)
586  {
587  _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
588  pThis ->OnProcessingInstruction (pszTarget, pszData);
589  }
590 
591  // @cmember Comment handler wrapper
592 
593  static void __cdecl CommentHandler (void *pUserData,
594  const XML_Char *pszData)
595  {
596  _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
597  pThis ->OnComment (pszData);
598  }
599 
600  // @cmember Start CDATA section wrapper
601 
602  static void __cdecl StartCdataSectionHandler (void *pUserData)
603  {
604  _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
605  pThis ->OnStartCdataSection ();
606  }
607 
608  // @cmember End CDATA section wrapper
609 
610  static void __cdecl EndCdataSectionHandler (void *pUserData)
611  {
612  _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
613  pThis ->OnEndCdataSection ();
614  }
615 
616  // @cmember Default wrapper
617 
618  static void __cdecl DefaultHandler (void *pUserData,
619  const XML_Char *pszData, int nLength)
620  {
621  _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
622  pThis ->OnDefault (pszData, nLength);
623  }
624 
625  // @cmember External entity ref wrapper
626 
627  static int __cdecl ExternalEntityRefHandler (void *pUserData,
628  const XML_Char *pszContext, const XML_Char *pszBase,
629  const XML_Char *pszSystemID, const XML_Char *pszPublicID)
630  {
631  _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
632  return pThis ->OnExternalEntityRef (pszContext,
633  pszBase, pszSystemID, pszPublicID) ? 1 : 0;
634  }
635 
636  // @cmember Unknown encoding wrapper
637 
638  static int __cdecl UnknownEncodingHandler (void * pUserData, const XML_Char * pszName, XML_Encoding * pInfo)
639  {
640  _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
641  return pThis ->OnUnknownEncoding (pszName, pInfo) ? 1 : 0;
642  }
643 
644  // @cmember Start namespace decl wrapper
645 
646  static void __cdecl StartNamespaceDeclHandler (void * pUserData, const XML_Char * pszPrefix, const XML_Char * pszURI)
647  {
648  _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
649  pThis ->OnStartNamespaceDecl (pszPrefix, pszURI);
650  }
651 
652  // @cmember End namespace decl wrapper
653 
654  static void __cdecl EndNamespaceDeclHandler (void * pUserData, const XML_Char * pszPrefix)
655  {
656  _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
657  pThis ->OnEndNamespaceDecl (pszPrefix);
658  }
659 
660  // @cmember XML declaration wrapper
661 
662  static void __cdecl XmlDeclHandler (void *pUserData, const XML_Char *pszVersion, const XML_Char *pszEncoding, int nStandalone)
663  {
664  _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
665  pThis ->OnXmlDecl (pszVersion, pszEncoding, nStandalone != 0);
666  }
667 
668  // @cmember Start Doctype declaration wrapper
669 
670  static void __cdecl StartDoctypeDeclHandler (
671  void *pUserData, const XML_Char *pszDoctypeName, const XML_Char *pszSysID,
672  const XML_Char *pszPubID, int nHasInternalSubset
673  )
674  {
675  _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
676  pThis ->OnStartDoctypeDecl (pszDoctypeName, pszSysID,
677  pszPubID, nHasInternalSubset != 0);
678  }
679 
680  // @cmember End Doctype declaration wrapper
681 
682  static void __cdecl EndDoctypeDeclHandler (void *pUserData)
683  {
684  _T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
685  pThis ->OnEndDoctypeDecl ();
686  }
687 
688 
689 protected:
690 
691  XML_Parser m_p;
692 
694  static const XML_Char * FindAttr(const XML_Char ** iAttrs, const XML_Char * iAttrToFind)
695  {
696  for (const XML_Char ** Attr = iAttrs; *Attr != nullptr; Attr += 2)
697  {
698  if (strcmp(*Attr, iAttrToFind) == 0)
699  {
700  return *(Attr + 1);
701  }
702  } // for Attr - iAttrs[]
703  return nullptr;
704  }
705 } ;
706 
707 
708 
709 
virtual ~CXMLParser()
static void StartElementHandler(void *iContext, const XML_Char *iElement, const XML_Char **iAttributes)
Definition: XMLParser.h:33
CXMLParser(void)
XML_Parser mParser
Definition: XMLParser.h:31
virtual void OnStartElement(const XML_Char *iElement, const XML_Char **iAttributes)=0
static void EndElementHandler(void *iContext, const XML_Char *iElement)
Definition: XMLParser.h:38
virtual void OnCharacters(const XML_Char *iCharacters, int iLength)=0
virtual void OnEndElement(const XML_Char *iElement)=0
int Parse(const char *iData, size_t iLength, bool iIsFinal=false)
static void CharacterDataHandler(void *iContext, const XML_Char *iData, int iLength)
Definition: XMLParser.h:43
static void __cdecl ProcessingInstructionHandler(void *pUserData, const XML_Char *pszTarget, const XML_Char *pszData)
Definition: XMLParser.h:584
static void __cdecl CharacterDataHandler(void *pUserData, const XML_Char *pszData, int nLength)
Definition: XMLParser.h:575
void EnableStartDoctypeDeclHandler(bool fEnable=true)
Definition: XMLParser.h:312
static void __cdecl EndNamespaceDeclHandler(void *pUserData, const XML_Char *pszPrefix)
Definition: XMLParser.h:654
bool OnUnknownEncoding(const XML_Char *pszName, XML_Encoding *pInfo)
Definition: XMLParser.h:499
void EnableStartElementHandler(bool fEnable=true)
Definition: XMLParser.h:175
void OnDefault(const XML_Char *pszData, int nLength)
Definition: XMLParser.h:483
static const XML_LChar * GetErrorString(enum XML_Error nError)
Definition: XMLParser.h:422
void EnableDoctypeDeclHandler(bool fEnable=true)
Definition: XMLParser.h:329
void EnableStartCdataSectionHandler(bool fEnable=true)
Definition: XMLParser.h:224
static void __cdecl StartElementHandler(void *pUserData, const XML_Char *pszName, const XML_Char **papszAttrs)
Definition: XMLParser.h:557
void EnableEndCdataSectionHandler(bool fEnable=true)
Definition: XMLParser.h:232
void Destroy(void)
Definition: XMLParser.h:135
void OnPostCreate()
Definition: XMLParser.h:548
bool ParseBuffer(int nLength, bool fIsFinal=true)
Definition: XMLParser.h:155
void OnEndDoctypeDecl()
Definition: XMLParser.h:538
void OnComment(const XML_Char *pszData)
Definition: XMLParser.h:462
void OnProcessingInstruction(const XML_Char *pszTarget, const XML_Char *pszData)
Definition: XMLParser.h:454
bool OnExternalEntityRef(const XML_Char *pszContext, const XML_Char *pszBase, const XML_Char *pszSystemID, const XML_Char *pszPublicID)
Definition: XMLParser.h:490
static void __cdecl DefaultHandler(void *pUserData, const XML_Char *pszData, int nLength)
Definition: XMLParser.h:618
void OnEndNamespaceDecl(const XML_Char *pszPrefix)
Definition: XMLParser.h:514
void EnableCommentHandler(bool fEnable=true)
Definition: XMLParser.h:216
static int __cdecl UnknownEncodingHandler(void *pUserData, const XML_Char *pszName, XML_Encoding *pInfo)
Definition: XMLParser.h:638
static void __cdecl StartCdataSectionHandler(void *pUserData)
Definition: XMLParser.h:602
CExpatImpl()
Definition: XMLParser.h:85
void OnStartCdataSection()
Definition: XMLParser.h:469
static void __cdecl StartNamespaceDeclHandler(void *pUserData, const XML_Char *pszPrefix, const XML_Char *pszURI)
Definition: XMLParser.h:646
static void __cdecl CommentHandler(void *pUserData, const XML_Char *pszData)
Definition: XMLParser.h:593
~CExpatImpl()
Definition: XMLParser.h:92
static int __cdecl ExternalEntityRefHandler(void *pUserData, const XML_Char *pszContext, const XML_Char *pszBase, const XML_Char *pszSystemID, const XML_Char *pszPublicID)
Definition: XMLParser.h:627
void OnStartNamespaceDecl(const XML_Char *pszPrefix, const XML_Char *pszURI)
Definition: XMLParser.h:506
void EnableEndDoctypeDeclHandler(bool fEnable=true)
Definition: XMLParser.h:320
XML_Parser m_p
Definition: XMLParser.h:691
bool Create(const XML_Char *pszEncoding=nullptr, const XML_Char *pszSep=nullptr)
Definition: XMLParser.h:102
void EnableUnknownEncodingHandler(bool fEnable=true)
Definition: XMLParser.h:272
void EnableExternalEntityRefHandler(bool fEnable=true)
Definition: XMLParser.h:264
void EnableDefaultHandler(bool fEnable=true, bool fExpand=true)
Definition: XMLParser.h:249
void EnableNamespaceDeclHandler(bool fEnable=true)
Definition: XMLParser.h:296
static void __cdecl StartDoctypeDeclHandler(void *pUserData, const XML_Char *pszDoctypeName, const XML_Char *pszSysID, const XML_Char *pszPubID, int nHasInternalSubset)
Definition: XMLParser.h:670
void OnXmlDecl(const XML_Char *pszVersion, const XML_Char *pszEncoding, bool fStandalone)
Definition: XMLParser.h:521
static void __cdecl EndDoctypeDeclHandler(void *pUserData)
Definition: XMLParser.h:682
static void __cdecl XmlDeclHandler(void *pUserData, const XML_Char *pszVersion, const XML_Char *pszEncoding, int nStandalone)
Definition: XMLParser.h:662
void OnStartElement(const XML_Char *pszName, const XML_Char **papszAttrs)
Definition: XMLParser.h:433
void EnableCharacterDataHandler(bool fEnable=true)
Definition: XMLParser.h:200
int GetCurrentByteCount()
Definition: XMLParser.h:373
void OnStartDoctypeDecl(const XML_Char *pszDoctypeName, const XML_Char *pszSysID, const XML_Char *pszPubID, bool fHasInternalSubset)
Definition: XMLParser.h:529
static const XML_Char * FindAttr(const XML_Char **iAttrs, const XML_Char *iAttrToFind)
Returns the value of the specified attribute, if found; nullptr otherwise.
Definition: XMLParser.h:694
const char * GetInputContext(int *pnOffset, int *pnSize)
Definition: XMLParser.h:381
bool Parse(const char *pszBuffer, int nLength, bool fIsFinal=true)
Definition: XMLParser.h:147
int GetCurrentColumnNumber()
Definition: XMLParser.h:365
static const XML_LChar * GetExpatVersion()
Definition: XMLParser.h:396
void OnEndElement(const XML_Char *pszName)
Definition: XMLParser.h:440
long GetCurrentByteIndex()
Definition: XMLParser.h:349
static void __cdecl EndCdataSectionHandler(void *pUserData)
Definition: XMLParser.h:610
int GetCurrentLineNumber()
Definition: XMLParser.h:357
void OnCharacterData(const XML_Char *pszData, int nLength)
Definition: XMLParser.h:447
void EnableStartNamespaceDeclHandler(bool fEnable=true)
Definition: XMLParser.h:280
static void GetExpatVersion(int *pnMajor, int *pnMinor, int *pnMicro)
Definition: XMLParser.h:403
void EnableEndElementHandler(bool fEnable=true)
Definition: XMLParser.h:183
void EnableElementHandler(bool fEnable=true)
Definition: XMLParser.h:191
void EnableCdataSectionHandler(bool fEnable=true)
Definition: XMLParser.h:240
static void __cdecl EndElementHandler(void *pUserData, const XML_Char *pszName)
Definition: XMLParser.h:566
void EnableProcessingInstructionHandler(bool fEnable=true)
Definition: XMLParser.h:208
void EnableEndNamespaceDeclHandler(bool fEnable=true)
Definition: XMLParser.h:288
void * GetBuffer(int nLength)
Definition: XMLParser.h:163
enum XML_Error GetErrorCode()
Definition: XMLParser.h:341
const XML_LChar * GetErrorString()
Definition: XMLParser.h:389
void OnEndCdataSection()
Definition: XMLParser.h:476
void EnableXmlDeclHandler(bool fEnable=true)
Definition: XMLParser.h:304