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 XFA_FGAS_XML_FGAS_SAX_IMP_H_ | 7 #ifndef XFA_FGAS_XML_FGAS_SAX_IMP_H_ |
8 #define XFA_FGAS_XML_FGAS_SAX_IMP_H_ | 8 #define XFA_FGAS_XML_FGAS_SAX_IMP_H_ |
9 | 9 |
10 #include "xfa/fgas/xml/fgas_sax.h" | 10 #include "xfa/fgas/xml/fgas_sax.h" |
11 | 11 |
12 class CFX_SAXFile { | 12 class CFX_SAXFile { |
13 public: | 13 public: |
14 CFX_SAXFile(); | 14 CFX_SAXFile(); |
15 FX_BOOL StartFile(IFX_FileRead* pFile, FX_DWORD dwStart, FX_DWORD dwLen); | 15 FX_BOOL StartFile(IFX_FileRead* pFile, uint32_t dwStart, uint32_t dwLen); |
16 FX_BOOL ReadNextBlock(); | 16 FX_BOOL ReadNextBlock(); |
17 void Reset(); | 17 void Reset(); |
18 IFX_FileRead* m_pFile; | 18 IFX_FileRead* m_pFile; |
19 FX_DWORD m_dwStart; | 19 uint32_t m_dwStart; |
20 FX_DWORD m_dwEnd; | 20 uint32_t m_dwEnd; |
21 FX_DWORD m_dwCur; | 21 uint32_t m_dwCur; |
22 uint8_t* m_pBuf; | 22 uint8_t* m_pBuf; |
23 FX_DWORD m_dwBufSize; | 23 uint32_t m_dwBufSize; |
24 FX_DWORD m_dwBufIndex; | 24 uint32_t m_dwBufIndex; |
25 }; | 25 }; |
26 | 26 |
27 enum FX_SAXMODE { | 27 enum FX_SAXMODE { |
28 FX_SAXMODE_Text = 0, | 28 FX_SAXMODE_Text = 0, |
29 FX_SAXMODE_NodeStart, | 29 FX_SAXMODE_NodeStart, |
30 FX_SAXMODE_DeclOrComment, | 30 FX_SAXMODE_DeclOrComment, |
31 FX_SAXMODE_DeclNode, | 31 FX_SAXMODE_DeclNode, |
32 FX_SAXMODE_Comment, | 32 FX_SAXMODE_Comment, |
33 FX_SAXMODE_CommentContent, | 33 FX_SAXMODE_CommentContent, |
34 FX_SAXMODE_TagName, | 34 FX_SAXMODE_TagName, |
(...skipping 11 matching lines...) Expand all Loading... |
46 public: | 46 public: |
47 CFX_SAXItem() | 47 CFX_SAXItem() |
48 : m_pNode(NULL), | 48 : m_pNode(NULL), |
49 m_eNode(FX_SAXNODE_Unknown), | 49 m_eNode(FX_SAXNODE_Unknown), |
50 m_dwID(0), | 50 m_dwID(0), |
51 m_bSkip(FALSE), | 51 m_bSkip(FALSE), |
52 m_pPrev(NULL), | 52 m_pPrev(NULL), |
53 m_pNext(NULL) {} | 53 m_pNext(NULL) {} |
54 void* m_pNode; | 54 void* m_pNode; |
55 FX_SAXNODE m_eNode; | 55 FX_SAXNODE m_eNode; |
56 FX_DWORD m_dwID; | 56 uint32_t m_dwID; |
57 FX_BOOL m_bSkip; | 57 FX_BOOL m_bSkip; |
58 CFX_SAXItem* m_pPrev; | 58 CFX_SAXItem* m_pPrev; |
59 CFX_SAXItem* m_pNext; | 59 CFX_SAXItem* m_pNext; |
60 }; | 60 }; |
61 | 61 |
62 class CFX_SAXCommentContext { | 62 class CFX_SAXCommentContext { |
63 public: | 63 public: |
64 CFX_SAXCommentContext() : m_iHeaderCount(0), m_iTailCount(0) {} | 64 CFX_SAXCommentContext() : m_iHeaderCount(0), m_iTailCount(0) {} |
65 int32_t m_iHeaderCount; | 65 int32_t m_iHeaderCount; |
66 int32_t m_iTailCount; | 66 int32_t m_iTailCount; |
67 }; | 67 }; |
68 | 68 |
69 class CFX_SAXReader : public IFX_SAXReader { | 69 class CFX_SAXReader : public IFX_SAXReader { |
70 public: | 70 public: |
71 CFX_SAXReader(); | 71 CFX_SAXReader(); |
72 ~CFX_SAXReader(); | 72 ~CFX_SAXReader(); |
73 virtual void Release() { delete this; } | 73 virtual void Release() { delete this; } |
74 virtual int32_t StartParse(IFX_FileRead* pFile, | 74 virtual int32_t StartParse(IFX_FileRead* pFile, |
75 FX_DWORD dwStart = 0, | 75 uint32_t dwStart = 0, |
76 FX_DWORD dwLen = -1, | 76 uint32_t dwLen = -1, |
77 FX_DWORD dwParseMode = 0); | 77 uint32_t dwParseMode = 0); |
78 virtual int32_t ContinueParse(IFX_Pause* pPause = NULL); | 78 virtual int32_t ContinueParse(IFX_Pause* pPause = NULL); |
79 virtual void SkipCurrentNode(); | 79 virtual void SkipCurrentNode(); |
80 virtual void SetHandler(IFX_SAXReaderHandler* pHandler); | 80 virtual void SetHandler(IFX_SAXReaderHandler* pHandler); |
81 void AppendData(uint8_t ch); | 81 void AppendData(uint8_t ch); |
82 void AppendName(uint8_t ch); | 82 void AppendName(uint8_t ch); |
83 void ParseText(); | 83 void ParseText(); |
84 void ParseNodeStart(); | 84 void ParseNodeStart(); |
85 void ParseInstruction(); | 85 void ParseInstruction(); |
86 void ParseDeclOrComment(); | 86 void ParseDeclOrComment(); |
87 void ParseDeclNode(); | 87 void ParseDeclNode(); |
88 void ParseComment(); | 88 void ParseComment(); |
89 void ParseCommentContent(); | 89 void ParseCommentContent(); |
90 void ParseTagName(); | 90 void ParseTagName(); |
91 void ParseTagAttributeName(); | 91 void ParseTagAttributeName(); |
92 void ParseTagAttributeEqual(); | 92 void ParseTagAttributeEqual(); |
93 void ParseTagAttributeValue(); | 93 void ParseTagAttributeValue(); |
94 void ParseMaybeClose(); | 94 void ParseMaybeClose(); |
95 void ParseTagClose(); | 95 void ParseTagClose(); |
96 void ParseTagEnd(); | 96 void ParseTagEnd(); |
97 void ParseTargetData(); | 97 void ParseTargetData(); |
98 | 98 |
99 protected: | 99 protected: |
100 CFX_SAXFile m_File; | 100 CFX_SAXFile m_File; |
101 IFX_SAXReaderHandler* m_pHandler; | 101 IFX_SAXReaderHandler* m_pHandler; |
102 int32_t m_iState; | 102 int32_t m_iState; |
103 CFX_SAXItem* m_pRoot; | 103 CFX_SAXItem* m_pRoot; |
104 CFX_SAXItem* m_pCurItem; | 104 CFX_SAXItem* m_pCurItem; |
105 FX_DWORD m_dwItemID; | 105 uint32_t m_dwItemID; |
106 FX_SAXMODE m_eMode; | 106 FX_SAXMODE m_eMode; |
107 FX_SAXMODE m_ePrevMode; | 107 FX_SAXMODE m_ePrevMode; |
108 FX_BOOL m_bCharData; | 108 FX_BOOL m_bCharData; |
109 uint8_t m_CurByte; | 109 uint8_t m_CurByte; |
110 FX_DWORD m_dwDataOffset; | 110 uint32_t m_dwDataOffset; |
111 CFX_ByteArray m_SkipStack; | 111 CFX_ByteArray m_SkipStack; |
112 uint8_t m_SkipChar; | 112 uint8_t m_SkipChar; |
113 FX_DWORD m_dwNodePos; | 113 uint32_t m_dwNodePos; |
114 uint8_t* m_pszData; | 114 uint8_t* m_pszData; |
115 int32_t m_iDataSize; | 115 int32_t m_iDataSize; |
116 int32_t m_iDataLength; | 116 int32_t m_iDataLength; |
117 int32_t m_iEntityStart; | 117 int32_t m_iEntityStart; |
118 int32_t m_iDataPos; | 118 int32_t m_iDataPos; |
119 uint8_t* m_pszName; | 119 uint8_t* m_pszName; |
120 int32_t m_iNameSize; | 120 int32_t m_iNameSize; |
121 int32_t m_iNameLength; | 121 int32_t m_iNameLength; |
122 FX_DWORD m_dwParseMode; | 122 uint32_t m_dwParseMode; |
123 CFX_SAXCommentContext* m_pCommentContext; | 123 CFX_SAXCommentContext* m_pCommentContext; |
124 void Reset(); | 124 void Reset(); |
125 void Push(); | 125 void Push(); |
126 void Pop(); | 126 void Pop(); |
127 FX_BOOL SkipSpace(uint8_t ch); | 127 FX_BOOL SkipSpace(uint8_t ch); |
128 void SkipNode(); | 128 void SkipNode(); |
129 void NotifyData(); | 129 void NotifyData(); |
130 void NotifyEnter(); | 130 void NotifyEnter(); |
131 void NotifyAttribute(); | 131 void NotifyAttribute(); |
132 void NotifyBreak(); | 132 void NotifyBreak(); |
133 void NotifyClose(); | 133 void NotifyClose(); |
134 void NotifyEnd(); | 134 void NotifyEnd(); |
135 void NotifyTargetData(); | 135 void NotifyTargetData(); |
136 void ReallocDataBuffer(); | 136 void ReallocDataBuffer(); |
137 void ReallocNameBuffer(); | 137 void ReallocNameBuffer(); |
138 void ParseChar(uint8_t ch); | 138 void ParseChar(uint8_t ch); |
139 }; | 139 }; |
140 | 140 |
141 #endif // XFA_FGAS_XML_FGAS_SAX_IMP_H_ | 141 #endif // XFA_FGAS_XML_FGAS_SAX_IMP_H_ |
OLD | NEW |