Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Unified Diff: core/include/fxcrt/fx_xml.h

Issue 1665273002: Merge to Master: Remove CFX_PtrArray from fx_xml.h (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | core/src/fxcrt/fx_xml_parser.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/include/fxcrt/fx_xml.h
diff --git a/core/include/fxcrt/fx_xml.h b/core/include/fxcrt/fx_xml.h
index eaf872c1643db5be0e22c2b27ea875f34324e9a9..e1255c1f30f65dad88b74ceeb30798debb74e917 100644
--- a/core/include/fxcrt/fx_xml.h
+++ b/core/include/fxcrt/fx_xml.h
@@ -7,7 +7,9 @@
#ifndef CORE_INCLUDE_FXCRT_FX_XML_H_
#define CORE_INCLUDE_FXCRT_FX_XML_H_
-#include "fx_basic.h"
+#include <vector>
+
+#include "core/include/fxcrt/fx_basic.h"
class CXML_AttrItem {
public:
@@ -15,6 +17,7 @@ class CXML_AttrItem {
CFX_ByteString m_AttrName;
CFX_WideString m_Value;
};
+
class CXML_AttrMap {
public:
CXML_AttrMap() { m_pMap = NULL; }
@@ -30,6 +33,7 @@ class CXML_AttrMap {
CXML_AttrItem& GetAt(int index) const;
CFX_ObjectArray<CXML_AttrItem>* m_pMap;
};
+
class CXML_Content {
public:
CXML_Content() : m_bCDATA(FALSE), m_Content() {}
@@ -40,8 +44,11 @@ class CXML_Content {
FX_BOOL m_bCDATA;
CFX_WideString m_Content;
};
+
class CXML_Element {
public:
+ enum ChildType { Invalid, Element, Content };
+
static CXML_Element* Parse(const void* pBuffer,
size_t size,
FX_BOOL bSaveSpaceChars = FALSE,
@@ -52,31 +59,23 @@ class CXML_Element {
static CXML_Element* Parse(IFX_BufferRead* pBuffer,
FX_BOOL bSaveSpaceChars = FALSE,
FX_FILESIZE* pParsedSize = NULL);
+
CXML_Element(const CFX_ByteStringC& qSpace, const CFX_ByteStringC& tagName);
CXML_Element(const CFX_ByteStringC& qTagName);
CXML_Element();
-
~CXML_Element();
void Empty();
-
CFX_ByteString GetTagName(FX_BOOL bQualified = FALSE) const;
-
CFX_ByteString GetNamespace(FX_BOOL bQualified = FALSE) const;
-
CFX_ByteString GetNamespaceURI(const CFX_ByteStringC& qName) const;
-
CXML_Element* GetParent() const { return m_pParent; }
-
FX_DWORD CountAttrs() const { return m_AttrMap.GetSize(); }
-
void GetAttrByIndex(int index,
CFX_ByteString& space,
CFX_ByteString& name,
CFX_WideString& value) const;
-
FX_BOOL HasAttr(const CFX_ByteStringC& qName) const;
-
FX_BOOL GetAttrValue(const CFX_ByteStringC& name,
CFX_WideString& attribute) const;
CFX_WideString GetAttrValue(const CFX_ByteStringC& name) const {
@@ -129,16 +128,10 @@ class CXML_Element {
return attr;
}
- FX_DWORD CountChildren() const;
-
- enum ChildType { Invalid, Element, Content };
-
+ FX_DWORD CountChildren() const { return m_Children.size(); }
ChildType GetChildType(FX_DWORD index) const;
-
CFX_WideString GetContent(FX_DWORD index) const;
-
CXML_Element* GetElement(FX_DWORD index) const;
-
CXML_Element* GetElement(const CFX_ByteStringC& space,
const CFX_ByteStringC& tag) const {
return GetElement(space, tag, 0);
@@ -146,29 +139,28 @@ class CXML_Element {
FX_DWORD CountElements(const CFX_ByteStringC& space,
const CFX_ByteStringC& tag) const;
-
CXML_Element* GetElement(const CFX_ByteStringC& space,
const CFX_ByteStringC& tag,
int index) const;
FX_DWORD FindElement(CXML_Element* pChild) const;
-
void SetTag(const CFX_ByteStringC& qSpace, const CFX_ByteStringC& tagname);
-
void SetTag(const CFX_ByteStringC& qTagName);
-
void RemoveChildren();
-
void RemoveChild(FX_DWORD index);
protected:
+ struct ChildRecord {
+ ChildType type;
+ void* child; // CXML_Element and CXML_Content lack a common ancestor.
+ };
+
CXML_Element* m_pParent;
CFX_ByteString m_QSpaceName;
CFX_ByteString m_TagName;
-
CXML_AttrMap m_AttrMap;
+ std::vector<ChildRecord> m_Children;
- CFX_PtrArray m_Children;
friend class CXML_Parser;
friend class CXML_Composer;
};
« no previous file with comments | « no previous file | core/src/fxcrt/fx_xml_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698