xref: /aosp_15_r20/external/pdfium/core/fpdfapi/parser/cfdf_document.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2016 The PDFium Authors
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_FPDFAPI_PARSER_CFDF_DOCUMENT_H_
8 #define CORE_FPDFAPI_PARSER_CFDF_DOCUMENT_H_
9 
10 #include <memory>
11 
12 #include "core/fpdfapi/parser/cpdf_indirect_object_holder.h"
13 #include "core/fxcrt/retain_ptr.h"
14 #include "third_party/base/containers/span.h"
15 
16 class CPDF_Dictionary;
17 class IFX_SeekableReadStream;
18 
19 class CFDF_Document final : public CPDF_IndirectObjectHolder {
20  public:
21   static std::unique_ptr<CFDF_Document> CreateNewDoc();
22   static std::unique_ptr<CFDF_Document> ParseMemory(
23       pdfium::span<const uint8_t> span);
24 
25   CFDF_Document();
26   ~CFDF_Document() override;
27 
28   ByteString WriteToString() const;
GetRoot()29   const CPDF_Dictionary* GetRoot() const { return m_pRootDict.Get(); }
GetMutableRoot()30   RetainPtr<CPDF_Dictionary> GetMutableRoot() const { return m_pRootDict; }
31 
32  private:
33   void ParseStream(RetainPtr<IFX_SeekableReadStream> pFile);
34 
35   RetainPtr<CPDF_Dictionary> m_pRootDict;
36   RetainPtr<IFX_SeekableReadStream> m_pFile;
37 };
38 
39 #endif  // CORE_FPDFAPI_PARSER_CFDF_DOCUMENT_H_
40