| 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_DICTIONARY_H_ | 7 #ifndef CORE_FPDFAPI_PARSER_CPDF_DICTIONARY_H_ |
| 8 #define CORE_FPDFAPI_PARSER_CPDF_DICTIONARY_H_ | 8 #define CORE_FPDFAPI_PARSER_CPDF_DICTIONARY_H_ |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <set> | 11 #include <set> |
| 12 | 12 |
| 13 #include "core/fpdfapi/parser/cpdf_object.h" | 13 #include "core/fpdfapi/parser/cpdf_object.h" |
| 14 #include "core/fxcrt/cfx_string_pool_template.h" | 14 #include "core/fxcrt/cfx_string_pool_template.h" |
| 15 #include "core/fxcrt/cfx_weak_ptr.h" | 15 #include "core/fxcrt/cfx_weak_ptr.h" |
| 16 #include "core/fxcrt/fx_coordinates.h" | 16 #include "core/fxcrt/fx_coordinates.h" |
| 17 #include "core/fxcrt/fx_string.h" | 17 #include "core/fxcrt/fx_string.h" |
| 18 #include "third_party/base/ptr_util.h" | 18 #include "third_party/base/ptr_util.h" |
| 19 | 19 |
| 20 class CPDF_IndirectObjectHolder; | 20 class CPDF_IndirectObjectHolder; |
| 21 | 21 |
| 22 class CPDF_Dictionary : public CPDF_Object { | 22 class CPDF_Dictionary : public CPDF_Object { |
| 23 public: | 23 public: |
| 24 using iterator = std::map<CFX_ByteString, UniqueObject>::iterator; | 24 using iterator = std::map<CFX_ByteString, CPDF_Object*>::iterator; |
| 25 using const_iterator = std::map<CFX_ByteString, UniqueObject>::const_iterator; | 25 using const_iterator = std::map<CFX_ByteString, CPDF_Object*>::const_iterator; |
| 26 | 26 |
| 27 CPDF_Dictionary(); | 27 CPDF_Dictionary(); |
| 28 explicit CPDF_Dictionary(const CFX_WeakPtr<CFX_ByteStringPool>& pPool); | 28 explicit CPDF_Dictionary(const CFX_WeakPtr<CFX_ByteStringPool>& pPool); |
| 29 | 29 |
| 30 // CPDF_Object. | 30 // CPDF_Object. |
| 31 Type GetType() const override; | 31 Type GetType() const override; |
| 32 CPDF_Object* Clone() const override; | 32 CPDF_Object* Clone() const override; |
| 33 CPDF_Dictionary* GetDict() const override; | 33 CPDF_Dictionary* GetDict() const override; |
| 34 bool IsDictionary() const override; | 34 bool IsDictionary() const override; |
| 35 CPDF_Dictionary* AsDictionary() override; | 35 CPDF_Dictionary* AsDictionary() override; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 protected: | 90 protected: |
| 91 ~CPDF_Dictionary() override; | 91 ~CPDF_Dictionary() override; |
| 92 | 92 |
| 93 CFX_ByteString MaybeIntern(const CFX_ByteString& str); | 93 CFX_ByteString MaybeIntern(const CFX_ByteString& str); |
| 94 CPDF_Object* CloneNonCyclic( | 94 CPDF_Object* CloneNonCyclic( |
| 95 bool bDirect, | 95 bool bDirect, |
| 96 std::set<const CPDF_Object*>* visited) const override; | 96 std::set<const CPDF_Object*>* visited) const override; |
| 97 | 97 |
| 98 CFX_WeakPtr<CFX_ByteStringPool> m_pPool; | 98 CFX_WeakPtr<CFX_ByteStringPool> m_pPool; |
| 99 std::map<CFX_ByteString, UniqueObject> m_Map; | 99 std::map<CFX_ByteString, CPDF_Object*> m_Map; |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 using UniqueDictionary = | 102 using UniqueDictionary = |
| 103 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Object>>; | 103 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Object>>; |
| 104 | 104 |
| 105 inline CPDF_Dictionary* ToDictionary(CPDF_Object* obj) { | 105 inline CPDF_Dictionary* ToDictionary(CPDF_Object* obj) { |
| 106 return obj ? obj->AsDictionary() : nullptr; | 106 return obj ? obj->AsDictionary() : nullptr; |
| 107 } | 107 } |
| 108 | 108 |
| 109 inline const CPDF_Dictionary* ToDictionary(const CPDF_Object* obj) { | 109 inline const CPDF_Dictionary* ToDictionary(const CPDF_Object* obj) { |
| 110 return obj ? obj->AsDictionary() : nullptr; | 110 return obj ? obj->AsDictionary() : nullptr; |
| 111 } | 111 } |
| 112 | 112 |
| 113 inline UniqueDictionary ToDictionary(UniqueObject obj) { | 113 inline UniqueDictionary ToDictionary(UniqueObject obj) { |
| 114 CPDF_Dictionary* pDict = ToDictionary(obj.get()); | 114 CPDF_Dictionary* pDict = ToDictionary(obj.get()); |
| 115 if (!pDict) | 115 if (!pDict) |
| 116 return nullptr; | 116 return nullptr; |
| 117 obj.release(); | 117 obj.release(); |
| 118 return UniqueDictionary(pDict); | 118 return UniqueDictionary(pDict); |
| 119 } | 119 } |
| 120 | 120 |
| 121 #endif // CORE_FPDFAPI_PARSER_CPDF_DICTIONARY_H_ | 121 #endif // CORE_FPDFAPI_PARSER_CPDF_DICTIONARY_H_ |
| OLD | NEW |