2012-04-03 03:34:16 +02:00
|
|
|
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following disclaimer
|
|
|
|
// in the documentation and/or other materials provided with the
|
|
|
|
// distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
|
|
|
// Framework nor the names of its contributors may be used to endorse
|
|
|
|
// or promote products derived from this software without specific prior
|
|
|
|
// written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// The contents of this file must follow a specific format in order to
|
|
|
|
// support the CEF translator tool. See the translator.README.txt file in the
|
|
|
|
// tools directory for more information.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef CEF_INCLUDE_CEF_XML_READER_H_
|
|
|
|
#define CEF_INCLUDE_CEF_XML_READER_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "include/cef_base.h"
|
|
|
|
#include "include/cef_stream.h"
|
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Class that supports the reading of XML data via the libxml streaming API.
|
|
|
|
/// The methods of this class should only be called on the thread that creates
|
|
|
|
/// the object.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef(source=library)--*/
|
2017-02-09 23:07:43 +01:00
|
|
|
class CefXmlReader : public virtual CefBaseRefCounted {
|
2012-04-03 03:34:16 +02:00
|
|
|
public:
|
|
|
|
typedef cef_xml_encoding_type_t EncodingType;
|
|
|
|
typedef cef_xml_node_type_t NodeType;
|
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Create a new CefXmlReader object. The returned object's methods can only
|
|
|
|
/// be called from the thread that created the object.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
|
|
|
static CefRefPtr<CefXmlReader> Create(CefRefPtr<CefStreamReader> stream,
|
|
|
|
EncodingType encodingType,
|
|
|
|
const CefString& URI);
|
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Moves the cursor to the next node in the document. This method must be
|
|
|
|
/// called at least once to set the current cursor position. Returns true if
|
|
|
|
/// the cursor position was set successfully.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool MoveToNextNode() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Close the document. This should be called directly to ensure that cleanup
|
|
|
|
/// occurs on the correct thread.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool Close() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns true if an error has been reported by the XML parser.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool HasError() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the error string.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetError() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2022-09-01 04:03:04 +02:00
|
|
|
/// The below methods retrieve data for the node at the current cursor
|
|
|
|
/// position.
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the node type.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef(default_retval=XML_NODE_UNSUPPORTED)--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual NodeType GetType() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the node depth. Depth starts at 0 for the root node.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual int GetDepth() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the local name. See
|
|
|
|
/// http://www.w3.org/TR/REC-xml-names/#NT-LocalPart for additional details.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetLocalName() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the namespace prefix. See http://www.w3.org/TR/REC-xml-names/ for
|
|
|
|
/// additional details.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetPrefix() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the qualified name, equal to (Prefix:)LocalName. See
|
|
|
|
/// http://www.w3.org/TR/REC-xml-names/#ns-qualnames for additional details.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetQualifiedName() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the URI defining the namespace associated with the node. See
|
|
|
|
/// http://www.w3.org/TR/REC-xml-names/ for additional details.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetNamespaceURI() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the base URI of the node. See http://www.w3.org/TR/xmlbase/ for
|
|
|
|
/// additional details.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetBaseURI() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the xml:lang scope within which the node resides. See
|
|
|
|
/// http://www.w3.org/TR/REC-xml/#sec-lang-tag for additional details.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetXmlLang() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns true if the node represents an empty element. "<a/>" is considered
|
|
|
|
/// empty but "<a></a>" is not.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool IsEmptyElement() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns true if the node has a text value.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool HasValue() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the text value.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetValue() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns true if the node has attributes.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool HasAttributes() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the number of attributes.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual size_t GetAttributeCount() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the value of the attribute at the specified 0-based index.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef(capi_name=get_attribute_byindex,index_param=index)--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetAttribute(int index) = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the value of the attribute with the specified qualified name.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef(capi_name=get_attribute_byqname)--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetAttribute(const CefString& qualifiedName) = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the value of the attribute with the specified local name and
|
|
|
|
/// namespace URI.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef(capi_name=get_attribute_bylname)--*/
|
|
|
|
virtual CefString GetAttribute(const CefString& localName,
|
2017-05-17 11:29:28 +02:00
|
|
|
const CefString& namespaceURI) = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns an XML representation of the current node's children.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetInnerXml() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns an XML representation of the current node including its children.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual CefString GetOuterXml() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Returns the line number for the current node.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual int GetLineNumber() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Attribute nodes are not traversed by default. The below methods can be
|
|
|
|
/// used to move the cursor to an attribute node. MoveToCarryingElement() can
|
|
|
|
/// be called afterwards to return the cursor to the carrying element. The
|
|
|
|
/// depth of an attribute node will be 1 + the depth of the carrying element.
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Moves the cursor to the attribute at the specified 0-based index. Returns
|
|
|
|
/// true if the cursor position was set successfully.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef(capi_name=move_to_attribute_byindex,index_param=index)--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool MoveToAttribute(int index) = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Moves the cursor to the attribute with the specified qualified name.
|
|
|
|
/// Returns true if the cursor position was set successfully.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef(capi_name=move_to_attribute_byqname)--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool MoveToAttribute(const CefString& qualifiedName) = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Moves the cursor to the attribute with the specified local name and
|
|
|
|
/// namespace URI. Returns true if the cursor position was set successfully.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef(capi_name=move_to_attribute_bylname)--*/
|
|
|
|
virtual bool MoveToAttribute(const CefString& localName,
|
2017-05-17 11:29:28 +02:00
|
|
|
const CefString& namespaceURI) = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Moves the cursor to the first attribute in the current element. Returns
|
|
|
|
/// true if the cursor position was set successfully.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool MoveToFirstAttribute() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Moves the cursor to the next attribute in the current element. Returns
|
|
|
|
/// true if the cursor position was set successfully.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool MoveToNextAttribute() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
///
|
2022-09-01 04:03:04 +02:00
|
|
|
/// Moves the cursor back to the carrying element. Returns true if the cursor
|
|
|
|
/// position was set successfully.
|
2012-04-03 03:34:16 +02:00
|
|
|
///
|
|
|
|
/*--cef()--*/
|
2017-05-17 11:29:28 +02:00
|
|
|
virtual bool MoveToCarryingElement() = 0;
|
2012-04-03 03:34:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_INCLUDE_CEF_XML_READER_H_
|