• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef CORE_FXCRT_XML_INT_H_
8 #define CORE_FXCRT_XML_INT_H_
9 
10 #include <algorithm>
11 #include <memory>
12 
13 #include "core/fxcrt/fx_stream.h"
14 
15 class CFX_UTF8Decoder;
16 class CXML_Element;
17 
18 class CXML_Parser {
19  public:
20   CXML_Parser();
21   ~CXML_Parser();
22 
23   bool Init(const uint8_t* pBuffer, size_t size);
24   bool ReadNextBlock();
25   bool IsEOF();
26   bool HaveAvailData();
27   void SkipWhiteSpaces();
28   void GetName(CFX_ByteString* space, CFX_ByteString* name);
29   void GetAttrValue(CFX_WideString& value);
30   uint32_t GetCharRef();
31   void GetTagName(bool bStartTag,
32                   bool* bEndTag,
33                   CFX_ByteString* space,
34                   CFX_ByteString* name);
35   void SkipLiterals(const CFX_ByteStringC& str);
36   std::unique_ptr<CXML_Element> ParseElement(CXML_Element* pParent,
37                                              bool bStartTag);
38   void InsertContentSegment(bool bCDATA,
39                             const CFX_WideStringC& content,
40                             CXML_Element* pElement);
41   void InsertCDATASegment(CFX_UTF8Decoder& decoder, CXML_Element* pElement);
42 
43   CFX_RetainPtr<IFX_BufferedReadStream> m_pDataAcc;
44   FX_FILESIZE m_nOffset;
45   const uint8_t* m_pBuffer;
46   size_t m_dwBufferSize;
47   FX_FILESIZE m_nBufferOffset;
48   size_t m_dwIndex;
49 };
50 
51 void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName,
52                                CFX_ByteStringC& bsSpace,
53                                CFX_ByteStringC& bsName);
54 
55 #endif  // CORE_FXCRT_XML_INT_H_
56