HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_XMLReader.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_XMLReader.h ( UT Library, C++)
7  *
8  * COMMENTS:
9  * The reader uses the libxml2 API documented at:
10  * http://xmlsoft.org/html/libxml-xmlreader.html
11  * http://xmlsoft.org/examples/reader1.c
12  *
13  * COMMENTS:
14  */
15 
16 #ifndef __UT_XMLReader__
17 #define __UT_XMLReader__
18 
19 #include "UT_API.h"
20 #include "UT_String.h"
21 #include "UT_WorkBuffer.h"
22 #include "UT_XMLNode.h"
23 
24 struct _xmlTextReader;
25 typedef struct _xmlTextReader *xmlTextReaderPtr;
26 
28 {
29 public:
30  /// Standard constructor.
31  UT_XMLReader();
32 
33  /// Standard destructor.
34  ~UT_XMLReader();
35 
36  /// Initialize the reader to read from file.
37  bool beginReadingFromFile(const char *file);
38 
39  /// Initialize the reader to read from memory buffer.
40  bool beginReadingFromMemory(
41  const UT_WorkBuffer &memory,
42  const char *URL,
43  const char *encoding = nullptr);
44 
45  /// Read the next XML element.
46  bool read();
47 
48  /// Return the currently read node.
49  /// Return NULL if no node has been read.
50  const UT_XMLNode *getNode();
51 
52  /// Return the type for the currently read XML node.
53  UT_XMLNodeType getNodeType() const;
54 
55  /// Pass back the name of the currently read XML node.
56  void getNodeName(UT_String &name) const;
57 
58  /// Pass back the contents of the currently read XML element or text node.
59  void getNodeContents(UT_String &contents) const;
60 
61  /// Return the depth of the current node in the XML document.
62  int getNodeDepth() const;
63 
64  /// Return true if the currently read node has attributes.
65  /// Return false otherwise.
66  bool hasNodeAttributes() const;
67 
68  /// Pass back the value of the specified attribute on the current node.
69  void getNodeAttribute(const char *attr_name,
70  UT_String &attr_val) const;
71 
72  /// Return true if the currently read node has a value.
73  /// Return false otherwise.
74  bool hasNodeValue() const;
75 
76  /// Pass back the value of the current node.
77  void getNodeValue(UT_String &node_val) const;
78 
79 private:
80  /// The reader that does the actual reading:
81  xmlTextReaderPtr myReader;
82 
83  /// Temporary storage for the current node.
84  UT_XMLNode *myNode;
85 };
86 
87 #endif
88 
#define UT_API
Definition: UT_API.h:12
struct _xmlTextReader * xmlTextReaderPtr
Definition: UT_XMLReader.h:25
void read(T &in, bool &v)
Definition: ImfXdr.h:611
GLuint const GLchar * name
Definition: glcorearb.h:785
xmlElementType UT_XMLNodeType
Definition: UT_XMLNode.h:35