]> git.sesse.net Git - casparcg/blob - dependencies64/cef/include/cef_xml_reader.h
* Merged html producer and updated to latest CEF version (does not have satisfactory...
[casparcg] / dependencies64 / cef / include / cef_xml_reader.h
1 // Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 //    * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //    * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 //    * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // ---------------------------------------------------------------------------
31 //
32 // The contents of this file must follow a specific format in order to
33 // support the CEF translator tool. See the translator.README.txt file in the
34 // tools directory for more information.
35 //
36
37 #ifndef CEF_INCLUDE_CEF_XML_READER_H_
38 #define CEF_INCLUDE_CEF_XML_READER_H_
39 #pragma once
40
41 #include "include/cef_base.h"
42 #include "include/cef_stream.h"
43
44 ///
45 // Class that supports the reading of XML data via the libxml streaming API.
46 // The methods of this class should only be called on the thread that creates
47 // the object.
48 ///
49 /*--cef(source=library)--*/
50 class CefXmlReader : public virtual CefBase {
51  public:
52   typedef cef_xml_encoding_type_t EncodingType;
53   typedef cef_xml_node_type_t NodeType;
54
55   ///
56   // Create a new CefXmlReader object. The returned object's methods can only
57   // be called from the thread that created the object.
58   ///
59   /*--cef()--*/
60   static CefRefPtr<CefXmlReader> Create(CefRefPtr<CefStreamReader> stream,
61                                         EncodingType encodingType,
62                                         const CefString& URI);
63
64   ///
65   // Moves the cursor to the next node in the document. This method must be
66   // called at least once to set the current cursor position. Returns true if
67   // the cursor position was set successfully.
68   ///
69   /*--cef()--*/
70   virtual bool MoveToNextNode() =0;
71
72   ///
73   // Close the document. This should be called directly to ensure that cleanup
74   // occurs on the correct thread.
75   ///
76   /*--cef()--*/
77   virtual bool Close() =0;
78
79   ///
80   // Returns true if an error has been reported by the XML parser.
81   ///
82   /*--cef()--*/
83   virtual bool HasError() =0;
84
85   ///
86   // Returns the error string.
87   ///
88   /*--cef()--*/
89   virtual CefString GetError() =0;
90
91
92   // The below methods retrieve data for the node at the current cursor
93   // position.
94
95   ///
96   // Returns the node type.
97   ///
98   /*--cef(default_retval=XML_NODE_UNSUPPORTED)--*/
99   virtual NodeType GetType() =0;
100
101   ///
102   // Returns the node depth. Depth starts at 0 for the root node.
103   ///
104   /*--cef()--*/
105   virtual int GetDepth() =0;
106
107   ///
108   // Returns the local name. See
109   // http://www.w3.org/TR/REC-xml-names/#NT-LocalPart for additional details.
110   ///
111   /*--cef()--*/
112   virtual CefString GetLocalName() =0;
113
114   ///
115   // Returns the namespace prefix. See http://www.w3.org/TR/REC-xml-names/ for
116   // additional details.
117   ///
118   /*--cef()--*/
119   virtual CefString GetPrefix() =0;
120
121   ///
122   // Returns the qualified name, equal to (Prefix:)LocalName. See
123   // http://www.w3.org/TR/REC-xml-names/#ns-qualnames for additional details.
124   ///
125   /*--cef()--*/
126   virtual CefString GetQualifiedName() =0;
127
128   ///
129   // Returns the URI defining the namespace associated with the node. See
130   // http://www.w3.org/TR/REC-xml-names/ for additional details.
131   ///
132   /*--cef()--*/
133   virtual CefString GetNamespaceURI() =0;
134
135   ///
136   // Returns the base URI of the node. See http://www.w3.org/TR/xmlbase/ for
137   // additional details.
138   ///
139   /*--cef()--*/
140   virtual CefString GetBaseURI() =0;
141
142   ///
143   // Returns the xml:lang scope within which the node resides. See
144   // http://www.w3.org/TR/REC-xml/#sec-lang-tag for additional details.
145   ///
146   /*--cef()--*/
147   virtual CefString GetXmlLang() =0;
148
149   ///
150   // Returns true if the node represents an empty element. <a/> is considered
151   // empty but <a></a> is not.
152   ///
153   /*--cef()--*/
154   virtual bool IsEmptyElement() =0;
155
156   ///
157   // Returns true if the node has a text value.
158   ///
159   /*--cef()--*/
160   virtual bool HasValue() =0;
161
162   ///
163   // Returns the text value.
164   ///
165   /*--cef()--*/
166   virtual CefString GetValue() =0;
167
168   ///
169   // Returns true if the node has attributes.
170   ///
171   /*--cef()--*/
172   virtual bool HasAttributes() =0;
173
174   ///
175   // Returns the number of attributes.
176   ///
177   /*--cef()--*/
178   virtual size_t GetAttributeCount() =0;
179
180   ///
181   // Returns the value of the attribute at the specified 0-based index.
182   ///
183   /*--cef(capi_name=get_attribute_byindex,index_param=index)--*/
184   virtual CefString GetAttribute(int index) =0;
185
186   ///
187   // Returns the value of the attribute with the specified qualified name.
188   ///
189   /*--cef(capi_name=get_attribute_byqname)--*/
190   virtual CefString GetAttribute(const CefString& qualifiedName) =0;
191
192   ///
193   // Returns the value of the attribute with the specified local name and
194   // namespace URI.
195   ///
196   /*--cef(capi_name=get_attribute_bylname)--*/
197   virtual CefString GetAttribute(const CefString& localName,
198                                  const CefString& namespaceURI) =0;
199
200   ///
201   // Returns an XML representation of the current node's children.
202   ///
203   /*--cef()--*/
204   virtual CefString GetInnerXml() =0;
205
206   ///
207   // Returns an XML representation of the current node including its children.
208   ///
209   /*--cef()--*/
210   virtual CefString GetOuterXml() =0;
211
212   ///
213   // Returns the line number for the current node.
214   ///
215   /*--cef()--*/
216   virtual int GetLineNumber() =0;
217
218
219   // Attribute nodes are not traversed by default. The below methods can be
220   // used to move the cursor to an attribute node. MoveToCarryingElement() can
221   // be called afterwards to return the cursor to the carrying element. The
222   // depth of an attribute node will be 1 + the depth of the carrying element.
223
224   ///
225   // Moves the cursor to the attribute at the specified 0-based index. Returns
226   // true if the cursor position was set successfully.
227   ///
228   /*--cef(capi_name=move_to_attribute_byindex,index_param=index)--*/
229   virtual bool MoveToAttribute(int index) =0;
230
231   ///
232   // Moves the cursor to the attribute with the specified qualified name.
233   // Returns true if the cursor position was set successfully.
234   ///
235   /*--cef(capi_name=move_to_attribute_byqname)--*/
236   virtual bool MoveToAttribute(const CefString& qualifiedName) =0;
237
238   ///
239   // Moves the cursor to the attribute with the specified local name and
240   // namespace URI. Returns true if the cursor position was set successfully.
241   ///
242   /*--cef(capi_name=move_to_attribute_bylname)--*/
243   virtual bool MoveToAttribute(const CefString& localName,
244                                const CefString& namespaceURI) =0;
245
246   ///
247   // Moves the cursor to the first attribute in the current element. Returns
248   // true if the cursor position was set successfully.
249   ///
250   /*--cef()--*/
251   virtual bool MoveToFirstAttribute() =0;
252
253   ///
254   // Moves the cursor to the next attribute in the current element. Returns
255   // true if the cursor position was set successfully.
256   ///
257   /*--cef()--*/
258   virtual bool MoveToNextAttribute() =0;
259
260   ///
261   // Moves the cursor back to the carrying element. Returns true if the cursor
262   // position was set successfully.
263   ///
264   /*--cef()--*/
265   virtual bool MoveToCarryingElement() =0;
266 };
267
268 #endif  // CEF_INCLUDE_CEF_XML_READER_H_