diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2015-10-21 11:07:42 -0400 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2015-10-21 11:07:42 -0400 |
commit | 43ce9035a026c7b4f15aa938dc39444d9253ea9f (patch) | |
tree | 8f18c1508dfd0db47d9dec1dbc708fd018349b3f /core/include/fpdfapi/fpdf_objects.h | |
parent | 1edb860fd465879311ec85c5c6385067b7985013 (diff) | |
download | pdfium-43ce9035a026c7b4f15aa938dc39444d9253ea9f.tar.xz |
Merge to XFA: Add type cast definitions for CPDF_Number.
This Cl adds ToNumber, CPDF_Object::AsNumber and CPDF_Object::IsNumber and
updates the src to use them as needed.
BUG=pdfium:201
TBR=thestig@chromium.org
Review URL: https://codereview.chromium.org/1410673005 .
(cherry picked from commit 83bf02dfb860a66d756434d194118dae572d04d3)
Review URL: https://codereview.chromium.org/1422583002 .
Diffstat (limited to 'core/include/fpdfapi/fpdf_objects.h')
-rw-r--r-- | core/include/fpdfapi/fpdf_objects.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/include/fpdfapi/fpdf_objects.h b/core/include/fpdfapi/fpdf_objects.h index 17aba67deb..41b457799b 100644 --- a/core/include/fpdfapi/fpdf_objects.h +++ b/core/include/fpdfapi/fpdf_objects.h @@ -82,6 +82,7 @@ class CPDF_Object { bool IsBoolean() const { return m_Type == PDFOBJ_BOOLEAN; } bool IsDictionary() const { return m_Type == PDFOBJ_DICTIONARY; } + bool IsNumber() const { return m_Type == PDFOBJ_NUMBER; } CPDF_Boolean* AsBoolean(); const CPDF_Boolean* AsBoolean() const; @@ -89,6 +90,9 @@ class CPDF_Object { CPDF_Dictionary* AsDictionary(); const CPDF_Dictionary* AsDictionary() const; + CPDF_Number* AsNumber(); + const CPDF_Number* AsNumber() const; + protected: CPDF_Object(FX_DWORD type) : m_Type(type), m_ObjNum(0), m_GenNum(0) {} ~CPDF_Object() {} @@ -180,6 +184,13 @@ class CPDF_Number : public CPDF_Object { }; friend class CPDF_Object; }; +inline CPDF_Number* ToNumber(CPDF_Object* obj) { + return obj ? obj->AsNumber() : nullptr; +} +inline const CPDF_Number* ToNumber(const CPDF_Object* obj) { + return obj ? obj->AsNumber() : nullptr; +} + class CPDF_String : public CPDF_Object { public: static CPDF_String* Create(const CFX_ByteString& str, FX_BOOL bHex = FALSE) { |