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

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

Issue 1805603002: core/include/fdpfapi cleanup Part I. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 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
« no previous file with comments | « core/include/fpdfapi/cpdf_number.h ('k') | core/include/fpdfapi/cpdf_parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_INCLUDE_FPDFAPI_CPDF_OBJECT_H_
8 #define CORE_INCLUDE_FPDFAPI_CPDF_OBJECT_H_
9
10 #include "core/include/fxcrt/fx_string.h"
11 #include "core/include/fxcrt/fx_system.h"
12
13 class CPDF_Array;
14 class CPDF_Boolean;
15 class CPDF_Dictionary;
16 class CPDF_Name;
17 class CPDF_Null;
18 class CPDF_Number;
19 class CPDF_Reference;
20 class CPDF_Stream;
21 class CPDF_String;
22
23 class CPDF_Object {
24 public:
25 enum Type {
26 BOOLEAN = 1,
27 NUMBER,
28 STRING,
29 NAME,
30 ARRAY,
31 DICTIONARY,
32 STREAM,
33 NULLOBJ,
34 REFERENCE
35 };
36
37 virtual Type GetType() const = 0;
38 FX_DWORD GetObjNum() const { return m_ObjNum; }
39 FX_DWORD GetGenNum() const { return m_GenNum; }
40
41 virtual CPDF_Object* Clone(FX_BOOL bDirect = FALSE) const = 0;
42 virtual CPDF_Object* GetDirect() const;
43
44 FX_BOOL IsModified() const { return FALSE; }
45 void Release();
46
47 virtual CFX_ByteString GetString() const;
48 virtual CFX_ByteStringC GetConstString() const;
49 virtual CFX_WideString GetUnicodeText() const;
50 virtual FX_FLOAT GetNumber() const;
51 virtual int GetInteger() const;
52 virtual CPDF_Dictionary* GetDict() const;
53 virtual CPDF_Array* GetArray() const;
54
55 virtual void SetString(const CFX_ByteString& str);
56
57 virtual bool IsArray() const;
58 virtual bool IsBoolean() const;
59 virtual bool IsDictionary() const;
60 virtual bool IsName() const;
61 virtual bool IsNumber() const;
62 virtual bool IsReference() const;
63 virtual bool IsStream() const;
64 virtual bool IsString() const;
65
66 virtual CPDF_Array* AsArray();
67 virtual const CPDF_Array* AsArray() const;
68 virtual CPDF_Boolean* AsBoolean();
69 virtual const CPDF_Boolean* AsBoolean() const;
70 virtual CPDF_Dictionary* AsDictionary();
71 virtual const CPDF_Dictionary* AsDictionary() const;
72 virtual CPDF_Name* AsName();
73 virtual const CPDF_Name* AsName() const;
74 virtual CPDF_Number* AsNumber();
75 virtual const CPDF_Number* AsNumber() const;
76 virtual CPDF_Reference* AsReference();
77 virtual const CPDF_Reference* AsReference() const;
78 virtual CPDF_Stream* AsStream();
79 virtual const CPDF_Stream* AsStream() const;
80 virtual CPDF_String* AsString();
81 virtual const CPDF_String* AsString() const;
82
83 protected:
84 CPDF_Object() : m_ObjNum(0), m_GenNum(0) {}
85 virtual ~CPDF_Object();
86 void Destroy() { delete this; }
87
88 FX_DWORD m_ObjNum;
89 FX_DWORD m_GenNum;
90
91 friend class CPDF_IndirectObjectHolder;
92 friend class CPDF_Parser;
93
94 private:
95 CPDF_Object(const CPDF_Object& src) {}
96 };
97
98 inline CPDF_Boolean* ToBoolean(CPDF_Object* obj) {
99 return obj ? obj->AsBoolean() : nullptr;
100 }
101
102 inline const CPDF_Boolean* ToBoolean(const CPDF_Object* obj) {
103 return obj ? obj->AsBoolean() : nullptr;
104 }
105
106 inline CPDF_Number* ToNumber(CPDF_Object* obj) {
107 return obj ? obj->AsNumber() : nullptr;
108 }
109
110 inline const CPDF_Number* ToNumber(const CPDF_Object* obj) {
111 return obj ? obj->AsNumber() : nullptr;
112 }
113
114 inline CPDF_String* ToString(CPDF_Object* obj) {
115 return obj ? obj->AsString() : nullptr;
116 }
117
118 inline const CPDF_String* ToString(const CPDF_Object* obj) {
119 return obj ? obj->AsString() : nullptr;
120 }
121
122 inline CPDF_Name* ToName(CPDF_Object* obj) {
123 return obj ? obj->AsName() : nullptr;
124 }
125
126 inline const CPDF_Name* ToName(const CPDF_Object* obj) {
127 return obj ? obj->AsName() : nullptr;
128 }
129
130 inline CPDF_Array* ToArray(CPDF_Object* obj) {
131 return obj ? obj->AsArray() : nullptr;
132 }
133
134 inline const CPDF_Array* ToArray(const CPDF_Object* obj) {
135 return obj ? obj->AsArray() : nullptr;
136 }
137
138 inline CPDF_Dictionary* ToDictionary(CPDF_Object* obj) {
139 return obj ? obj->AsDictionary() : nullptr;
140 }
141
142 inline const CPDF_Dictionary* ToDictionary(const CPDF_Object* obj) {
143 return obj ? obj->AsDictionary() : nullptr;
144 }
145 inline CPDF_Reference* ToReference(CPDF_Object* obj) {
146 return obj ? obj->AsReference() : nullptr;
147 }
148
149 inline const CPDF_Reference* ToReference(const CPDF_Object* obj) {
150 return obj ? obj->AsReference() : nullptr;
151 }
152
153 inline CPDF_Stream* ToStream(CPDF_Object* obj) {
154 return obj ? obj->AsStream() : nullptr;
155 }
156
157 inline const CPDF_Stream* ToStream(const CPDF_Object* obj) {
158 return obj ? obj->AsStream() : nullptr;
159 }
160
161 #endif // CORE_INCLUDE_FPDFAPI_CPDF_OBJECT_H_
OLDNEW
« no previous file with comments | « core/include/fpdfapi/cpdf_number.h ('k') | core/include/fpdfapi/cpdf_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698