Split the FDE XML file into indiviual class files.

This Cl splits the fde_xml_int file apart into individual class files.
Includes are fixed as needed. fde_xml.h is also removed and the needed
defines moved to more appropiate places.

Change-Id: I29774dabc4d0fb2d5092fcbbe7853f03401b6ec7
Reviewed-on: https://pdfium-review.googlesource.com/3616
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fde/xml/cfde_xmlsyntaxparser.h b/xfa/fde/xml/cfde_xmlsyntaxparser.h
new file mode 100644
index 0000000..9e768d0
--- /dev/null
+++ b/xfa/fde/xml/cfde_xmlsyntaxparser.h
@@ -0,0 +1,128 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FDE_XML_CFDE_XMLSYNTAXPARSER_H_
+#define XFA_FDE_XML_CFDE_XMLSYNTAXPARSER_H_
+
+#include <stack>
+
+#include "core/fxcrt/cfx_blockbuffer.h"
+#include "core/fxcrt/cfx_retain_ptr.h"
+#include "core/fxcrt/fx_string.h"
+#include "xfa/fde/xml/cfde_xmlnode.h"
+#include "xfa/fgas/crt/ifgas_stream.h"
+
+enum class FDE_XmlSyntaxResult {
+  None,
+  InstructionOpen,
+  InstructionClose,
+  ElementOpen,
+  ElementBreak,
+  ElementClose,
+  TargetName,
+  TagName,
+  AttriName,
+  AttriValue,
+  Text,
+  CData,
+  TargetData,
+  Error,
+  EndOfString
+};
+
+class CFDE_XMLSyntaxParser {
+ public:
+  CFDE_XMLSyntaxParser();
+  ~CFDE_XMLSyntaxParser();
+
+  void Init(const CFX_RetainPtr<IFGAS_Stream>& pStream,
+            int32_t iXMLPlaneSize,
+            int32_t iTextDataSize = 256);
+
+  FDE_XmlSyntaxResult DoSyntaxParse();
+
+  int32_t GetStatus() const;
+  int32_t GetCurrentPos() const {
+    return m_iParsedChars + (m_pStart - m_pBuffer);
+  }
+  FX_FILESIZE GetCurrentBinaryPos() const;
+  int32_t GetCurrentNodeNumber() const { return m_iCurrentNodeNum; }
+  int32_t GetLastNodeNumber() const { return m_iLastNodeNum; }
+
+  void GetTargetName(CFX_WideString& wsTarget) const {
+    m_BlockBuffer.GetTextData(wsTarget, 0, m_iTextDataLength);
+  }
+  void GetTagName(CFX_WideString& wsTag) const {
+    m_BlockBuffer.GetTextData(wsTag, 0, m_iTextDataLength);
+  }
+  void GetAttributeName(CFX_WideString& wsAttriName) const {
+    m_BlockBuffer.GetTextData(wsAttriName, 0, m_iTextDataLength);
+  }
+  void GetAttributeValue(CFX_WideString& wsAttriValue) const {
+    m_BlockBuffer.GetTextData(wsAttriValue, 0, m_iTextDataLength);
+  }
+  void GetTextData(CFX_WideString& wsText) const {
+    m_BlockBuffer.GetTextData(wsText, 0, m_iTextDataLength);
+  }
+  void GetTargetData(CFX_WideString& wsData) const {
+    m_BlockBuffer.GetTextData(wsData, 0, m_iTextDataLength);
+  }
+
+ protected:
+  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);
+
+  CFX_RetainPtr<IFGAS_Stream> m_pStream;
+  int32_t m_iXMLPlaneSize;
+  int32_t m_iCurrentPos;
+  int32_t m_iCurrentNodeNum;
+  int32_t m_iLastNodeNum;
+  int32_t m_iParsedChars;
+  int32_t m_iParsedBytes;
+  wchar_t* m_pBuffer;
+  int32_t m_iBufferChars;
+  bool m_bEOS;
+  wchar_t* m_pStart;
+  wchar_t* m_pEnd;
+  FDE_XMLNODE m_CurNode;
+  std::stack<FDE_XMLNODE> m_XMLNodeStack;
+  CFX_BlockBuffer m_BlockBuffer;
+  int32_t m_iAllocStep;
+  int32_t& m_iDataLength;
+  wchar_t* m_pCurrentBlock;
+  int32_t m_iIndexInBlock;
+  int32_t m_iTextDataLength;
+  FDE_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  // XFA_FDE_XML_CFDE_XMLSYNTAXPARSER_H_