From c2bfc000e502c42c9a3017038fd9104c7997d126 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 22 Oct 2015 09:31:44 -0400 Subject: Add type cast definitions for CPDF_Array. This Cl adds ToArray, CPDF_Object::AsArray and CPDF_Object::IsArray 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/1417893003 . --- core/include/fpdfapi/fpdf_objects.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'core/include/fpdfapi') diff --git a/core/include/fpdfapi/fpdf_objects.h b/core/include/fpdfapi/fpdf_objects.h index 2404774dcb..162a514cd7 100644 --- a/core/include/fpdfapi/fpdf_objects.h +++ b/core/include/fpdfapi/fpdf_objects.h @@ -79,12 +79,16 @@ class CPDF_Object { FX_BOOL IsModified() const { return FALSE; } + bool IsArray() const { return m_Type == PDFOBJ_ARRAY; } 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; } bool IsString() const { return m_Type == PDFOBJ_STRING; } + CPDF_Array* AsArray(); + const CPDF_Array* AsArray() const; + CPDF_Boolean* AsBoolean(); const CPDF_Boolean* AsBoolean() const; @@ -341,6 +345,13 @@ class CPDF_Array : public CPDF_Object { CFX_PtrArray m_Objects; friend class CPDF_Object; }; +inline CPDF_Array* ToArray(CPDF_Object* obj) { + return obj ? obj->AsArray() : nullptr; +} +inline const CPDF_Array* ToArray(const CPDF_Object* obj) { + return obj ? obj->AsArray() : nullptr; +} + class CPDF_Dictionary : public CPDF_Object { public: static CPDF_Dictionary* Create() { return new CPDF_Dictionary(); } -- cgit v1.2.3