2011-01-10 02:31:12 +01:00
|
|
|
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
2010-10-20 17:12:46 +02:00
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#ifndef CEF_LIBCEF_XML_READER_IMPL_H_
|
|
|
|
#define CEF_LIBCEF_XML_READER_IMPL_H_
|
|
|
|
#pragma once
|
2010-10-20 17:12:46 +02:00
|
|
|
|
|
|
|
#include <libxml/xmlreader.h>
|
|
|
|
#include <sstream>
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#include "include/cef_xml_reader.h"
|
|
|
|
#include "base/threading/platform_thread.h"
|
|
|
|
|
2010-10-20 17:12:46 +02:00
|
|
|
// Implementation of CefXmlReader
|
2012-01-10 00:46:23 +01:00
|
|
|
class CefXmlReaderImpl : public CefXmlReader {
|
|
|
|
public:
|
2010-10-20 17:12:46 +02:00
|
|
|
CefXmlReaderImpl();
|
|
|
|
~CefXmlReaderImpl();
|
|
|
|
|
|
|
|
// Initialize the reader context.
|
|
|
|
bool Initialize(CefRefPtr<CefStreamReader> stream,
|
2010-11-22 18:49:46 +01:00
|
|
|
EncodingType encodingType, const CefString& URI);
|
2010-10-20 17:12:46 +02:00
|
|
|
|
2011-12-08 02:38:30 +01:00
|
|
|
virtual bool MoveToNextNode() OVERRIDE;
|
|
|
|
virtual bool Close() OVERRIDE;
|
|
|
|
virtual bool HasError() OVERRIDE;
|
|
|
|
virtual CefString GetError() OVERRIDE;
|
|
|
|
virtual NodeType GetType() OVERRIDE;
|
|
|
|
virtual int GetDepth() OVERRIDE;
|
|
|
|
virtual CefString GetLocalName() OVERRIDE;
|
|
|
|
virtual CefString GetPrefix() OVERRIDE;
|
|
|
|
virtual CefString GetQualifiedName() OVERRIDE;
|
|
|
|
virtual CefString GetNamespaceURI() OVERRIDE;
|
|
|
|
virtual CefString GetBaseURI() OVERRIDE;
|
|
|
|
virtual CefString GetXmlLang() OVERRIDE;
|
|
|
|
virtual bool IsEmptyElement() OVERRIDE;
|
|
|
|
virtual bool HasValue() OVERRIDE;
|
|
|
|
virtual CefString GetValue() OVERRIDE;
|
|
|
|
virtual bool HasAttributes() OVERRIDE;
|
|
|
|
virtual size_t GetAttributeCount() OVERRIDE;
|
2011-12-08 11:22:15 +01:00
|
|
|
virtual CefString GetAttribute(int index) OVERRIDE;
|
2011-12-08 02:38:30 +01:00
|
|
|
virtual CefString GetAttribute(const CefString& qualifiedName) OVERRIDE;
|
2010-11-22 18:49:46 +01:00
|
|
|
virtual CefString GetAttribute(const CefString& localName,
|
2011-12-08 02:38:30 +01:00
|
|
|
const CefString& namespaceURI) OVERRIDE;
|
|
|
|
virtual CefString GetInnerXml() OVERRIDE;
|
|
|
|
virtual CefString GetOuterXml() OVERRIDE;
|
|
|
|
virtual int GetLineNumber() OVERRIDE;
|
2011-12-08 11:22:15 +01:00
|
|
|
virtual bool MoveToAttribute(int index) OVERRIDE;
|
2011-12-08 02:38:30 +01:00
|
|
|
virtual bool MoveToAttribute(const CefString& qualifiedName) OVERRIDE;
|
2010-11-22 18:49:46 +01:00
|
|
|
virtual bool MoveToAttribute(const CefString& localName,
|
2011-12-08 02:38:30 +01:00
|
|
|
const CefString& namespaceURI) OVERRIDE;
|
|
|
|
virtual bool MoveToFirstAttribute() OVERRIDE;
|
|
|
|
virtual bool MoveToNextAttribute() OVERRIDE;
|
|
|
|
virtual bool MoveToCarryingElement() OVERRIDE;
|
2010-10-20 17:12:46 +02:00
|
|
|
|
|
|
|
// Add another line to the error string.
|
2010-11-22 18:49:46 +01:00
|
|
|
void AppendError(const CefString& error_str);
|
2010-10-20 17:12:46 +02:00
|
|
|
|
|
|
|
// Verify that the reader exists and is being accessed from the correct
|
|
|
|
// thread.
|
|
|
|
bool VerifyContext();
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
protected:
|
2011-01-07 22:34:20 +01:00
|
|
|
base::PlatformThreadId supported_thread_id_;
|
2010-11-09 22:06:39 +01:00
|
|
|
CefRefPtr<CefStreamReader> stream_;
|
2010-10-20 17:12:46 +02:00
|
|
|
xmlTextReaderPtr reader_;
|
2010-11-22 18:49:46 +01:00
|
|
|
std::stringstream error_buf_;
|
2011-05-20 16:42:25 +02:00
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(CefXMLReaderImpl);
|
2010-10-20 17:12:46 +02:00
|
|
|
};
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#endif // CEF_LIBCEF_XML_READER_IMPL_H_
|