summaryrefslogtreecommitdiff
path: root/core/include
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-10-20 16:44:57 -0400
committerDan Sinclair <dsinclair@chromium.org>2015-10-20 16:44:57 -0400
commit05d9e934b74c2d4e4f2983cb8d31e995a18cbe6a (patch)
tree928a7ccab88e351df14ae1e0cbff3c7c8fad3c89 /core/include
parentf1251c1ff2b3452854681d0648b4c1ca4180ff0d (diff)
downloadpdfium-05d9e934b74c2d4e4f2983cb8d31e995a18cbe6a.tar.xz
[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 .
Diffstat (limited to 'core/include')
-rw-r--r--core/include/fpdfapi/fpdf_objects.h11
1 files changed, 11 insertions, 0 deletions
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); }