Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: core/fpdfapi/parser/cpdf_dictionary.h

Issue 2484033002: Return unique_ptr from CPDF_Object::Clone(). (Closed)
Patch Set: std::move() it Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfapi/parser/cpdf_boolean.cpp ('k') | core/fpdfapi/parser/cpdf_dictionary.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
(...skipping 10 matching lines...) Expand all
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, CPDF_Object*>::iterator; 24 using iterator = std::map<CFX_ByteString, CPDF_Object*>::iterator;
25 using const_iterator = std::map<CFX_ByteString, CPDF_Object*>::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 ~CPDF_Dictionary() override; 29 ~CPDF_Dictionary() override;
30 30
31 // CPDF_Object. 31 // CPDF_Object:
32 Type GetType() const override; 32 Type GetType() const override;
33 CPDF_Object* Clone() const override; 33 std::unique_ptr<CPDF_Object> Clone() const override;
34 CPDF_Dictionary* GetDict() const override; 34 CPDF_Dictionary* GetDict() const override;
35 bool IsDictionary() const override; 35 bool IsDictionary() const override;
36 CPDF_Dictionary* AsDictionary() override; 36 CPDF_Dictionary* AsDictionary() override;
37 const CPDF_Dictionary* AsDictionary() const override; 37 const CPDF_Dictionary* AsDictionary() const override;
38 38
39 size_t GetCount() const { return m_Map.size(); } 39 size_t GetCount() const { return m_Map.size(); }
40 CPDF_Object* GetObjectFor(const CFX_ByteString& key) const; 40 CPDF_Object* GetObjectFor(const CFX_ByteString& key) const;
41 CPDF_Object* GetDirectObjectFor(const CFX_ByteString& key) const; 41 CPDF_Object* GetDirectObjectFor(const CFX_ByteString& key) const;
42 CFX_ByteString GetStringFor(const CFX_ByteString& key) const; 42 CFX_ByteString GetStringFor(const CFX_ByteString& key) const;
43 CFX_ByteString GetStringFor(const CFX_ByteString& key, 43 CFX_ByteString GetStringFor(const CFX_ByteString& key,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 iterator begin() { return m_Map.begin(); } 84 iterator begin() { return m_Map.begin(); }
85 iterator end() { return m_Map.end(); } 85 iterator end() { return m_Map.end(); }
86 const_iterator begin() const { return m_Map.begin(); } 86 const_iterator begin() const { return m_Map.begin(); }
87 const_iterator end() const { return m_Map.end(); } 87 const_iterator end() const { return m_Map.end(); }
88 88
89 CFX_WeakPtr<CFX_ByteStringPool> GetByteStringPool() const { return m_pPool; } 89 CFX_WeakPtr<CFX_ByteStringPool> GetByteStringPool() const { return m_pPool; }
90 90
91 protected: 91 protected:
92 CFX_ByteString MaybeIntern(const CFX_ByteString& str); 92 CFX_ByteString MaybeIntern(const CFX_ByteString& str);
93 CPDF_Object* CloneNonCyclic( 93 std::unique_ptr<CPDF_Object> CloneNonCyclic(
94 bool bDirect, 94 bool bDirect,
95 std::set<const CPDF_Object*>* visited) const override; 95 std::set<const CPDF_Object*>* visited) const override;
96 96
97 CFX_WeakPtr<CFX_ByteStringPool> m_pPool; 97 CFX_WeakPtr<CFX_ByteStringPool> m_pPool;
98 std::map<CFX_ByteString, CPDF_Object*> m_Map; 98 std::map<CFX_ByteString, CPDF_Object*> m_Map;
99 }; 99 };
100 100
101 inline CPDF_Dictionary* ToDictionary(CPDF_Object* obj) { 101 inline CPDF_Dictionary* ToDictionary(CPDF_Object* obj) {
102 return obj ? obj->AsDictionary() : nullptr; 102 return obj ? obj->AsDictionary() : nullptr;
103 } 103 }
104 104
105 inline const CPDF_Dictionary* ToDictionary(const CPDF_Object* obj) { 105 inline const CPDF_Dictionary* ToDictionary(const CPDF_Object* obj) {
106 return obj ? obj->AsDictionary() : nullptr; 106 return obj ? obj->AsDictionary() : nullptr;
107 } 107 }
108 108
109 inline std::unique_ptr<CPDF_Dictionary> ToDictionary( 109 inline std::unique_ptr<CPDF_Dictionary> ToDictionary(
110 std::unique_ptr<CPDF_Object> obj) { 110 std::unique_ptr<CPDF_Object> obj) {
111 CPDF_Dictionary* pDict = ToDictionary(obj.get()); 111 CPDF_Dictionary* pDict = ToDictionary(obj.get());
112 if (!pDict) 112 if (!pDict)
113 return nullptr; 113 return nullptr;
114 obj.release(); 114 obj.release();
115 return std::unique_ptr<CPDF_Dictionary>(pDict); 115 return std::unique_ptr<CPDF_Dictionary>(pDict);
116 } 116 }
117 117
118 #endif // CORE_FPDFAPI_PARSER_CPDF_DICTIONARY_H_ 118 #endif // CORE_FPDFAPI_PARSER_CPDF_DICTIONARY_H_
OLDNEW
« no previous file with comments | « core/fpdfapi/parser/cpdf_boolean.cpp ('k') | core/fpdfapi/parser/cpdf_dictionary.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698