summaryrefslogtreecommitdiff
path: root/core/fxcrt/xml/cfx_xmlparser.h
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-04-12 13:15:39 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-12 13:15:39 +0000
commit332139df2c3c0826069fa61bcd436309fcdf5a6f (patch)
tree404ec9e20810029fc132ea0c7cdcbd2eb39aa558 /core/fxcrt/xml/cfx_xmlparser.h
parent6d503b875e6f75f0d8b5f29fcf811a89f12ad12d (diff)
downloadpdfium-332139df2c3c0826069fa61bcd436309fcdf5a6f.tar.xz
Merge CFX_XMLParser and CFX_XMLSyntaxParser
The CFX_XMLParser was a wrapper around the CFX_XMLSyntaxParser. This CL merges the SyntaxParser into protected/private methods if the XMLParser. Change-Id: If1519b5de55866ed14359dffd64dc12c36ee0244 Reviewed-on: https://pdfium-review.googlesource.com/30171 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/xml/cfx_xmlparser.h')
-rw-r--r--core/fxcrt/xml/cfx_xmlparser.h112
1 files changed, 109 insertions, 3 deletions
diff --git a/core/fxcrt/xml/cfx_xmlparser.h b/core/fxcrt/xml/cfx_xmlparser.h
index 8c4c354699..c7587e9151 100644
--- a/core/fxcrt/xml/cfx_xmlparser.h
+++ b/core/fxcrt/xml/cfx_xmlparser.h
@@ -9,29 +9,135 @@
#include <memory>
#include <stack>
+#include <vector>
+#include "core/fxcrt/cfx_blockbuffer.h"
+#include "core/fxcrt/cfx_seekablestreamproxy.h"
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/retain_ptr.h"
-#include "core/fxcrt/xml/cfx_xmlsyntaxparser.h"
+#include "core/fxcrt/xml/cfx_xmlnode.h"
class CFX_XMLElement;
class CFX_XMLNode;
class CFX_SeekableStreamProxy;
+enum class FX_XmlSyntaxResult {
+ None,
+ InstructionOpen,
+ InstructionClose,
+ ElementOpen,
+ ElementBreak,
+ ElementClose,
+ TargetName,
+ TagName,
+ AttriName,
+ AttriValue,
+ Text,
+ CData,
+ TargetData,
+ Error,
+ EndOfString
+};
+
class CFX_XMLParser {
public:
+ static bool IsXMLNameChar(wchar_t ch, bool bFirstChar);
+
CFX_XMLParser(CFX_XMLNode* pParent,
const RetainPtr<CFX_SeekableStreamProxy>& pStream);
- ~CFX_XMLParser();
+ virtual ~CFX_XMLParser();
int32_t Parse();
+ protected:
+ FX_XmlSyntaxResult DoSyntaxParse();
+
+ WideString GetTagName() const {
+ return m_BlockBuffer.GetTextData(0, m_iTextDataLength);
+ }
+
+ WideString GetAttributeName() const {
+ return m_BlockBuffer.GetTextData(0, m_iTextDataLength);
+ }
+
+ WideString GetAttributeValue() const {
+ return m_BlockBuffer.GetTextData(0, m_iTextDataLength);
+ }
+
+ WideString GetTextData() const {
+ return m_BlockBuffer.GetTextData(0, m_iTextDataLength);
+ }
+
private:
- std::unique_ptr<CFX_XMLSyntaxParser> m_pParser;
+ enum class FDE_XmlSyntaxState {
+ Text,
+ Node,
+ Target,
+ Tag,
+ AttriName,
+ AttriEqualSign,
+ AttriQuotation,
+ AttriValue,
+ Entity,
+ EntityDecimal,
+ EntityHex,
+ CloseInstruction,
+ BreakElement,
+ CloseElement,
+ SkipDeclNode,
+ DeclCharData,
+ SkipComment,
+ SkipCommentOrDecl,
+ SkipCData,
+ TargetData
+ };
+
+ void ParseTextChar(wchar_t ch);
+
+ int32_t GetStatus() const;
+ FX_FILESIZE GetCurrentPos() const { return m_ParsedChars + m_Start; }
+ FX_FILESIZE GetCurrentBinaryPos() const;
+ int32_t GetCurrentNodeNumber() const { return m_iCurrentNodeNum; }
+ int32_t GetLastNodeNumber() const { return m_iLastNodeNum; }
+
+ WideString GetTargetName() const {
+ return m_BlockBuffer.GetTextData(0, m_iTextDataLength);
+ }
+
+ WideString GetTargetData() const {
+ return m_BlockBuffer.GetTextData(0, m_iTextDataLength);
+ }
+
CFX_XMLNode* m_pParent;
CFX_XMLNode* m_pChild;
std::stack<CFX_XMLNode*> m_NodeStack;
WideString m_ws1;
+
+ RetainPtr<CFX_SeekableStreamProxy> m_pStream;
+ size_t m_iXMLPlaneSize;
+ FX_FILESIZE m_iCurrentPos;
+ int32_t m_iCurrentNodeNum;
+ int32_t m_iLastNodeNum;
+ int32_t m_iParsedBytes;
+ FX_FILESIZE m_ParsedChars;
+ std::vector<wchar_t> m_Buffer;
+ size_t m_iBufferChars;
+ bool m_bEOS;
+ FX_FILESIZE m_Start; // Start position in m_Buffer
+ FX_FILESIZE m_End; // End position in m_Buffer
+ FX_XMLNODE m_CurNode;
+ std::stack<FX_XMLNODE> m_XMLNodeStack;
+ CFX_BlockBuffer m_BlockBuffer;
+ int32_t m_iAllocStep;
+ wchar_t* m_pCurrentBlock; // Pointer into CFX_BlockBuffer
+ int32_t m_iIndexInBlock;
+ int32_t m_iTextDataLength;
+ FX_XmlSyntaxResult m_syntaxParserResult;
+ FDE_XmlSyntaxState m_syntaxParserState;
+ wchar_t m_wQuotationMark;
+ int32_t m_iEntityStart;
+ std::stack<wchar_t> m_SkipStack;
+ wchar_t m_SkipChar;
};
#endif // CORE_FXCRT_XML_CFX_XMLPARSER_H_