Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cfx_xmlparser.h
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#ifndef CORE_FXCRT_XML_CFX_XMLPARSER_H_
8#define CORE_FXCRT_XML_CFX_XMLPARSER_H_
9
10#include <memory>
11#include <optional>
12
13#include "core/fxcrt/retain_ptr.h"
14#include "core/fxcrt/unowned_ptr.h"
15#include "core/fxcrt/widestring.h"
16
17class CFX_SeekableStreamProxy;
18class CFX_XMLDocument;
19class CFX_XMLNode;
21
22class CFX_XMLParser final {
23 public:
24 static bool IsXMLNameChar(wchar_t ch, bool bFirstChar);
25
26 explicit CFX_XMLParser(const RetainPtr<IFX_SeekableReadStream>& pStream);
28
30
31 private:
32 enum class FDE_XmlSyntaxState {
33 Text,
34 Node,
35 Target,
36 Tag,
37 AttriName,
38 AttriEqualSign,
39 AttriQuotation,
40 AttriValue,
41 CloseInstruction,
42 BreakElement,
43 CloseElement,
44 SkipDeclNode,
45 SkipComment,
46 SkipCommentOrDecl,
47 SkipCData,
48 TargetData
49 };
50
51 bool DoSyntaxParse(CFX_XMLDocument* doc);
52 WideString GetTextData();
53 void ProcessTextChar(wchar_t ch);
54 void ProcessTargetData();
55
56 UnownedPtr<CFX_XMLNode> current_node_;
57 RetainPtr<CFX_SeekableStreamProxy> stream_;
58 WideString current_text_;
59 size_t xml_plane_size_ = 1024;
60 std::optional<size_t> entity_start_;
61};
62
63#endif // CORE_FXCRT_XML_CFX_XMLPARSER_H_
CFX_XMLElement * ToXMLElement(CFX_XMLNode *pNode)
const CFX_XMLElement * ToXMLElement(const CFX_XMLNode *pNode)
#define DCHECK
Definition check.h:33
CFX_XMLElement * GetRoot() const
T * CreateNode(Args &&... args)
void AppendNodesFrom(CFX_XMLDocument *other)
void Save(const RetainPtr< IFX_RetainableWriteStream > &pXMLStream) override
WideString GetNamespacePrefix() const
WideString GetTextData() const
const WideString & GetName() const
CFX_XMLNode * Clone(CFX_XMLDocument *doc) override
~CFX_XMLElement() override
CFX_XMLElement(const WideString &wsTag)
bool HasAttribute(const WideString &name) const
WideString GetLocalTagName() const
Type GetType() const override
WideString GetAttribute(const WideString &name) const
WideString GetNamespaceURI() const
void SetAttribute(const WideString &name, const WideString &value)
CFX_XMLElement * GetFirstChildNamed(WideStringView name) const
void RemoveAttribute(const WideString &name)
const std::map< WideString, WideString > & GetAttributes() const
CFX_XMLElement * GetNthChildNamed(WideStringView name, size_t idx) const
virtual void Save(const RetainPtr< IFX_RetainableWriteStream > &pXMLStream)=0
void InsertChildNode(CFX_XMLNode *pNode, int32_t index)
virtual CFX_XMLNode * Clone(CFX_XMLDocument *doc)=0
virtual Type GetType() const =0
~CFX_XMLNode() override
CFX_XMLNode * GetRoot()
CFX_XMLParser(const RetainPtr< IFX_SeekableReadStream > &pStream)
static bool IsXMLNameChar(wchar_t ch, bool bFirstChar)
std::unique_ptr< CFX_XMLDocument > Parse()
std::vector< UnsupportedFeature > CheckForSharedForm() const
CPDF_Metadata(RetainPtr< const CPDF_Stream > pStream)
bool HasChild(const T *child) const
Definition tree_node.h:39
void RemoveSelfIfParented()
Definition tree_node.h:141
void AppendLastChild(T *child)
Definition tree_node.h:67
T * GetPrevSibling() const
Definition tree_node.h:35
T * GetParent() const
Definition tree_node.h:25
void RemoveChild(T *child)
Definition tree_node.h:117
T * GetLastChild() const
Definition tree_node.h:29
virtual ~TreeNodeBase()=default
T * GetNthChild(int32_t n)
Definition tree_node.h:43
T * GetFirstChild() const
Definition tree_node.h:26
void InsertBefore(T *child, T *other)
Definition tree_node.h:81
T * GetNextSibling() const
Definition tree_node.h:32
void InsertAfter(T *child, T *other)
Definition tree_node.h:99
void AppendFirstChild(T *child)
Definition tree_node.h:53
TreeNodeBase()=default
TreeNode()=default
virtual ~TreeNode()=default
static WideString FromASCII(ByteStringView str)
bool EqualsASCII(ByteStringView that) const
Definition widestring.h:111
UnsupportedFeature
#define CHECK(cvref)
fxcrt::WideStringView WideStringView
#define UNOWNED_PTR_EXCLUSION
fxcrt::WideString WideString
Definition widestring.h:207