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<CPDF_Object*>::iterator; | 20 using iterator = std::vector<CPDF_Object*>::iterator; |
21 using const_iterator = std::vector<CPDF_Object*>::const_iterator; | 21 using const_iterator = std::vector<CPDF_Object*>::const_iterator; |
22 | 22 |
23 CPDF_Array(); | 23 CPDF_Array(); |
24 ~CPDF_Array() override; | 24 ~CPDF_Array() override; |
25 | 25 |
26 // CPDF_Object. | 26 // CPDF_Object: |
27 Type GetType() const override; | 27 Type GetType() const override; |
28 CPDF_Object* Clone() const override; | 28 std::unique_ptr<CPDF_Object> Clone() const override; |
29 bool IsArray() const override; | 29 bool IsArray() const override; |
30 CPDF_Array* AsArray() override; | 30 CPDF_Array* AsArray() override; |
31 const CPDF_Array* AsArray() const override; | 31 const CPDF_Array* AsArray() const override; |
32 | 32 |
33 bool IsEmpty() const { return m_Objects.empty(); } | 33 bool IsEmpty() const { return m_Objects.empty(); } |
34 size_t GetCount() const { return m_Objects.size(); } | 34 size_t GetCount() const { return m_Objects.size(); } |
35 CPDF_Object* GetObjectAt(size_t index) const; | 35 CPDF_Object* GetObjectAt(size_t index) const; |
36 CPDF_Object* GetDirectObjectAt(size_t index) const; | 36 CPDF_Object* GetDirectObjectAt(size_t index) const; |
37 CFX_ByteString GetStringAt(size_t index) const; | 37 CFX_ByteString GetStringAt(size_t index) const; |
38 int GetIntegerAt(size_t index) const; | 38 int GetIntegerAt(size_t index) const; |
(...skipping 16 matching lines...) Expand all Loading... |
55 void AddString(const CFX_ByteString& str); | 55 void AddString(const CFX_ByteString& str); |
56 void AddName(const CFX_ByteString& str); | 56 void AddName(const CFX_ByteString& str); |
57 void AddReference(CPDF_IndirectObjectHolder* pDoc, uint32_t objnum); | 57 void AddReference(CPDF_IndirectObjectHolder* pDoc, uint32_t objnum); |
58 | 58 |
59 iterator begin() { return m_Objects.begin(); } | 59 iterator begin() { return m_Objects.begin(); } |
60 iterator end() { return m_Objects.end(); } | 60 iterator end() { return m_Objects.end(); } |
61 const_iterator begin() const { return m_Objects.begin(); } | 61 const_iterator begin() const { return m_Objects.begin(); } |
62 const_iterator end() const { return m_Objects.end(); } | 62 const_iterator end() const { return m_Objects.end(); } |
63 | 63 |
64 protected: | 64 protected: |
65 CPDF_Object* CloneNonCyclic( | 65 std::unique_ptr<CPDF_Object> CloneNonCyclic( |
66 bool bDirect, | 66 bool bDirect, |
67 std::set<const CPDF_Object*>* pVisited) const override; | 67 std::set<const CPDF_Object*>* pVisited) const override; |
68 | 68 |
69 std::vector<CPDF_Object*> m_Objects; | 69 std::vector<CPDF_Object*> m_Objects; |
70 }; | 70 }; |
71 | 71 |
72 inline CPDF_Array* ToArray(CPDF_Object* obj) { | 72 inline CPDF_Array* ToArray(CPDF_Object* obj) { |
73 return obj ? obj->AsArray() : nullptr; | 73 return obj ? obj->AsArray() : nullptr; |
74 } | 74 } |
75 | 75 |
76 inline const CPDF_Array* ToArray(const CPDF_Object* obj) { | 76 inline const CPDF_Array* ToArray(const CPDF_Object* obj) { |
77 return obj ? obj->AsArray() : nullptr; | 77 return obj ? obj->AsArray() : nullptr; |
78 } | 78 } |
79 | 79 |
80 inline std::unique_ptr<CPDF_Array> ToArray(std::unique_ptr<CPDF_Object> obj) { | 80 inline std::unique_ptr<CPDF_Array> ToArray(std::unique_ptr<CPDF_Object> obj) { |
81 CPDF_Array* pArray = ToArray(obj.get()); | 81 CPDF_Array* pArray = ToArray(obj.get()); |
82 if (!pArray) | 82 if (!pArray) |
83 return nullptr; | 83 return nullptr; |
84 obj.release(); | 84 obj.release(); |
85 return std::unique_ptr<CPDF_Array>(pArray); | 85 return std::unique_ptr<CPDF_Array>(pArray); |
86 } | 86 } |
87 | 87 |
88 #endif // CORE_FPDFAPI_PARSER_CPDF_ARRAY_H_ | 88 #endif // CORE_FPDFAPI_PARSER_CPDF_ARRAY_H_ |
OLD | NEW |