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

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

Issue 2392603004: Move core/fpdfapi/fpdf_parser to core/fpdfapi/parser (Closed)
Patch Set: Rebase to master Created 4 years, 2 months 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
(Empty)
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #ifndef CORE_FPDFAPI_FPDF_PARSER_CPDF_DICTIONARY_H_
8 #define CORE_FPDFAPI_FPDF_PARSER_CPDF_DICTIONARY_H_
9
10 #include <map>
11 #include <set>
12
13 #include "core/fpdfapi/fpdf_parser/cpdf_object.h"
14 #include "core/fxcrt/cfx_string_pool_template.h"
15 #include "core/fxcrt/cfx_weak_ptr.h"
16 #include "core/fxcrt/fx_coordinates.h"
17 #include "core/fxcrt/fx_string.h"
18
19 class CPDF_IndirectObjectHolder;
20
21 class CPDF_Dictionary : public CPDF_Object {
22 public:
23 using iterator = std::map<CFX_ByteString, CPDF_Object*>::iterator;
24 using const_iterator = std::map<CFX_ByteString, CPDF_Object*>::const_iterator;
25
26 CPDF_Dictionary();
27 explicit CPDF_Dictionary(const CFX_WeakPtr<CFX_ByteStringPool>& pPool);
28
29 // CPDF_Object.
30 Type GetType() const override;
31 CPDF_Object* Clone() const override;
32 CPDF_Dictionary* GetDict() const override;
33 bool IsDictionary() const override;
34 CPDF_Dictionary* AsDictionary() override;
35 const CPDF_Dictionary* AsDictionary() const override;
36
37 size_t GetCount() const { return m_Map.size(); }
38 CPDF_Object* GetObjectFor(const CFX_ByteString& key) const;
39 CPDF_Object* GetDirectObjectFor(const CFX_ByteString& key) const;
40 CFX_ByteString GetStringFor(const CFX_ByteString& key) const;
41 CFX_ByteString GetStringFor(const CFX_ByteString& key,
42 const CFX_ByteString& default_str) const;
43 CFX_WideString GetUnicodeTextFor(const CFX_ByteString& key) const;
44 int GetIntegerFor(const CFX_ByteString& key) const;
45 int GetIntegerFor(const CFX_ByteString& key, int default_int) const;
46 bool GetBooleanFor(const CFX_ByteString& key, bool bDefault = false) const;
47 FX_FLOAT GetNumberFor(const CFX_ByteString& key) const;
48 CPDF_Dictionary* GetDictFor(const CFX_ByteString& key) const;
49 CPDF_Stream* GetStreamFor(const CFX_ByteString& key) const;
50 CPDF_Array* GetArrayFor(const CFX_ByteString& key) const;
51 CFX_FloatRect GetRectFor(const CFX_ByteString& key) const;
52 CFX_Matrix GetMatrixFor(const CFX_ByteString& key) const;
53 FX_FLOAT GetFloatFor(const CFX_ByteString& key) const {
54 return GetNumberFor(key);
55 }
56
57 FX_BOOL KeyExist(const CFX_ByteString& key) const;
58 bool IsSignatureDict() const;
59
60 // Set* functions invalidate iterators for the element with the key |key|.
61 void SetFor(const CFX_ByteString& key, CPDF_Object* pObj);
62 void SetNameFor(const CFX_ByteString& key, const CFX_ByteString& name);
63 void SetStringFor(const CFX_ByteString& key, const CFX_ByteString& str);
64 void SetIntegerFor(const CFX_ByteString& key, int i);
65 void SetNumberFor(const CFX_ByteString& key, FX_FLOAT f);
66 void SetReferenceFor(const CFX_ByteString& key,
67 CPDF_IndirectObjectHolder* pDoc,
68 uint32_t objnum);
69 void SetRectFor(const CFX_ByteString& key, const CFX_FloatRect& rect);
70 void SetMatrixFor(const CFX_ByteString& key, const CFX_Matrix& matrix);
71 void SetBooleanFor(const CFX_ByteString& key, bool bValue);
72
73 // Invalidates iterators for the element with the key |key|.
74 void RemoveFor(const CFX_ByteString& key);
75
76 // Invalidates iterators for the element with the key |oldkey|.
77 void ReplaceKey(const CFX_ByteString& oldkey, const CFX_ByteString& newkey);
78
79 iterator begin() { return m_Map.begin(); }
80 iterator end() { return m_Map.end(); }
81 const_iterator begin() const { return m_Map.begin(); }
82 const_iterator end() const { return m_Map.end(); }
83
84 CFX_WeakPtr<CFX_ByteStringPool> GetByteStringPool() const { return m_pPool; }
85
86 protected:
87 ~CPDF_Dictionary() override;
88
89 CFX_ByteString MaybeIntern(const CFX_ByteString& str);
90 CPDF_Object* CloneNonCyclic(
91 bool bDirect,
92 std::set<const CPDF_Object*>* visited) const override;
93
94 CFX_WeakPtr<CFX_ByteStringPool> m_pPool;
95 std::map<CFX_ByteString, CPDF_Object*> m_Map;
96 };
97
98 #endif // CORE_FPDFAPI_FPDF_PARSER_CPDF_DICTIONARY_H_
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp ('k') | core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698