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_ARRAY_H_ | 7 #ifndef CORE_FPDFAPI_PARSER_CPDF_ARRAY_H_ |
8 #define CORE_FPDFAPI_PARSER_CPDF_ARRAY_H_ | 8 #define CORE_FPDFAPI_PARSER_CPDF_ARRAY_H_ |
9 | 9 |
10 #include <set> | 10 #include <set> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "core/fpdfapi/parser/cpdf_indirect_object_holder.h" | 13 #include "core/fpdfapi/parser/cpdf_indirect_object_holder.h" |
14 #include "core/fpdfapi/parser/cpdf_object.h" | 14 #include "core/fpdfapi/parser/cpdf_object.h" |
15 #include "core/fxcrt/fx_basic.h" | 15 #include "core/fxcrt/fx_basic.h" |
16 #include "core/fxcrt/fx_coordinates.h" | 16 #include "core/fxcrt/fx_coordinates.h" |
17 | 17 |
18 class CPDF_Array : public CPDF_Object { | 18 class CPDF_Array : public CPDF_Object { |
19 public: | 19 public: |
20 using iterator = std::vector<UniqueObject>::iterator; | 20 using iterator = std::vector<CPDF_Object*>::iterator; |
21 using const_iterator = std::vector<UniqueObject>::const_iterator; | 21 using const_iterator = std::vector<CPDF_Object*>::const_iterator; |
22 | 22 |
23 CPDF_Array(); | 23 CPDF_Array(); |
24 | 24 |
25 // CPDF_Object. | 25 // CPDF_Object. |
26 Type GetType() const override; | 26 Type GetType() const override; |
27 CPDF_Object* Clone() const override; | 27 CPDF_Object* Clone() const override; |
28 bool IsArray() const override; | 28 bool IsArray() const override; |
29 CPDF_Array* AsArray() override; | 29 CPDF_Array* AsArray() override; |
30 const CPDF_Array* AsArray() const override; | 30 const CPDF_Array* AsArray() const override; |
31 | 31 |
(...skipping 28 matching lines...) Expand all Loading... |
60 const_iterator begin() const { return m_Objects.begin(); } | 60 const_iterator begin() const { return m_Objects.begin(); } |
61 const_iterator end() const { return m_Objects.end(); } | 61 const_iterator end() const { return m_Objects.end(); } |
62 | 62 |
63 protected: | 63 protected: |
64 ~CPDF_Array() override; | 64 ~CPDF_Array() override; |
65 | 65 |
66 CPDF_Object* CloneNonCyclic( | 66 CPDF_Object* CloneNonCyclic( |
67 bool bDirect, | 67 bool bDirect, |
68 std::set<const CPDF_Object*>* pVisited) const override; | 68 std::set<const CPDF_Object*>* pVisited) const override; |
69 | 69 |
70 std::vector<UniqueObject> m_Objects; | 70 std::vector<CPDF_Object*> m_Objects; |
71 }; | 71 }; |
72 | |
73 using UniqueArray = std::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Object>>; | 72 using UniqueArray = std::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Object>>; |
74 | 73 |
75 inline CPDF_Array* ToArray(CPDF_Object* obj) { | 74 inline CPDF_Array* ToArray(CPDF_Object* obj) { |
76 return obj ? obj->AsArray() : nullptr; | 75 return obj ? obj->AsArray() : nullptr; |
77 } | 76 } |
78 | 77 |
79 inline const CPDF_Array* ToArray(const CPDF_Object* obj) { | 78 inline const CPDF_Array* ToArray(const CPDF_Object* obj) { |
80 return obj ? obj->AsArray() : nullptr; | 79 return obj ? obj->AsArray() : nullptr; |
81 } | 80 } |
82 | 81 |
83 inline UniqueArray ToArray(UniqueObject obj) { | 82 inline UniqueArray ToArray(UniqueObject obj) { |
84 CPDF_Array* pArray = ToArray(obj.get()); | 83 CPDF_Array* pArray = ToArray(obj.get()); |
85 if (!pArray) | 84 if (!pArray) |
86 return nullptr; | 85 return nullptr; |
87 obj.release(); | 86 obj.release(); |
88 return UniqueArray(pArray); | 87 return UniqueArray(pArray); |
89 } | 88 } |
90 | 89 |
91 #endif // CORE_FPDFAPI_PARSER_CPDF_ARRAY_H_ | 90 #endif // CORE_FPDFAPI_PARSER_CPDF_ARRAY_H_ |
OLD | NEW |