OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef CORE_FPDFAPI_PARSER_CPDF_INDIRECT_OBJECT_HOLDER_H_ | 7 #ifndef CORE_FPDFAPI_PARSER_CPDF_INDIRECT_OBJECT_HOLDER_H_ |
8 #define CORE_FPDFAPI_PARSER_CPDF_INDIRECT_OBJECT_HOLDER_H_ | 8 #define CORE_FPDFAPI_PARSER_CPDF_INDIRECT_OBJECT_HOLDER_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "core/fpdfapi/parser/cpdf_object.h" | |
14 #include "core/fxcrt/cfx_string_pool_template.h" | |
15 #include "core/fxcrt/cfx_weak_ptr.h" | |
16 #include "core/fxcrt/fx_system.h" | 13 #include "core/fxcrt/fx_system.h" |
17 | 14 |
18 class CPDF_Array; | 15 class CPDF_Object; |
19 class CPDF_Dictionary; | |
20 class CPDF_Stream; | |
21 | 16 |
22 class CPDF_IndirectObjectHolder { | 17 class CPDF_IndirectObjectHolder { |
23 public: | 18 public: |
24 using const_iterator = | 19 using const_iterator = |
25 std::map<uint32_t, std::unique_ptr<CPDF_Object>>::const_iterator; | 20 std::map<uint32_t, std::unique_ptr<CPDF_Object>>::const_iterator; |
26 | 21 |
27 CPDF_IndirectObjectHolder(); | 22 CPDF_IndirectObjectHolder(); |
28 virtual ~CPDF_IndirectObjectHolder(); | 23 virtual ~CPDF_IndirectObjectHolder(); |
29 | 24 |
30 CPDF_Object* GetIndirectObject(uint32_t objnum) const; | 25 CPDF_Object* GetIndirectObject(uint32_t objnum) const; |
31 CPDF_Object* GetOrParseIndirectObject(uint32_t objnum); | 26 CPDF_Object* GetOrParseIndirectObject(uint32_t objnum); |
32 void DeleteIndirectObject(uint32_t objnum); | 27 void ReleaseIndirectObject(uint32_t objnum); |
33 | 28 |
34 // Take ownership of |pObj|, returns unowned pointer to it. | 29 // Take ownership of |pObj|. |
35 CPDF_Object* AddIndirectObject(UniqueObject pObj); | 30 uint32_t AddIndirectObject(CPDF_Object* pObj); |
36 | |
37 // Adds and owns a new object, returns unowned pointer to it. | |
38 CPDF_Array* AddIndirectArray(); | |
39 CPDF_Dictionary* AddIndirectDictionary(); | |
40 CPDF_Dictionary* AddIndirectDictionary( | |
41 const CFX_WeakPtr<CFX_ByteStringPool>& pPool); | |
42 CPDF_Stream* AddIndirectStream(); | |
43 CPDF_Stream* AddIndirectStream(uint8_t* pData, | |
44 uint32_t size, | |
45 CPDF_Dictionary* pDict); | |
46 | |
47 bool ReplaceIndirectObjectIfHigherGeneration(uint32_t objnum, | 31 bool ReplaceIndirectObjectIfHigherGeneration(uint32_t objnum, |
48 UniqueObject pObj); | 32 CPDF_Object* pObj); |
49 | 33 |
50 uint32_t GetLastObjNum() const { return m_LastObjNum; } | 34 uint32_t GetLastObjNum() const { return m_LastObjNum; } |
51 void SetLastObjNum(uint32_t objnum) { m_LastObjNum = objnum; } | 35 void SetLastObjNum(uint32_t objnum) { m_LastObjNum = objnum; } |
52 | 36 |
53 const_iterator begin() const { return m_IndirectObjs.begin(); } | 37 const_iterator begin() const { return m_IndirectObjs.begin(); } |
54 const_iterator end() const { return m_IndirectObjs.end(); } | 38 const_iterator end() const { return m_IndirectObjs.end(); } |
55 | 39 |
56 protected: | 40 protected: |
57 virtual CPDF_Object* ParseIndirectObject(uint32_t objnum); | 41 virtual CPDF_Object* ParseIndirectObject(uint32_t objnum); |
58 | 42 |
59 private: | 43 private: |
60 uint32_t m_LastObjNum; | 44 uint32_t m_LastObjNum; |
61 | |
62 // Ordinary deleter, not Release(). | |
63 std::map<uint32_t, std::unique_ptr<CPDF_Object>> m_IndirectObjs; | 45 std::map<uint32_t, std::unique_ptr<CPDF_Object>> m_IndirectObjs; |
64 }; | 46 }; |
65 | 47 |
66 #endif // CORE_FPDFAPI_PARSER_CPDF_INDIRECT_OBJECT_HOLDER_H_ | 48 #endif // CORE_FPDFAPI_PARSER_CPDF_INDIRECT_OBJECT_HOLDER_H_ |
OLD | NEW |