From 05d9e934b74c2d4e4f2983cb8d31e995a18cbe6a Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 20 Oct 2015 16:44:57 -0400 Subject: [Merge to XFA] 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 TBR=thestig@chromium.org, tsepez@chromium.org Review URL: https://codereview.chromium.org/1417623005 . (cherry picked from commit ce4f95d61f5aa5fb9a5fc6cb8487999a9cf46458) Review URL: https://codereview.chromium.org/1419663004 . --- 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 d64a0924f8..a5f52832a1 100644 --- a/core/include/fpdfapi/fpdf_objects.h +++ b/core/include/fpdfapi/fpdf_objects.h @@ -80,8 +80,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; @@ -119,6 +123,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