| 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_FPDF_PARSER_INCLUDE_CPDF_INDIRECT_OBJECT_HOLDER_H_ | 7 #ifndef CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_INDIRECT_OBJECT_HOLDER_H_ |
| 8 #define CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_INDIRECT_OBJECT_HOLDER_H_ | 8 #define CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_INDIRECT_OBJECT_HOLDER_H_ |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | |
| 12 | 11 |
| 13 #include "core/fxcrt/include/fx_system.h" | 12 #include "core/fxcrt/include/fx_system.h" |
| 14 | 13 |
| 15 class CPDF_Object; | 14 class CPDF_Object; |
| 16 | 15 |
| 17 class CPDF_IndirectObjectHolder { | 16 class CPDF_IndirectObjectHolder { |
| 18 public: | 17 public: |
| 19 using const_iterator = | 18 using iterator = std::map<uint32_t, CPDF_Object*>::iterator; |
| 20 std::map<uint32_t, std::unique_ptr<CPDF_Object>>::const_iterator; | 19 using const_iterator = std::map<uint32_t, CPDF_Object*>::const_iterator; |
| 21 | 20 |
| 22 CPDF_IndirectObjectHolder(); | 21 CPDF_IndirectObjectHolder(); |
| 23 virtual ~CPDF_IndirectObjectHolder(); | 22 virtual ~CPDF_IndirectObjectHolder(); |
| 24 | 23 |
| 25 CPDF_Object* GetIndirectObject(uint32_t objnum) const; | 24 CPDF_Object* GetIndirectObject(uint32_t objnum) const; |
| 26 CPDF_Object* GetOrParseIndirectObject(uint32_t objnum); | 25 CPDF_Object* GetOrParseIndirectObject(uint32_t objnum); |
| 27 void ReleaseIndirectObject(uint32_t objnum); | 26 void ReleaseIndirectObject(uint32_t objnum); |
| 28 | 27 |
| 29 // Take ownership of |pObj|. | 28 // Take ownership of |pObj|. |
| 30 uint32_t AddIndirectObject(CPDF_Object* pObj); | 29 uint32_t AddIndirectObject(CPDF_Object* pObj); |
| 31 bool ReplaceIndirectObjectIfHigherGeneration(uint32_t objnum, | 30 bool ReplaceIndirectObjectIfHigherGeneration(uint32_t objnum, |
| 32 CPDF_Object* pObj); | 31 CPDF_Object* pObj); |
| 33 | 32 |
| 34 uint32_t GetLastObjNum() const { return m_LastObjNum; } | 33 uint32_t GetLastObjNum() const { return m_LastObjNum; } |
| 35 void SetLastObjNum(uint32_t objnum) { m_LastObjNum = objnum; } | 34 void SetLastObjNum(uint32_t objnum) { m_LastObjNum = objnum; } |
| 36 | 35 |
| 36 iterator begin() { return m_IndirectObjs.begin(); } |
| 37 const_iterator begin() const { return m_IndirectObjs.begin(); } | 37 const_iterator begin() const { return m_IndirectObjs.begin(); } |
| 38 iterator end() { return m_IndirectObjs.end(); } |
| 38 const_iterator end() const { return m_IndirectObjs.end(); } | 39 const_iterator end() const { return m_IndirectObjs.end(); } |
| 39 | 40 |
| 40 protected: | 41 protected: |
| 41 virtual CPDF_Object* ParseIndirectObject(uint32_t objnum); | 42 virtual CPDF_Object* ParseIndirectObject(uint32_t objnum); |
| 42 | 43 |
| 43 private: | 44 private: |
| 44 uint32_t m_LastObjNum; | 45 uint32_t m_LastObjNum; |
| 45 std::map<uint32_t, std::unique_ptr<CPDF_Object>> m_IndirectObjs; | 46 std::map<uint32_t, CPDF_Object*> m_IndirectObjs; |
| 46 }; | 47 }; |
| 47 | 48 |
| 48 #endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_INDIRECT_OBJECT_HOLDER_H_ | 49 #endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_INDIRECT_OBJECT_HOLDER_H_ |
| OLD | NEW |