From ce4f95d61f5aa5fb9a5fc6cb8487999a9cf46458 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 20 Oct 2015 16:38:12 -0400 Subject: Add type cast definitions for CPDF_Boolean. This CL adds ToBoolean, CPDF_Object::AsBoolean and CPDF_Object::IsBoolean and updates the src to use them as needed. BUG=pdfium:201 R=thestig@chromium.org, tsepez@chromium.org Review URL: https://codereview.chromium.org/1417623005 . --- core/include/fpdfapi/fpdf_objects.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'core/include') diff --git a/core/include/fpdfapi/fpdf_objects.h b/core/include/fpdfapi/fpdf_objects.h index 4141ec854a..a52132f6b9 100644 --- a/core/include/fpdfapi/fpdf_objects.h +++ b/core/include/fpdfapi/fpdf_objects.h @@ -78,8 +78,12 @@ class CPDF_Object { FX_BOOL IsModified() const { return FALSE; } + bool IsBoolean() const { return m_Type == PDFOBJ_BOOLEAN; } bool IsDictionary() const { return m_Type == PDFOBJ_DICTIONARY; } + CPDF_Boolean* AsBoolean(); + const CPDF_Boolean* AsBoolean() const; + CPDF_Dictionary* AsDictionary(); const CPDF_Dictionary* AsDictionary() const; @@ -117,6 +121,13 @@ class CPDF_Boolean : public CPDF_Object { FX_BOOL m_bValue; friend class CPDF_Object; }; +inline CPDF_Boolean* ToBoolean(CPDF_Object* obj) { + return obj ? obj->AsBoolean() : nullptr; +} +inline const CPDF_Boolean* ToBoolean(const CPDF_Object* obj) { + return obj ? obj->AsBoolean() : nullptr; +} + class CPDF_Number : public CPDF_Object { public: static CPDF_Number* Create(int value) { return new CPDF_Number(value); } -- cgit v1.2.3