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_DICTIONARY_H_ | 7 #ifndef CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DICTIONARY_H_ |
8 #define CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DICTIONARY_H_ | 8 #define CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DICTIONARY_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <set> | 11 #include <set> |
12 | 12 |
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h" | 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h" |
| 14 #include "core/fxcrt/include/cfx_string_pool_template.h" |
| 15 #include "core/fxcrt/include/cfx_weak_ptr.h" |
14 #include "core/fxcrt/include/fx_coordinates.h" | 16 #include "core/fxcrt/include/fx_coordinates.h" |
15 #include "core/fxcrt/include/fx_string.h" | 17 #include "core/fxcrt/include/fx_string.h" |
16 | 18 |
17 class CPDF_IndirectObjectHolder; | 19 class CPDF_IndirectObjectHolder; |
18 | 20 |
19 class CPDF_Dictionary : public CPDF_Object { | 21 class CPDF_Dictionary : public CPDF_Object { |
20 public: | 22 public: |
21 using iterator = std::map<CFX_ByteString, CPDF_Object*>::iterator; | 23 using iterator = std::map<CFX_ByteString, CPDF_Object*>::iterator; |
22 using const_iterator = std::map<CFX_ByteString, CPDF_Object*>::const_iterator; | 24 using const_iterator = std::map<CFX_ByteString, CPDF_Object*>::const_iterator; |
23 | 25 |
24 CPDF_Dictionary(); | 26 explicit CPDF_Dictionary(const CFX_WeakPtr<CFX_ByteStringPool>& pPool); |
25 | 27 |
26 // CPDF_Object. | 28 // CPDF_Object. |
27 Type GetType() const override; | 29 Type GetType() const override; |
28 CPDF_Object* Clone() const override; | 30 CPDF_Object* Clone() const override; |
29 CPDF_Dictionary* GetDict() const override; | 31 CPDF_Dictionary* GetDict() const override; |
30 bool IsDictionary() const override; | 32 bool IsDictionary() const override; |
31 CPDF_Dictionary* AsDictionary() override; | 33 CPDF_Dictionary* AsDictionary() override; |
32 const CPDF_Dictionary* AsDictionary() const override; | 34 const CPDF_Dictionary* AsDictionary() const override; |
33 | 35 |
34 size_t GetCount() const { return m_Map.size(); } | 36 size_t GetCount() const { return m_Map.size(); } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 void RemoveFor(const CFX_ByteString& key); | 73 void RemoveFor(const CFX_ByteString& key); |
72 | 74 |
73 // Invalidates iterators for the element with the key |oldkey|. | 75 // Invalidates iterators for the element with the key |oldkey|. |
74 void ReplaceKey(const CFX_ByteString& oldkey, const CFX_ByteString& newkey); | 76 void ReplaceKey(const CFX_ByteString& oldkey, const CFX_ByteString& newkey); |
75 | 77 |
76 iterator begin() { return m_Map.begin(); } | 78 iterator begin() { return m_Map.begin(); } |
77 iterator end() { return m_Map.end(); } | 79 iterator end() { return m_Map.end(); } |
78 const_iterator begin() const { return m_Map.begin(); } | 80 const_iterator begin() const { return m_Map.begin(); } |
79 const_iterator end() const { return m_Map.end(); } | 81 const_iterator end() const { return m_Map.end(); } |
80 | 82 |
| 83 CFX_WeakPtr<CFX_ByteStringPool> GetByteStringPool() const { return m_pPool; } |
| 84 |
81 protected: | 85 protected: |
82 ~CPDF_Dictionary() override; | 86 ~CPDF_Dictionary() override; |
83 | 87 |
| 88 CFX_ByteString MaybeIntern(const CFX_ByteString& str); |
84 CPDF_Object* CloneNonCyclic( | 89 CPDF_Object* CloneNonCyclic( |
85 bool bDirect, | 90 bool bDirect, |
86 std::set<const CPDF_Object*>* visited) const override; | 91 std::set<const CPDF_Object*>* visited) const override; |
87 | 92 |
| 93 CFX_WeakPtr<CFX_ByteStringPool> m_pPool; |
88 std::map<CFX_ByteString, CPDF_Object*> m_Map; | 94 std::map<CFX_ByteString, CPDF_Object*> m_Map; |
89 }; | 95 }; |
90 | 96 |
91 #endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DICTIONARY_H_ | 97 #endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DICTIONARY_H_ |
OLD | NEW |