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_XML_INT_H_ | 7 #ifndef CORE_FXCRT_XML_INT_H_ |
8 #define CORE_FXCRT_XML_INT_H_ | 8 #define CORE_FXCRT_XML_INT_H_ |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 | 11 |
12 #include "core/fxcrt/fx_stream.h" | 12 #include "core/fxcrt/fx_stream.h" |
13 | 13 |
14 class CFX_UTF8Decoder; | 14 class CFX_UTF8Decoder; |
15 class CXML_Element; | 15 class CXML_Element; |
16 | 16 |
17 class CXML_DataBufAcc : public IFX_BufferRead { | 17 class CXML_DataBufAcc : public IFX_BufferRead { |
18 public: | 18 public: |
19 CXML_DataBufAcc(const uint8_t* pBuffer, size_t size); | 19 CXML_DataBufAcc(const uint8_t* pBuffer, size_t size); |
20 ~CXML_DataBufAcc() override; | 20 ~CXML_DataBufAcc() override; |
21 | 21 |
22 // IFX_BufferRead | 22 // IFX_BufferRead |
23 void Release() override; | 23 void Release() override; |
24 FX_BOOL IsEOF() override; | 24 bool IsEOF() override; |
25 FX_FILESIZE GetPosition() override; | 25 FX_FILESIZE GetPosition() override; |
26 size_t ReadBlock(void* buffer, size_t size) override; | 26 size_t ReadBlock(void* buffer, size_t size) override; |
27 FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) override; | 27 bool ReadNextBlock(bool bRestart = FALSE) override; |
28 const uint8_t* GetBlockBuffer() override; | 28 const uint8_t* GetBlockBuffer() override; |
29 size_t GetBlockSize() override; | 29 size_t GetBlockSize() override; |
30 FX_FILESIZE GetBlockOffset() override; | 30 FX_FILESIZE GetBlockOffset() override; |
31 | 31 |
32 protected: | 32 protected: |
33 const uint8_t* m_pBuffer; | 33 const uint8_t* m_pBuffer; |
34 size_t m_dwSize; | 34 size_t m_dwSize; |
35 size_t m_dwCurPos; | 35 size_t m_dwCurPos; |
36 }; | 36 }; |
37 | 37 |
38 class CXML_DataStmAcc : public IFX_BufferRead { | 38 class CXML_DataStmAcc : public IFX_BufferRead { |
39 public: | 39 public: |
40 explicit CXML_DataStmAcc(IFX_SeekableReadStream* pFileRead); | 40 explicit CXML_DataStmAcc(IFX_SeekableReadStream* pFileRead); |
41 ~CXML_DataStmAcc() override; | 41 ~CXML_DataStmAcc() override; |
42 | 42 |
43 // IFX_BufferRead | 43 // IFX_BufferRead |
44 void Release() override; | 44 void Release() override; |
45 FX_BOOL IsEOF() override; | 45 bool IsEOF() override; |
46 FX_FILESIZE GetPosition() override; | 46 FX_FILESIZE GetPosition() override; |
47 size_t ReadBlock(void* buffer, size_t size) override; | 47 size_t ReadBlock(void* buffer, size_t size) override; |
48 FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) override; | 48 bool ReadNextBlock(bool bRestart = FALSE) override; |
49 const uint8_t* GetBlockBuffer() override; | 49 const uint8_t* GetBlockBuffer() override; |
50 size_t GetBlockSize() override; | 50 size_t GetBlockSize() override; |
51 FX_FILESIZE GetBlockOffset() override; | 51 FX_FILESIZE GetBlockOffset() override; |
52 | 52 |
53 protected: | 53 protected: |
54 IFX_SeekableReadStream* m_pFileRead; | 54 IFX_SeekableReadStream* m_pFileRead; |
55 uint8_t* m_pBuffer; | 55 uint8_t* m_pBuffer; |
56 FX_FILESIZE m_nStart; | 56 FX_FILESIZE m_nStart; |
57 size_t m_dwSize; | 57 size_t m_dwSize; |
58 }; | 58 }; |
59 | 59 |
60 class CXML_Parser { | 60 class CXML_Parser { |
61 public: | 61 public: |
62 CXML_Parser(); | 62 CXML_Parser(); |
63 ~CXML_Parser(); | 63 ~CXML_Parser(); |
64 | 64 |
65 FX_BOOL Init(uint8_t* pBuffer, size_t size); | 65 bool Init(uint8_t* pBuffer, size_t size); |
66 FX_BOOL Init(IFX_SeekableReadStream* pFileRead); | 66 bool Init(IFX_SeekableReadStream* pFileRead); |
67 FX_BOOL Init(IFX_BufferRead* pBuffer); | 67 bool Init(IFX_BufferRead* pBuffer); |
68 FX_BOOL Init(FX_BOOL bOwndedStream); | 68 bool Init(bool bOwndedStream); |
69 FX_BOOL ReadNextBlock(); | 69 bool ReadNextBlock(); |
70 FX_BOOL IsEOF(); | 70 bool IsEOF(); |
71 FX_BOOL HaveAvailData(); | 71 bool HaveAvailData(); |
72 void SkipWhiteSpaces(); | 72 void SkipWhiteSpaces(); |
73 void GetName(CFX_ByteString& space, CFX_ByteString& name); | 73 void GetName(CFX_ByteString& space, CFX_ByteString& name); |
74 void GetAttrValue(CFX_WideString& value); | 74 void GetAttrValue(CFX_WideString& value); |
75 uint32_t GetCharRef(); | 75 uint32_t GetCharRef(); |
76 void GetTagName(CFX_ByteString& space, | 76 void GetTagName(CFX_ByteString& space, |
77 CFX_ByteString& name, | 77 CFX_ByteString& name, |
78 FX_BOOL& bEndTag, | 78 FX_BOOL& bEndTag, |
79 FX_BOOL bStartTag = FALSE); | 79 FX_BOOL bStartTag = FALSE); |
80 void SkipLiterals(const CFX_ByteStringC& str); | 80 void SkipLiterals(const CFX_ByteStringC& str); |
81 CXML_Element* ParseElement(CXML_Element* pParent, FX_BOOL bStartTag = FALSE); | 81 CXML_Element* ParseElement(CXML_Element* pParent, FX_BOOL bStartTag = FALSE); |
82 void InsertContentSegment(FX_BOOL bCDATA, | 82 void InsertContentSegment(FX_BOOL bCDATA, |
83 const CFX_WideStringC& content, | 83 const CFX_WideStringC& content, |
84 CXML_Element* pElement); | 84 CXML_Element* pElement); |
85 void InsertCDATASegment(CFX_UTF8Decoder& decoder, CXML_Element* pElement); | 85 void InsertCDATASegment(CFX_UTF8Decoder& decoder, CXML_Element* pElement); |
86 | 86 |
87 IFX_BufferRead* m_pDataAcc; | 87 IFX_BufferRead* m_pDataAcc; |
88 FX_BOOL m_bOwnedStream; | 88 bool m_bOwnedStream; |
89 FX_FILESIZE m_nOffset; | 89 FX_FILESIZE m_nOffset; |
90 FX_BOOL m_bSaveSpaceChars; | 90 FX_BOOL m_bSaveSpaceChars; |
91 const uint8_t* m_pBuffer; | 91 const uint8_t* m_pBuffer; |
92 size_t m_dwBufferSize; | 92 size_t m_dwBufferSize; |
93 FX_FILESIZE m_nBufferOffset; | 93 FX_FILESIZE m_nBufferOffset; |
94 size_t m_dwIndex; | 94 size_t m_dwIndex; |
95 }; | 95 }; |
96 | 96 |
97 void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName, | 97 void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName, |
98 CFX_ByteStringC& bsSpace, | 98 CFX_ByteStringC& bsSpace, |
99 CFX_ByteStringC& bsName); | 99 CFX_ByteStringC& bsName); |
100 | 100 |
101 #endif // CORE_FXCRT_XML_INT_H_ | 101 #endif // CORE_FXCRT_XML_INT_H_ |
OLD | NEW |