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

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

Issue 1417933002: Add type cast definitions for CPDF_String. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 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_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ 7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_
8 #define CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ 8 #define CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_
9 9
10 #include "../fxcrt/fx_coordinates.h" 10 #include "../fxcrt/fx_coordinates.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 void SetUnicodeText(const FX_WCHAR* pUnicodes, int len = -1); 75 void SetUnicodeText(const FX_WCHAR* pUnicodes, int len = -1);
76 76
77 int GetDirectType() const; 77 int GetDirectType() const;
78 78
79 FX_BOOL IsModified() const { return FALSE; } 79 FX_BOOL IsModified() const { return FALSE; }
80 80
81 bool IsBoolean() const { return m_Type == PDFOBJ_BOOLEAN; } 81 bool IsBoolean() const { return m_Type == PDFOBJ_BOOLEAN; }
82 bool IsDictionary() const { return m_Type == PDFOBJ_DICTIONARY; } 82 bool IsDictionary() const { return m_Type == PDFOBJ_DICTIONARY; }
83 bool IsNumber() const { return m_Type == PDFOBJ_NUMBER; } 83 bool IsNumber() const { return m_Type == PDFOBJ_NUMBER; }
84 bool IsString() const { return m_Type == PDFOBJ_STRING; }
84 85
85 CPDF_Boolean* AsBoolean(); 86 CPDF_Boolean* AsBoolean();
86 const CPDF_Boolean* AsBoolean() const; 87 const CPDF_Boolean* AsBoolean() const;
87 88
88 CPDF_Dictionary* AsDictionary(); 89 CPDF_Dictionary* AsDictionary();
89 const CPDF_Dictionary* AsDictionary() const; 90 const CPDF_Dictionary* AsDictionary() const;
90 91
91 CPDF_Number* AsNumber(); 92 CPDF_Number* AsNumber();
92 const CPDF_Number* AsNumber() const; 93 const CPDF_Number* AsNumber() const;
93 94
95 CPDF_String* AsString();
96 const CPDF_String* AsString() const;
97
94 protected: 98 protected:
95 CPDF_Object(FX_DWORD type) : m_Type(type), m_ObjNum(0), m_GenNum(0) {} 99 CPDF_Object(FX_DWORD type) : m_Type(type), m_ObjNum(0), m_GenNum(0) {}
96 ~CPDF_Object() {} 100 ~CPDF_Object() {}
97 void Destroy(); 101 void Destroy();
98 102
99 static const int OBJECT_REF_MAX_DEPTH = 128; 103 static const int OBJECT_REF_MAX_DEPTH = 128;
100 static int s_nCurRefDepth; 104 static int s_nCurRefDepth;
101 FX_DWORD m_Type; 105 FX_DWORD m_Type;
102 FX_DWORD m_ObjNum; 106 FX_DWORD m_ObjNum;
103 FX_DWORD m_GenNum; 107 FX_DWORD m_GenNum;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 217 }
214 218
215 FX_BOOL IsHex() const { return m_bHex; } 219 FX_BOOL IsHex() const { return m_bHex; }
216 220
217 protected: 221 protected:
218 CFX_ByteString m_String; 222 CFX_ByteString m_String;
219 223
220 FX_BOOL m_bHex; 224 FX_BOOL m_bHex;
221 friend class CPDF_Object; 225 friend class CPDF_Object;
222 }; 226 };
227 inline CPDF_String* ToString(CPDF_Object* obj) {
228 return obj ? obj->AsString() : nullptr;
229 }
230 inline const CPDF_String* ToString(const CPDF_Object* obj) {
231 return obj ? obj->AsString() : nullptr;
232 }
233
223 class CPDF_Name : public CPDF_Object { 234 class CPDF_Name : public CPDF_Object {
224 public: 235 public:
225 static CPDF_Name* Create(const CFX_ByteString& str) { 236 static CPDF_Name* Create(const CFX_ByteString& str) {
226 return new CPDF_Name(str); 237 return new CPDF_Name(str);
227 } 238 }
228 239
229 static CPDF_Name* Create(const CFX_ByteStringC& str) { 240 static CPDF_Name* Create(const CFX_ByteStringC& str) {
230 return new CPDF_Name(str); 241 return new CPDF_Name(str);
231 } 242 }
232 243
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 597
587 protected: 598 protected:
588 CFX_MapPtrToPtr m_IndirectObjs; 599 CFX_MapPtrToPtr m_IndirectObjs;
589 600
590 CPDF_Parser* m_pParser; 601 CPDF_Parser* m_pParser;
591 602
592 FX_DWORD m_LastObjNum; 603 FX_DWORD m_LastObjNum;
593 }; 604 };
594 605
595 #endif // CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ 606 #endif // CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_
OLDNEW
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698