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

Side by Side Diff: core/include/fxcrt/fx_xml.h

Issue 1265503005: clang-format all pdfium code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: sigh Created 5 years, 4 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 unified diff | Download patch
OLDNEW
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_INCLUDE_FXCRT_FX_XML_H_ 7 #ifndef CORE_INCLUDE_FXCRT_FX_XML_H_
8 #define CORE_INCLUDE_FXCRT_FX_XML_H_ 8 #define CORE_INCLUDE_FXCRT_FX_XML_H_
9 9
10 #include "fx_basic.h" 10 #include "fx_basic.h"
11 11
12 class CXML_AttrItem 12 class CXML_AttrItem {
13 { 13 public:
14 public: 14 CFX_ByteString m_QSpaceName;
15 CFX_ByteString» m_QSpaceName; 15 CFX_ByteString m_AttrName;
16 CFX_ByteString» m_AttrName; 16 CFX_WideString m_Value;
17 CFX_WideString» m_Value;
18 }; 17 };
19 class CXML_AttrMap 18 class CXML_AttrMap {
20 { 19 public:
21 public: 20 CXML_AttrMap() { m_pMap = NULL; }
22 CXML_AttrMap() 21 ~CXML_AttrMap() { RemoveAll(); }
23 { 22 const CFX_WideString* Lookup(const CFX_ByteStringC& space,
24 m_pMap = NULL; 23 const CFX_ByteStringC& name) const;
25 } 24 void SetAt(const CFX_ByteStringC& space,
26 ~CXML_AttrMap() 25 const CFX_ByteStringC& name,
27 { 26 const CFX_WideStringC& value);
28 RemoveAll(); 27 void RemoveAt(const CFX_ByteStringC& space, const CFX_ByteStringC& name);
29 } 28 void RemoveAll();
30 const CFX_WideString*» Lookup(const CFX_ByteStringC& space, const CFX_B yteStringC& name) const; 29 int GetSize() const;
31 void» » » » » SetAt(const CFX_ByteStringC& spa ce, const CFX_ByteStringC& name, const CFX_WideStringC& value); 30 CXML_AttrItem& GetAt(int index) const;
32 void» » » » » RemoveAt(const CFX_ByteStringC& space, const CFX_ByteStringC& name); 31 CFX_ObjectArray<CXML_AttrItem>* m_pMap;
33 void» » » » » RemoveAll();
34 int»» » » » » GetSize() const;
35 CXML_AttrItem&» » » GetAt(int index) const;
36 CFX_ObjectArray<CXML_AttrItem>*» m_pMap;
37 }; 32 };
38 class CXML_Content 33 class CXML_Content {
39 { 34 public:
40 public: 35 CXML_Content() : m_bCDATA(FALSE), m_Content() {}
41 CXML_Content() : m_bCDATA(FALSE), m_Content() {} 36 void Set(FX_BOOL bCDATA, const CFX_WideStringC& content) {
42 void» Set(FX_BOOL bCDATA, const CFX_WideStringC& content) 37 m_bCDATA = bCDATA;
43 { 38 m_Content = content;
44 m_bCDATA = bCDATA; 39 }
45 m_Content = content; 40 FX_BOOL m_bCDATA;
46 } 41 CFX_WideString m_Content;
47 FX_BOOL» » » m_bCDATA;
48 CFX_WideString» m_Content;
49 }; 42 };
50 class CXML_Element 43 class CXML_Element {
51 { 44 public:
52 public: 45 static CXML_Element* Parse(const void* pBuffer,
53 static CXML_Element*» Parse(const void* pBuffer, size_t size, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL); 46 size_t size,
54 static CXML_Element*» Parse(IFX_FileRead *pFile, FX_BOOL bSaveSpaceCha rs = FALSE, FX_FILESIZE* pParsedSize = NULL); 47 FX_BOOL bSaveSpaceChars = FALSE,
55 static CXML_Element*» Parse(IFX_BufferRead *pBuffer, FX_BOOL bSaveSpac eChars = FALSE, FX_FILESIZE* pParsedSize = NULL); 48 FX_FILESIZE* pParsedSize = NULL);
56 CXML_Element(const CFX_ByteStringC& qSpace, const CFX_ByteStringC& tagName); 49 static CXML_Element* Parse(IFX_FileRead* pFile,
57 CXML_Element(const CFX_ByteStringC& qTagName); 50 FX_BOOL bSaveSpaceChars = FALSE,
58 CXML_Element(); 51 FX_FILESIZE* pParsedSize = NULL);
52 static CXML_Element* Parse(IFX_BufferRead* pBuffer,
53 FX_BOOL bSaveSpaceChars = FALSE,
54 FX_FILESIZE* pParsedSize = NULL);
55 CXML_Element(const CFX_ByteStringC& qSpace, const CFX_ByteStringC& tagName);
56 CXML_Element(const CFX_ByteStringC& qTagName);
57 CXML_Element();
59 58
60 ~CXML_Element(); 59 ~CXML_Element();
61 60
62 void» Empty(); 61 void Empty();
63 62
63 CFX_ByteString GetTagName(FX_BOOL bQualified = FALSE) const;
64 64
65 CFX_ByteString GetNamespace(FX_BOOL bQualified = FALSE) const;
65 66
66 CFX_ByteString» » » GetTagName(FX_BOOL bQualified = FALSE) c onst; 67 CFX_ByteString GetNamespaceURI(const CFX_ByteStringC& qName) const;
67 68
68 CFX_ByteString» » » GetNamespace(FX_BOOL bQualified = FALSE) const; 69 CXML_Element* GetParent() const { return m_pParent; }
69 70
70 CFX_ByteString» » » GetNamespaceURI(const CFX_ByteStringC& q Name) const; 71 FX_DWORD CountAttrs() const { return m_AttrMap.GetSize(); }
71 72
72 CXML_Element*» » » GetParent() const 73 void GetAttrByIndex(int index,
73 { 74 CFX_ByteString& space,
74 return m_pParent; 75 CFX_ByteString& name,
75 } 76 CFX_WideString& value) const;
76 77
77 FX_DWORD» » » » CountAttrs() const 78 FX_BOOL HasAttr(const CFX_ByteStringC& qName) const;
78 {
79 return m_AttrMap.GetSize();
80 }
81 79
82 void» » » » » GetAttrByIndex(int index, CFX_By teString &space, CFX_ByteString &name, CFX_WideString &value) const; 80 FX_BOOL GetAttrValue(const CFX_ByteStringC& name,
81 CFX_WideString& attribute) const;
82 CFX_WideString GetAttrValue(const CFX_ByteStringC& name) const {
83 CFX_WideString attr;
84 GetAttrValue(name, attr);
85 return attr;
86 }
83 87
84 FX_BOOL» » » » » HasAttr(const CFX_ByteStringC& q Name) const; 88 FX_BOOL GetAttrValue(const CFX_ByteStringC& space,
89 const CFX_ByteStringC& name,
90 CFX_WideString& attribute) const;
91 CFX_WideString GetAttrValue(const CFX_ByteStringC& space,
92 const CFX_ByteStringC& name) const {
93 CFX_WideString attr;
94 GetAttrValue(space, name, attr);
95 return attr;
96 }
85 97
86 FX_BOOL» » » » » GetAttrValue(const CFX_ByteStrin gC& name, CFX_WideString& attribute) const; 98 FX_BOOL GetAttrInteger(const CFX_ByteStringC& name, int& attribute) const;
87 CFX_WideString» » » GetAttrValue(const CFX_ByteStringC& name ) const 99 int GetAttrInteger(const CFX_ByteStringC& name) const {
88 { 100 int attr = 0;
89 CFX_WideString attr; 101 GetAttrInteger(name, attr);
90 GetAttrValue(name, attr); 102 return attr;
91 return attr; 103 }
92 }
93 104
94 FX_BOOL» » » » » GetAttrValue(const CFX_ByteStrin gC& space, const CFX_ByteStringC& name, CFX_WideString& attribute) const; 105 FX_BOOL GetAttrInteger(const CFX_ByteStringC& space,
95 CFX_WideString» » » GetAttrValue(const CFX_ByteStringC& spac e, const CFX_ByteStringC& name) const 106 const CFX_ByteStringC& name,
96 { 107 int& attribute) const;
97 CFX_WideString attr; 108 int GetAttrInteger(const CFX_ByteStringC& space,
98 GetAttrValue(space, name, attr); 109 const CFX_ByteStringC& name) const {
99 return attr; 110 int attr = 0;
100 } 111 GetAttrInteger(space, name, attr);
112 return attr;
113 }
101 114
102 FX_BOOL» » » » » GetAttrInteger(const CFX_ByteStr ingC& name, int& attribute) const; 115 FX_BOOL GetAttrFloat(const CFX_ByteStringC& name, FX_FLOAT& attribute) const;
103 int»» » » » » GetAttrInteger(const CFX_ByteStr ingC& name) const 116 FX_FLOAT GetAttrFloat(const CFX_ByteStringC& name) const {
104 { 117 FX_FLOAT attr = 0;
105 int attr = 0; 118 GetAttrFloat(name, attr);
106 GetAttrInteger(name, attr); 119 return attr;
107 return attr; 120 }
108 }
109 121
110 FX_BOOL» » » » » GetAttrInteger(const CFX_ByteStr ingC& space, const CFX_ByteStringC& name, int& attribute) const; 122 FX_BOOL GetAttrFloat(const CFX_ByteStringC& space,
111 int»» » » » » GetAttrInteger(const CFX_ByteStr ingC& space, const CFX_ByteStringC& name) const 123 const CFX_ByteStringC& name,
112 { 124 FX_FLOAT& attribute) const;
113 int attr = 0; 125 FX_FLOAT GetAttrFloat(const CFX_ByteStringC& space,
114 GetAttrInteger(space, name, attr); 126 const CFX_ByteStringC& name) const {
115 return attr; 127 FX_FLOAT attr = 0;
116 } 128 GetAttrFloat(space, name, attr);
129 return attr;
130 }
117 131
118 FX_BOOL» » » » » GetAttrFloat(const CFX_ByteStrin gC& name, FX_FLOAT& attribute) const; 132 FX_DWORD CountChildren() const;
119 FX_FLOAT» » » » GetAttrFloat(const CFX_ByteStringC& name ) const
120 {
121 FX_FLOAT attr = 0;
122 GetAttrFloat(name, attr);
123 return attr;
124 }
125 133
126 FX_BOOL» » » » » GetAttrFloat(const CFX_ByteStrin gC& space, const CFX_ByteStringC& name, FX_FLOAT& attribute) const; 134 enum ChildType { Invalid, Element, Content };
127 FX_FLOAT» » » » GetAttrFloat(const CFX_ByteStringC& spac e, const CFX_ByteStringC& name) const
128 {
129 FX_FLOAT attr = 0;
130 GetAttrFloat(space, name, attr);
131 return attr;
132 }
133 135
134 FX_DWORD» » » » CountChildren() const; 136 ChildType GetChildType(FX_DWORD index) const;
135 137
136 enum ChildType { Invalid, Element, Content}; 138 CFX_WideString GetContent(FX_DWORD index) const;
137 139
138 ChildType» » » » GetChildType(FX_DWORD index) const; 140 CXML_Element* GetElement(FX_DWORD index) const;
139 141
140 CFX_WideString» » » GetContent(FX_DWORD index) const; 142 CXML_Element* GetElement(const CFX_ByteStringC& space,
143 const CFX_ByteStringC& tag) const {
144 return GetElement(space, tag, 0);
145 }
141 146
142 CXML_Element*» » » GetElement(FX_DWORD index) const; 147 FX_DWORD CountElements(const CFX_ByteStringC& space,
148 const CFX_ByteStringC& tag) const;
143 149
144 CXML_Element*» » » GetElement(const CFX_ByteStringC& space, const CFX_ByteStringC& tag) const 150 CXML_Element* GetElement(const CFX_ByteStringC& space,
145 { 151 const CFX_ByteStringC& tag,
146 return GetElement(space, tag, 0); 152 int index) const;
147 }
148 153
149 FX_DWORD» » » » CountElements(const CFX_ByteStringC& spa ce, const CFX_ByteStringC& tag) const; 154 FX_DWORD FindElement(CXML_Element* pChild) const;
150 155
151 CXML_Element*» » » GetElement(const CFX_ByteStringC& space, const CFX_ByteStringC& tag, int index) const; 156 void SetTag(const CFX_ByteStringC& qSpace, const CFX_ByteStringC& tagname);
152 157
153 FX_DWORD» » » » FindElement(CXML_Element *pChild) const; 158 void SetTag(const CFX_ByteStringC& qTagName);
154 159
160 void RemoveChildren();
155 161
162 void RemoveChild(FX_DWORD index);
156 163
164 protected:
165 CXML_Element* m_pParent;
166 CFX_ByteString m_QSpaceName;
167 CFX_ByteString m_TagName;
157 168
158 void» » » » » SetTag(const CFX_ByteStringC& qS pace, const CFX_ByteStringC& tagname); 169 CXML_AttrMap m_AttrMap;
159 170
160 void» » » » » SetTag(const CFX_ByteStringC& qT agName); 171 CFX_PtrArray m_Children;
161 172 friend class CXML_Parser;
162 void» » » » » RemoveChildren(); 173 friend class CXML_Composer;
163
164 void» » » » » RemoveChild(FX_DWORD index);
165
166
167 protected:
168
169 CXML_Element*» » » m_pParent;
170 CFX_ByteString» » » m_QSpaceName;
171 CFX_ByteString» » » m_TagName;
172
173 CXML_AttrMap» » » m_AttrMap;
174
175 CFX_PtrArray» » » m_Children;
176 friend class CXML_Parser;
177 friend class CXML_Composer;
178 }; 174 };
179 175
180 #endif // CORE_INCLUDE_FXCRT_FX_XML_H_ 176 #endif // CORE_INCLUDE_FXCRT_FX_XML_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698