HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_XMLSaxParser.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_XMLSaxParser.h ( Library, C++)
7  *
8  * COMMENTS:
9  * The SAX parser uses the libxml2 API documented at:
10  * http://xmlsoft.org/html/libxml-parser.html
11  * http://xmlsoft.org/html/libxml-tree.html
12  *
13  */
14 
15 #ifndef __UT_XMLSaxParser__
16 #define __UT_XMLSaxParser__
17 
18 #include "UT_API.h"
19 #include "UT_Pair.h"
20 #include "UT_ValArray.h"
21 #include "UT_String.h"
22 #include "UT_XMLParser.h"
23 
24 struct _xmlSAXHandler;
25 typedef struct _xmlSAXHandler *xmlSAXHandlerPtr;
26 
28 {
29 public:
30  /// Standard constructor.
32 
33  /// Standard destructor.
34  virtual ~UT_XMLSaxParser();
35 
36 protected:
37 
38  /// An XML element attribute as defined by a name and a value.
40 
41  /// A list of XML element attributes.
43 
44  /// Callback methods that are called at various times
45  /// of the parse.
46  virtual void onStartDocument();
47  virtual void onEndDocument();
48  virtual void onStartElement(const UT_String &name,
49  const UT_XMLAttributeList &attribs);
50  virtual void onEndElement(const UT_String &name);
51  virtual void onCharacters(const UT_String &characters);
52  virtual void onCDATABlock(const UT_String &characters);
53  virtual void onComment(const UT_String &text);
54  virtual void onWarning(const UT_String &text);
55  virtual void onError(const UT_String &text);
56  virtual void onFatalError(const UT_String &text);
57 
58  /// Parse XML using the current context.
59  /// Return true on a successful parse. Return false otherwise.
60  bool parseContextSubclass();
61 
62  /// Utility method for getting the value of an attribute.
63  static bool getAttribute(const UT_XMLAttributeList &attribs,
64  const char * name, UT_String & value);
65 private:
66 
67  /// SAX parsing callback handler.
68  xmlSAXHandlerPtr myCallbackHandler;
69 
70  /// We need to give the callback helper class
71  /// access to the parser's callback functions (i.e. onStartElement).
72  friend class utSaxParserCallback;
73 };
74 
75 #endif
76 
#define UT_API
Definition: UT_API.h:12
GLuint const GLchar * name
Definition: glcorearb.h:785
GLsizei const GLfloat * value
Definition: glcorearb.h:823
struct _xmlSAXHandler * xmlSAXHandlerPtr
UT_Pair< UT_String, UT_String > UT_XMLAttribute
An XML element attribute as defined by a name and a value.
virtual bool parseContextSubclass()=0
UT_ValArray< UT_XMLAttribute * > UT_XMLAttributeList
A list of XML element attributes.