blob: 9a138775446c7e56035993ce383e4280a0cb723f [file] [log] [blame]
Tom Sepezf0408902016-03-10 09:20:03 -08001// Copyright 2016 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
dsinclair488b7ad2016-10-04 11:55:50 -07007#ifndef CORE_FPDFAPI_PARSER_CFDF_DOCUMENT_H_
8#define CORE_FPDFAPI_PARSER_CFDF_DOCUMENT_H_
Tom Sepezf0408902016-03-10 09:20:03 -08009
tsepez05e01692016-11-28 17:30:09 -080010#include <memory>
11
dsinclair488b7ad2016-10-04 11:55:50 -070012#include "core/fpdfapi/parser/cpdf_indirect_object_holder.h"
13#include "core/fpdfapi/parser/cpdf_object.h"
Tom Sepezd0409af2017-05-25 15:53:57 -070014#include "core/fxcrt/cfx_unowned_ptr.h"
dsinclaira52ab742016-09-29 13:59:29 -070015#include "core/fxcrt/fx_basic.h"
Tom Sepezf0408902016-03-10 09:20:03 -080016
17class CPDF_Dictionary;
18
19class CFDF_Document : public CPDF_IndirectObjectHolder {
20 public:
tsepez05e01692016-11-28 17:30:09 -080021 static std::unique_ptr<CFDF_Document> CreateNewDoc();
tsepez833619b2016-12-07 09:21:17 -080022 static std::unique_ptr<CFDF_Document> ParseFile(
23 const CFX_RetainPtr<IFX_SeekableReadStream>& pFile);
24 static std::unique_ptr<CFDF_Document> ParseMemory(uint8_t* pData,
tsepez05e01692016-11-28 17:30:09 -080025 uint32_t size);
26
27 CFDF_Document();
dsinclaira61c01e2016-08-24 10:31:23 -070028 ~CFDF_Document() override;
Tom Sepezf0408902016-03-10 09:20:03 -080029
tsepez12f3e4a2016-11-02 15:17:29 -070030 bool WriteBuf(CFX_ByteTextBuf& buf) const;
Tom Sepezd0409af2017-05-25 15:53:57 -070031 CPDF_Dictionary* GetRoot() const { return m_pRootDict.Get(); }
Tom Sepezf0408902016-03-10 09:20:03 -080032
33 protected:
tsepez833619b2016-12-07 09:21:17 -080034 void ParseStream(const CFX_RetainPtr<IFX_SeekableReadStream>& pFile);
Tom Sepezf0408902016-03-10 09:20:03 -080035
Tom Sepezd0409af2017-05-25 15:53:57 -070036 CFX_UnownedPtr<CPDF_Dictionary> m_pRootDict;
tsepez833619b2016-12-07 09:21:17 -080037 CFX_RetainPtr<IFX_SeekableReadStream> m_pFile;
Tom Sepezf0408902016-03-10 09:20:03 -080038};
39
dsinclair488b7ad2016-10-04 11:55:50 -070040#endif // CORE_FPDFAPI_PARSER_CFDF_DOCUMENT_H_