summaryrefslogtreecommitdiff
path: root/core/include
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-10-20 16:38:12 -0400
committerDan Sinclair <dsinclair@chromium.org>2015-10-20 16:38:12 -0400
commitce4f95d61f5aa5fb9a5fc6cb8487999a9cf46458 (patch)
treee94487d8febe420592249615061169e011ce8c3b /core/include
parent48cc160caf622bdd1dd5db2dde1935ccaf0b9203 (diff)
downloadpdfium-ce4f95d61f5aa5fb9a5fc6cb8487999a9cf46458.tar.xz
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 .
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 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); }