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

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

Issue 2384883003: Remove CPDF_Object::Release() in favor of direct delete (Closed)
Patch Set: rebase 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
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_OBJECT_H_ 7 #ifndef CORE_FPDFAPI_PARSER_CPDF_OBJECT_H_
8 #define CORE_FPDFAPI_PARSER_CPDF_OBJECT_H_ 8 #define CORE_FPDFAPI_PARSER_CPDF_OBJECT_H_
9 9
10 #include <memory> 10 #include <memory>
(...skipping 20 matching lines...) Expand all
31 NUMBER, 31 NUMBER,
32 STRING, 32 STRING,
33 NAME, 33 NAME,
34 ARRAY, 34 ARRAY,
35 DICTIONARY, 35 DICTIONARY,
36 STREAM, 36 STREAM,
37 NULLOBJ, 37 NULLOBJ,
38 REFERENCE 38 REFERENCE
39 }; 39 };
40 40
41 virtual ~CPDF_Object();
42
41 virtual Type GetType() const = 0; 43 virtual Type GetType() const = 0;
42 uint32_t GetObjNum() const { return m_ObjNum; } 44 uint32_t GetObjNum() const { return m_ObjNum; }
43 uint32_t GetGenNum() const { return m_GenNum; } 45 uint32_t GetGenNum() const { return m_GenNum; }
44 bool IsInline() const { return m_ObjNum == 0; } 46 bool IsInline() const { return m_ObjNum == 0; }
45 47
46 // Create a deep copy of the object. 48 // Create a deep copy of the object.
47 virtual CPDF_Object* Clone() const = 0; 49 virtual CPDF_Object* Clone() const = 0;
48 // Create a deep copy of the object except any reference object be 50 // Create a deep copy of the object except any reference object be
49 // copied to the object it points to directly. 51 // copied to the object it points to directly.
50 virtual CPDF_Object* CloneDirectObject() const; 52 virtual CPDF_Object* CloneDirectObject() const;
51 virtual CPDF_Object* GetDirect() const; 53 virtual CPDF_Object* GetDirect() const;
52 54
53 void Release();
54
55 virtual CFX_ByteString GetString() const; 55 virtual CFX_ByteString GetString() const;
56 virtual CFX_WideString GetUnicodeText() const; 56 virtual CFX_WideString GetUnicodeText() const;
57 virtual FX_FLOAT GetNumber() const; 57 virtual FX_FLOAT GetNumber() const;
58 virtual int GetInteger() const; 58 virtual int GetInteger() const;
59 virtual CPDF_Dictionary* GetDict() const; 59 virtual CPDF_Dictionary* GetDict() const;
60 60
61 virtual void SetString(const CFX_ByteString& str); 61 virtual void SetString(const CFX_ByteString& str);
62 62
63 virtual bool IsArray() const; 63 virtual bool IsArray() const;
64 virtual bool IsBoolean() const; 64 virtual bool IsBoolean() const;
(...skipping 22 matching lines...) Expand all
87 virtual const CPDF_String* AsString() const; 87 virtual const CPDF_String* AsString() const;
88 88
89 protected: 89 protected:
90 friend class CPDF_Array; 90 friend class CPDF_Array;
91 friend class CPDF_Dictionary; 91 friend class CPDF_Dictionary;
92 friend class CPDF_Document; 92 friend class CPDF_Document;
93 friend class CPDF_IndirectObjectHolder; 93 friend class CPDF_IndirectObjectHolder;
94 friend class CPDF_Parser; 94 friend class CPDF_Parser;
95 friend class CPDF_Reference; 95 friend class CPDF_Reference;
96 friend class CPDF_Stream; 96 friend class CPDF_Stream;
97 friend struct std::default_delete<CPDF_Object>;
98 97
99 CPDF_Object() : m_ObjNum(0), m_GenNum(0) {} 98 CPDF_Object() : m_ObjNum(0), m_GenNum(0) {}
100 virtual ~CPDF_Object();
101 99
102 CPDF_Object* CloneObjectNonCyclic(bool bDirect) const; 100 CPDF_Object* CloneObjectNonCyclic(bool bDirect) const;
103 101
104 // Create a deep copy of the object with the option to either 102 // Create a deep copy of the object with the option to either
105 // copy a reference object or directly copy the object it refers to 103 // copy a reference object or directly copy the object it refers to
106 // when |bDirect| is true. 104 // when |bDirect| is true.
107 // Also check cyclic reference against |pVisited|, no copy if it is found. 105 // Also check cyclic reference against |pVisited|, no copy if it is found.
108 // Complex objects should implement their own CloneNonCyclic() 106 // Complex objects should implement their own CloneNonCyclic()
109 // function to properly check for possible loop. 107 // function to properly check for possible loop.
110 virtual CPDF_Object* CloneNonCyclic( 108 virtual CPDF_Object* CloneNonCyclic(
111 bool bDirect, 109 bool bDirect,
112 std::set<const CPDF_Object*>* pVisited) const; 110 std::set<const CPDF_Object*>* pVisited) const;
113 111
114 uint32_t m_ObjNum; 112 uint32_t m_ObjNum;
115 uint32_t m_GenNum; 113 uint32_t m_GenNum;
116 114
117 private: 115 private:
118 CPDF_Object(const CPDF_Object& src) {} 116 CPDF_Object(const CPDF_Object& src) {}
119 }; 117 };
120 118
121 using UniqueObject = std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>>;
122
123 #endif // CORE_FPDFAPI_PARSER_CPDF_OBJECT_H_ 119 #endif // CORE_FPDFAPI_PARSER_CPDF_OBJECT_H_
OLDNEW
« no previous file with comments | « core/fpdfapi/parser/cpdf_indirect_object_holder.cpp ('k') | core/fpdfapi/parser/cpdf_object.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698