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

Side by Side Diff: core/src/fxcrt/xml_int.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_SRC_FXCRT_XML_INT_H_ 7 #ifndef CORE_SRC_FXCRT_XML_INT_H_
8 #define CORE_SRC_FXCRT_XML_INT_H_ 8 #define CORE_SRC_FXCRT_XML_INT_H_
9 9
10 #include "../../include/fxcrt/fx_stream.h" 10 #include "../../include/fxcrt/fx_stream.h"
11 11
12 class CXML_DataBufAcc : public IFX_BufferRead 12 class CXML_DataBufAcc : public IFX_BufferRead {
13 { 13 public:
14 public: 14 CXML_DataBufAcc(const uint8_t* pBuffer, size_t size)
15 CXML_DataBufAcc(const uint8_t* pBuffer, size_t size) 15 : m_pBuffer(pBuffer), m_dwSize(size), m_dwCurPos(0) {}
16 : m_pBuffer(pBuffer) 16 virtual ~CXML_DataBufAcc() {}
17 , m_dwSize(size) 17 virtual void Release() { delete this; }
18 , m_dwCurPos(0) 18 virtual FX_BOOL IsEOF() { return m_dwCurPos >= m_dwSize; }
19 { 19 virtual FX_FILESIZE GetPosition() { return (FX_FILESIZE)m_dwCurPos; }
20 virtual size_t ReadBlock(void* buffer, size_t size) { return 0; }
21 virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) {
22 if (bRestart) {
23 m_dwCurPos = 0;
20 } 24 }
21 virtual ~CXML_DataBufAcc() {} 25 if (m_dwCurPos < m_dwSize) {
22 virtual void» » » Release() 26 m_dwCurPos = m_dwSize;
23 { 27 return TRUE;
24 delete this;
25 } 28 }
26 virtual FX_BOOL» » » IsEOF() 29 return FALSE;
27 { 30 }
28 return m_dwCurPos >= m_dwSize; 31 virtual const uint8_t* GetBlockBuffer() { return m_pBuffer; }
32 virtual size_t GetBlockSize() { return m_dwSize; }
33 virtual FX_FILESIZE GetBlockOffset() { return 0; }
34
35 protected:
36 const uint8_t* m_pBuffer;
37 size_t m_dwSize;
38 size_t m_dwCurPos;
39 };
40 #define FX_XMLDATASTREAM_BufferSize (32 * 1024)
41 class CXML_DataStmAcc : public IFX_BufferRead {
42 public:
43 CXML_DataStmAcc(IFX_FileRead* pFileRead)
44 : m_pFileRead(pFileRead), m_pBuffer(NULL), m_nStart(0), m_dwSize(0) {
45 FXSYS_assert(m_pFileRead != NULL);
46 }
47 virtual ~CXML_DataStmAcc() {
48 if (m_pBuffer) {
49 FX_Free(m_pBuffer);
29 } 50 }
30 virtual FX_FILESIZE»» GetPosition() 51 }
31 { 52 virtual void Release() { delete this; }
32 return (FX_FILESIZE)m_dwCurPos; 53 virtual FX_BOOL IsEOF() {
54 return m_nStart + (FX_FILESIZE)m_dwSize >= m_pFileRead->GetSize();
55 }
56 virtual FX_FILESIZE GetPosition() { return m_nStart + (FX_FILESIZE)m_dwSize; }
57 virtual size_t ReadBlock(void* buffer, size_t size) { return 0; }
58 virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) {
59 if (bRestart) {
60 m_nStart = 0;
33 } 61 }
34 virtual size_t» » » ReadBlock(void* buffer, size_t size) 62 FX_FILESIZE nLength = m_pFileRead->GetSize();
35 { 63 m_nStart += (FX_FILESIZE)m_dwSize;
36 return 0; 64 if (m_nStart >= nLength) {
65 return FALSE;
37 } 66 }
38 virtual FX_BOOL» » » ReadNextBlock(FX_BOOL bRestart = FALSE) 67 m_dwSize = (size_t)FX_MIN(FX_XMLDATASTREAM_BufferSize, nLength - m_nStart);
39 { 68 if (!m_pBuffer) {
40 if (bRestart) { 69 m_pBuffer = FX_Alloc(uint8_t, m_dwSize);
41 m_dwCurPos = 0;
42 }
43 if (m_dwCurPos < m_dwSize) {
44 m_dwCurPos = m_dwSize;
45 return TRUE;
46 }
47 return FALSE;
48 } 70 }
49 virtual const uint8_t*» » GetBlockBuffer() 71 return m_pFileRead->ReadBlock(m_pBuffer, m_nStart, m_dwSize);
50 { 72 }
51 return m_pBuffer; 73 virtual const uint8_t* GetBlockBuffer() { return (const uint8_t*)m_pBuffer; }
52 } 74 virtual size_t GetBlockSize() { return m_dwSize; }
53 virtual size_t» » » GetBlockSize() 75 virtual FX_FILESIZE GetBlockOffset() { return m_nStart; }
54 { 76
55 return m_dwSize; 77 protected:
56 } 78 IFX_FileRead* m_pFileRead;
57 virtual FX_FILESIZE»» GetBlockOffset() 79 uint8_t* m_pBuffer;
58 { 80 FX_FILESIZE m_nStart;
59 return 0; 81 size_t m_dwSize;
60 }
61 protected:
62 const uint8_t*» » m_pBuffer;
63 size_t» » » m_dwSize;
64 size_t» » » m_dwCurPos;
65 }; 82 };
66 #define FX_XMLDATASTREAM_BufferSize» » (32 * 1024) 83 class CXML_Parser {
67 class CXML_DataStmAcc : public IFX_BufferRead 84 public:
68 { 85 ~CXML_Parser();
69 public: 86 IFX_BufferRead* m_pDataAcc;
70 CXML_DataStmAcc(IFX_FileRead *pFileRead) 87 FX_BOOL m_bOwnedStream;
71 : m_pFileRead(pFileRead) 88 FX_FILESIZE m_nOffset;
72 , m_pBuffer(NULL) 89 FX_BOOL m_bSaveSpaceChars;
73 , m_nStart(0) 90 const uint8_t* m_pBuffer;
74 , m_dwSize(0) 91 size_t m_dwBufferSize;
75 { 92 FX_FILESIZE m_nBufferOffset;
76 FXSYS_assert(m_pFileRead != NULL); 93 size_t m_dwIndex;
77 } 94 FX_BOOL Init(uint8_t* pBuffer, size_t size);
78 virtual ~CXML_DataStmAcc() 95 FX_BOOL Init(IFX_FileRead* pFileRead);
79 { 96 FX_BOOL Init(IFX_BufferRead* pBuffer);
80 if (m_pBuffer) { 97 FX_BOOL Init(FX_BOOL bOwndedStream);
81 FX_Free(m_pBuffer); 98 FX_BOOL ReadNextBlock();
82 } 99 FX_BOOL IsEOF();
83 } 100 FX_BOOL HaveAvailData();
84 virtual void» » » Release() 101 void SkipWhiteSpaces();
85 { 102 void GetName(CFX_ByteString& space, CFX_ByteString& name);
86 delete this; 103 void GetAttrValue(CFX_WideString& value);
87 } 104 FX_DWORD GetCharRef();
88 virtual FX_BOOL» » » IsEOF() 105 void GetTagName(CFX_ByteString& space,
89 { 106 CFX_ByteString& name,
90 return m_nStart + (FX_FILESIZE)m_dwSize >= m_pFileRead->GetSize(); 107 FX_BOOL& bEndTag,
91 } 108 FX_BOOL bStartTag = FALSE);
92 virtual FX_FILESIZE»» GetPosition() 109 void SkipLiterals(const CFX_ByteStringC& str);
93 { 110 CXML_Element* ParseElement(CXML_Element* pParent, FX_BOOL bStartTag = FALSE);
94 return m_nStart + (FX_FILESIZE)m_dwSize; 111 void InsertContentSegment(FX_BOOL bCDATA,
95 } 112 const CFX_WideStringC& content,
96 virtual size_t» » » ReadBlock(void* buffer, size_t size) 113 CXML_Element* pElement);
97 { 114 void InsertCDATASegment(CFX_UTF8Decoder& decoder, CXML_Element* pElement);
98 return 0;
99 }
100 virtual FX_BOOL» » » ReadNextBlock(FX_BOOL bRestart = FALSE)
101 {
102 if (bRestart) {
103 m_nStart = 0;
104 }
105 FX_FILESIZE nLength = m_pFileRead->GetSize();
106 m_nStart += (FX_FILESIZE)m_dwSize;
107 if (m_nStart >= nLength) {
108 return FALSE;
109 }
110 m_dwSize = (size_t)FX_MIN(FX_XMLDATASTREAM_BufferSize, nLength - m_nStar t);
111 if (!m_pBuffer) {
112 m_pBuffer = FX_Alloc(uint8_t, m_dwSize);
113 }
114 return m_pFileRead->ReadBlock(m_pBuffer, m_nStart, m_dwSize);
115 }
116 virtual const uint8_t*» » GetBlockBuffer()
117 {
118 return (const uint8_t*)m_pBuffer;
119 }
120 virtual size_t» » » GetBlockSize()
121 {
122 return m_dwSize;
123 }
124 virtual FX_FILESIZE»» GetBlockOffset()
125 {
126 return m_nStart;
127 }
128 protected:
129 IFX_FileRead» *m_pFileRead;
130 uint8_t*» » m_pBuffer;
131 FX_FILESIZE»» m_nStart;
132 size_t» » » m_dwSize;
133 }; 115 };
134 class CXML_Parser 116 void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName,
135 { 117 CFX_ByteStringC& bsSpace,
136 public: 118 CFX_ByteStringC& bsName);
137 ~CXML_Parser();
138 IFX_BufferRead*» m_pDataAcc;
139 FX_BOOL» » » m_bOwnedStream;
140 FX_FILESIZE»» m_nOffset;
141 FX_BOOL» » » m_bSaveSpaceChars;
142 const uint8_t*» » m_pBuffer;
143 size_t» » » m_dwBufferSize;
144 FX_FILESIZE»» m_nBufferOffset;
145 size_t» » » m_dwIndex;
146 FX_BOOL» » » Init(uint8_t* pBuffer, size_t size);
147 FX_BOOL» » » Init(IFX_FileRead *pFileRead);
148 FX_BOOL» » » Init(IFX_BufferRead *pBuffer);
149 FX_BOOL» » » Init(FX_BOOL bOwndedStream);
150 FX_BOOL» » » ReadNextBlock();
151 FX_BOOL» » » IsEOF();
152 FX_BOOL» » » HaveAvailData();
153 void» » » SkipWhiteSpaces();
154 void» » » GetName(CFX_ByteString& space, CFX_ByteString& n ame);
155 void» » » GetAttrValue(CFX_WideString &value);
156 FX_DWORD» » GetCharRef();
157 void» » » GetTagName(CFX_ByteString &space, CFX_ByteString &name, FX_BOOL &bEndTag, FX_BOOL bStartTag = FALSE);
158 void» » » SkipLiterals(const CFX_ByteStringC& str);
159 CXML_Element*» ParseElement(CXML_Element* pParent, FX_BOOL bStartTag = FALSE);
160 void» » » InsertContentSegment(FX_BOOL bCDATA, const CFX_W ideStringC& content, CXML_Element* pElement);
161 void» » » InsertCDATASegment(CFX_UTF8Decoder& decoder, CXM L_Element* pElement);
162 };
163 void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName, CFX_ByteString C &bsSpace, CFX_ByteStringC &bsName);
164 119
165 #endif // CORE_SRC_FXCRT_XML_INT_H_ 120 #endif // CORE_SRC_FXCRT_XML_INT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698