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_xmlelement.h
Go to the documentation of this file.
1// Copyright 2017 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_XMLELEMENT_H_
8#define CORE_FXCRT_XML_CFX_XMLELEMENT_H_
9
10#include <map>
11
12#include "core/fxcrt/widestring.h"
13#include "core/fxcrt/xml/cfx_xmlnode.h"
14
15class CFX_XMLDocument;
16
17class CFX_XMLElement final : public CFX_XMLNode {
18 public:
19 explicit CFX_XMLElement(const WideString& wsTag);
21
22 // CFX_XMLNode
23 Type GetType() const override;
24 CFX_XMLNode* Clone(CFX_XMLDocument* doc) override;
25 void Save(const RetainPtr<IFX_RetainableWriteStream>& pXMLStream) override;
26
27 const WideString& GetName() const { return name_; }
28
30 return attrs_;
31 }
32 bool HasAttribute(const WideString& name) const;
33 void SetAttribute(const WideString& name, const WideString& value);
34 WideString GetAttribute(const WideString& name) const;
35 void RemoveAttribute(const WideString& name);
36
37 CFX_XMLElement* GetFirstChildNamed(WideStringView name) const;
38 CFX_XMLElement* GetNthChildNamed(WideStringView name, size_t idx) const;
39
40 WideString GetLocalTagName() const;
41 WideString GetNamespacePrefix() const;
42 WideString GetNamespaceURI() const;
43
44 WideString GetTextData() const;
45
46 private:
47 WideString AttributeToString(const WideString& name, const WideString& value);
48
49 const WideString name_;
50 std::map<WideString, WideString> attrs_;
51};
52
53inline CFX_XMLElement* ToXMLElement(CFX_XMLNode* pNode) {
54 return pNode && pNode->GetType() == CFX_XMLNode::Type::kElement
55 ? static_cast<CFX_XMLElement*>(pNode)
56 : nullptr;
57}
58
59inline const CFX_XMLElement* ToXMLElement(const CFX_XMLNode* pNode) {
60 return pNode && pNode->GetType() == CFX_XMLNode::Type::kElement
61 ? static_cast<const CFX_XMLElement*>(pNode)
62 : nullptr;
63}
64
65#endif // CORE_FXCRT_XML_CFX_XMLELEMENT_H_
CFX_XMLElement * ToXMLElement(CFX_XMLNode *pNode)
const CFX_XMLElement * ToXMLElement(const CFX_XMLNode *pNode)
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 Type GetType() const =0
std::vector< UnsupportedFeature > CheckForSharedForm() const
CPDF_Metadata(RetainPtr< const CPDF_Stream > pStream)
static WideString FromASCII(ByteStringView str)
bool EqualsASCII(ByteStringView that) const
Definition widestring.h:216
UnsupportedFeature