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

Unified Diff: core/include/fpdfapi/fpdf_objects.h

Issue 1417823005: Add type cast definitions for CPDF_Name. (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 side-by-side diff with in-line comments
Download patch
Index: core/include/fpdfapi/fpdf_objects.h
diff --git a/core/include/fpdfapi/fpdf_objects.h b/core/include/fpdfapi/fpdf_objects.h
index 438c89cc50121bc201d6fc5882bd281e3af1b031..4cfe0d6a905333691917d42cc38f99c1e6491c3a 100644
--- a/core/include/fpdfapi/fpdf_objects.h
+++ b/core/include/fpdfapi/fpdf_objects.h
@@ -16,6 +16,7 @@ class CPDF_CryptoHandler;
class CPDF_Dictionary;
class CPDF_Document;
class CPDF_IndirectObjects;
+class CPDF_Name;
class CPDF_Null;
class CPDF_Number;
class CPDF_Parser;
@@ -80,6 +81,7 @@ class CPDF_Object {
bool IsBoolean() const { return m_Type == PDFOBJ_BOOLEAN; }
bool IsDictionary() const { return m_Type == PDFOBJ_DICTIONARY; }
+ bool IsName() const { return m_Type == PDFOBJ_NAME; }
bool IsNumber() const { return m_Type == PDFOBJ_NUMBER; }
CPDF_Boolean* AsBoolean();
@@ -88,6 +90,9 @@ class CPDF_Object {
CPDF_Dictionary* AsDictionary();
const CPDF_Dictionary* AsDictionary() const;
+ CPDF_Name* AsName();
+ const CPDF_Name* AsName() const;
+
CPDF_Number* AsNumber();
const CPDF_Number* AsNumber() const;
@@ -248,6 +253,13 @@ class CPDF_Name : public CPDF_Object {
CFX_ByteString m_Name;
friend class CPDF_Object;
};
+inline CPDF_Name* ToName(CPDF_Object* obj) {
+ return obj ? obj->AsName() : nullptr;
+}
+inline const CPDF_Name* ToName(const CPDF_Object* obj) {
+ return obj ? obj->AsName() : nullptr;
+}
+
class CPDF_Array : public CPDF_Object {
public:
static CPDF_Array* Create() { return new CPDF_Array(); }
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_font/fpdf_font.cpp » ('j') | core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698