OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef CORE_FXCRT_FX_XML_H_ | 7 #ifndef CORE_FXCRT_FX_XML_H_ |
8 #define CORE_FXCRT_FX_XML_H_ | 8 #define CORE_FXCRT_FX_XML_H_ |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 void SetAt(const CFX_ByteString& space, | 34 void SetAt(const CFX_ByteString& space, |
35 const CFX_ByteString& name, | 35 const CFX_ByteString& name, |
36 const CFX_WideString& value); | 36 const CFX_WideString& value); |
37 | 37 |
38 std::unique_ptr<std::vector<CXML_AttrItem>> m_pMap; | 38 std::unique_ptr<std::vector<CXML_AttrItem>> m_pMap; |
39 }; | 39 }; |
40 | 40 |
41 class CXML_Content { | 41 class CXML_Content { |
42 public: | 42 public: |
43 CXML_Content() : m_bCDATA(FALSE), m_Content() {} | 43 CXML_Content() : m_bCDATA(false), m_Content() {} |
44 void Set(FX_BOOL bCDATA, const CFX_WideStringC& content) { | 44 void Set(bool bCDATA, const CFX_WideStringC& content) { |
45 m_bCDATA = bCDATA; | 45 m_bCDATA = bCDATA; |
46 m_Content = content; | 46 m_Content = content; |
47 } | 47 } |
48 | 48 |
49 FX_BOOL m_bCDATA; | 49 bool m_bCDATA; |
50 CFX_WideString m_Content; | 50 CFX_WideString m_Content; |
51 }; | 51 }; |
52 | 52 |
53 class CXML_Element { | 53 class CXML_Element { |
54 public: | 54 public: |
55 enum ChildType { Invalid, Element, Content }; | 55 enum ChildType { Invalid, Element, Content }; |
56 | 56 |
57 static CXML_Element* Parse(const void* pBuffer, | 57 static CXML_Element* Parse(const void* pBuffer, |
58 size_t size, | 58 size_t size, |
59 FX_BOOL bSaveSpaceChars = FALSE, | 59 bool bSaveSpaceChars = false, |
60 FX_FILESIZE* pParsedSize = nullptr); | 60 FX_FILESIZE* pParsedSize = nullptr); |
61 static CXML_Element* Parse(IFX_SeekableReadStream* pFile, | 61 static CXML_Element* Parse(IFX_SeekableReadStream* pFile, |
62 FX_BOOL bSaveSpaceChars = FALSE, | 62 bool bSaveSpaceChars = false, |
63 FX_FILESIZE* pParsedSize = nullptr); | 63 FX_FILESIZE* pParsedSize = nullptr); |
64 static CXML_Element* Parse(IFX_BufferRead* pBuffer, | 64 static CXML_Element* Parse(IFX_BufferRead* pBuffer, |
65 FX_BOOL bSaveSpaceChars = FALSE, | 65 bool bSaveSpaceChars = false, |
66 FX_FILESIZE* pParsedSize = nullptr); | 66 FX_FILESIZE* pParsedSize = nullptr); |
67 | 67 |
68 CXML_Element(const CFX_ByteStringC& qSpace, const CFX_ByteStringC& tagName); | 68 CXML_Element(const CFX_ByteStringC& qSpace, const CFX_ByteStringC& tagName); |
69 CXML_Element(const CFX_ByteStringC& qTagName); | 69 CXML_Element(const CFX_ByteStringC& qTagName); |
70 CXML_Element(); | 70 CXML_Element(); |
71 ~CXML_Element(); | 71 ~CXML_Element(); |
72 | 72 |
73 void Empty(); | 73 void Empty(); |
74 CFX_ByteString GetTagName(FX_BOOL bQualified = FALSE) const; | 74 CFX_ByteString GetTagName(bool bQualified = false) const; |
75 CFX_ByteString GetNamespace(FX_BOOL bQualified = FALSE) const; | 75 CFX_ByteString GetNamespace(bool bQualified = false) const; |
76 CFX_ByteString GetNamespaceURI(const CFX_ByteString& qName) const; | 76 CFX_ByteString GetNamespaceURI(const CFX_ByteString& qName) const; |
77 CXML_Element* GetParent() const { return m_pParent; } | 77 CXML_Element* GetParent() const { return m_pParent; } |
78 uint32_t CountAttrs() const { return m_AttrMap.GetSize(); } | 78 uint32_t CountAttrs() const { return m_AttrMap.GetSize(); } |
79 void GetAttrByIndex(int index, | 79 void GetAttrByIndex(int index, |
80 CFX_ByteString& space, | 80 CFX_ByteString& space, |
81 CFX_ByteString& name, | 81 CFX_ByteString& name, |
82 CFX_WideString& value) const; | 82 CFX_WideString& value) const; |
83 FX_BOOL HasAttr(const CFX_ByteStringC& qName) const; | 83 bool HasAttr(const CFX_ByteStringC& qName) const; |
84 FX_BOOL GetAttrValue(const CFX_ByteStringC& name, | 84 bool GetAttrValue(const CFX_ByteStringC& name, |
85 CFX_WideString& attribute) const; | 85 CFX_WideString& attribute) const; |
86 CFX_WideString GetAttrValue(const CFX_ByteStringC& name) const { | 86 CFX_WideString GetAttrValue(const CFX_ByteStringC& name) const { |
87 CFX_WideString attr; | 87 CFX_WideString attr; |
88 GetAttrValue(name, attr); | 88 GetAttrValue(name, attr); |
89 return attr; | 89 return attr; |
90 } | 90 } |
91 | 91 |
92 FX_BOOL GetAttrValue(const CFX_ByteStringC& space, | 92 bool GetAttrValue(const CFX_ByteStringC& space, |
93 const CFX_ByteStringC& name, | 93 const CFX_ByteStringC& name, |
94 CFX_WideString& attribute) const; | 94 CFX_WideString& attribute) const; |
95 CFX_WideString GetAttrValue(const CFX_ByteStringC& space, | 95 CFX_WideString GetAttrValue(const CFX_ByteStringC& space, |
96 const CFX_ByteStringC& name) const { | 96 const CFX_ByteStringC& name) const { |
97 CFX_WideString attr; | 97 CFX_WideString attr; |
98 GetAttrValue(space, name, attr); | 98 GetAttrValue(space, name, attr); |
99 return attr; | 99 return attr; |
100 } | 100 } |
101 | 101 |
102 FX_BOOL GetAttrInteger(const CFX_ByteStringC& name, int& attribute) const; | 102 bool GetAttrInteger(const CFX_ByteStringC& name, int& attribute) const; |
103 int GetAttrInteger(const CFX_ByteStringC& name) const { | 103 int GetAttrInteger(const CFX_ByteStringC& name) const { |
104 int attr = 0; | 104 int attr = 0; |
105 GetAttrInteger(name, attr); | 105 GetAttrInteger(name, attr); |
106 return attr; | 106 return attr; |
107 } | 107 } |
108 | 108 |
109 FX_BOOL GetAttrInteger(const CFX_ByteStringC& space, | 109 bool GetAttrInteger(const CFX_ByteStringC& space, |
110 const CFX_ByteStringC& name, | 110 const CFX_ByteStringC& name, |
111 int& attribute) const; | 111 int& attribute) const; |
112 int GetAttrInteger(const CFX_ByteStringC& space, | 112 int GetAttrInteger(const CFX_ByteStringC& space, |
113 const CFX_ByteStringC& name) const { | 113 const CFX_ByteStringC& name) const { |
114 int attr = 0; | 114 int attr = 0; |
115 GetAttrInteger(space, name, attr); | 115 GetAttrInteger(space, name, attr); |
116 return attr; | 116 return attr; |
117 } | 117 } |
118 | 118 |
119 FX_BOOL GetAttrFloat(const CFX_ByteStringC& name, FX_FLOAT& attribute) const; | 119 bool GetAttrFloat(const CFX_ByteStringC& name, FX_FLOAT& attribute) const; |
120 FX_FLOAT GetAttrFloat(const CFX_ByteStringC& name) const { | 120 FX_FLOAT GetAttrFloat(const CFX_ByteStringC& name) const { |
121 FX_FLOAT attr = 0; | 121 FX_FLOAT attr = 0; |
122 GetAttrFloat(name, attr); | 122 GetAttrFloat(name, attr); |
123 return attr; | 123 return attr; |
124 } | 124 } |
125 | 125 |
126 FX_BOOL GetAttrFloat(const CFX_ByteStringC& space, | 126 bool GetAttrFloat(const CFX_ByteStringC& space, |
127 const CFX_ByteStringC& name, | 127 const CFX_ByteStringC& name, |
128 FX_FLOAT& attribute) const; | 128 FX_FLOAT& attribute) const; |
129 FX_FLOAT GetAttrFloat(const CFX_ByteStringC& space, | 129 FX_FLOAT GetAttrFloat(const CFX_ByteStringC& space, |
130 const CFX_ByteStringC& name) const { | 130 const CFX_ByteStringC& name) const { |
131 FX_FLOAT attr = 0; | 131 FX_FLOAT attr = 0; |
132 GetAttrFloat(space, name, attr); | 132 GetAttrFloat(space, name, attr); |
133 return attr; | 133 return attr; |
134 } | 134 } |
135 | 135 |
136 uint32_t CountChildren() const { return m_Children.size(); } | 136 uint32_t CountChildren() const { return m_Children.size(); } |
137 ChildType GetChildType(uint32_t index) const; | 137 ChildType GetChildType(uint32_t index) const; |
138 CFX_WideString GetContent(uint32_t index) const; | 138 CFX_WideString GetContent(uint32_t index) const; |
(...skipping 25 matching lines...) Expand all Loading... |
164 CFX_ByteString m_QSpaceName; | 164 CFX_ByteString m_QSpaceName; |
165 CFX_ByteString m_TagName; | 165 CFX_ByteString m_TagName; |
166 CXML_AttrMap m_AttrMap; | 166 CXML_AttrMap m_AttrMap; |
167 std::vector<ChildRecord> m_Children; | 167 std::vector<ChildRecord> m_Children; |
168 | 168 |
169 friend class CXML_Parser; | 169 friend class CXML_Parser; |
170 friend class CXML_Composer; | 170 friend class CXML_Composer; |
171 }; | 171 }; |
172 | 172 |
173 #endif // CORE_FXCRT_FX_XML_H_ | 173 #endif // CORE_FXCRT_FX_XML_H_ |
OLD | NEW |