1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
12 class CXML_AttrItem : public CFX_Object
15 CFX_ByteString m_QSpaceName;
16 CFX_ByteString m_AttrName;
17 CFX_WideString m_Value;
19 class CXML_AttrMap : public CFX_Object
30 const CFX_WideString* Lookup(FX_BSTR space, FX_BSTR name) const;
31 void SetAt(FX_BSTR space, FX_BSTR name, FX_WSTR value);
32 void RemoveAt(FX_BSTR space, FX_BSTR name);
35 CXML_AttrItem& GetAt(int index) const;
36 CFX_ObjectArray<CXML_AttrItem>* m_pMap;
38 class CXML_Content : public CFX_Object
41 CXML_Content() : m_bCDATA(FALSE), m_Content() {}
42 void Set(FX_BOOL bCDATA, FX_WSTR content)
48 CFX_WideString m_Content;
50 class CXML_Element : public CFX_Object
53 static CXML_Element* Parse(const void* pBuffer, size_t size, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL);
54 static CXML_Element* Parse(IFX_FileRead *pFile, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL);
55 static CXML_Element* Parse(IFX_BufferRead *pBuffer, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL);
56 CXML_Element(FX_BSTR qSpace, FX_BSTR tagName);
57 CXML_Element(FX_BSTR qTagName);
66 CFX_ByteString GetTagName(FX_BOOL bQualified = FALSE) const;
68 CFX_ByteString GetNamespace(FX_BOOL bQualified = FALSE) const;
70 CFX_ByteString GetNamespaceURI(FX_BSTR qName) const;
72 CXML_Element* GetParent() const
77 FX_DWORD CountAttrs() const
79 return m_AttrMap.GetSize();
82 void GetAttrByIndex(int index, CFX_ByteString &space, CFX_ByteString &name, CFX_WideString &value) const;
84 FX_BOOL HasAttr(FX_BSTR qName) const;
86 FX_BOOL GetAttrValue(FX_BSTR name, CFX_WideString& attribute) const;
87 CFX_WideString GetAttrValue(FX_BSTR name) const
90 GetAttrValue(name, attr);
94 FX_BOOL GetAttrValue(FX_BSTR space, FX_BSTR name, CFX_WideString& attribute) const;
95 CFX_WideString GetAttrValue(FX_BSTR space, FX_BSTR name) const
98 GetAttrValue(space, name, attr);
102 FX_BOOL GetAttrInteger(FX_BSTR name, int& attribute) const;
103 int GetAttrInteger(FX_BSTR name) const
106 GetAttrInteger(name, attr);
110 FX_BOOL GetAttrInteger(FX_BSTR space, FX_BSTR name, int& attribute) const;
111 int GetAttrInteger(FX_BSTR space, FX_BSTR name) const
114 GetAttrInteger(space, name, attr);
118 FX_BOOL GetAttrFloat(FX_BSTR name, FX_FLOAT& attribute) const;
119 FX_FLOAT GetAttrFloat(FX_BSTR name) const
122 GetAttrFloat(name, attr);
126 FX_BOOL GetAttrFloat(FX_BSTR space, FX_BSTR name, FX_FLOAT& attribute) const;
127 FX_FLOAT GetAttrFloat(FX_BSTR space, FX_BSTR name) const
130 GetAttrFloat(space, name, attr);
134 FX_DWORD CountChildren() const;
136 enum ChildType { Invalid, Element, Content};
138 ChildType GetChildType(FX_DWORD index) const;
140 CFX_WideString GetContent(FX_DWORD index) const;
142 CXML_Element* GetElement(FX_DWORD index) const;
144 CXML_Element* GetElement(FX_BSTR space, FX_BSTR tag) const
146 return GetElement(space, tag, 0);
149 FX_DWORD CountElements(FX_BSTR space, FX_BSTR tag) const;
151 CXML_Element* GetElement(FX_BSTR space, FX_BSTR tag, int index) const;
153 FX_DWORD FindElement(CXML_Element *pChild) const;
158 void SetTag(FX_BSTR qSpace, FX_BSTR tagname);
160 void SetTag(FX_BSTR qTagName);
162 void RemoveChildren();
164 void RemoveChild(FX_DWORD index);
169 CXML_Element* m_pParent;
170 CFX_ByteString m_QSpaceName;
171 CFX_ByteString m_TagName;
173 CXML_AttrMap m_AttrMap;
175 CFX_PtrArray m_Children;
176 friend class CXML_Parser;
177 friend class CXML_Composer;