Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1669)

Unified Diff: core/include/fpdfapi/fpdf_objects.h

Issue 1410673005: Add type cast definitions for CPDF_Number. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: core/include/fpdfapi/fpdf_objects.h
diff --git a/core/include/fpdfapi/fpdf_objects.h b/core/include/fpdfapi/fpdf_objects.h
index 0df8be727cb9019fdc1dfba16b70dbac8dd44195..438c89cc50121bc201d6fc5882bd281e3af1b031 100644
--- a/core/include/fpdfapi/fpdf_objects.h
+++ b/core/include/fpdfapi/fpdf_objects.h
@@ -80,6 +80,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; }
Lei Zhang 2015/10/21 14:45:50 Do we want to do alphabetical order, or PDFOBJ_FOO
dsinclair 2015/10/21 15:00:11 I'm doing alphabetical order as I think it makes t
CPDF_Boolean* AsBoolean();
const CPDF_Boolean* AsBoolean() const;
@@ -87,6 +88,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() {}
@@ -178,6 +182,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) {
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp » ('j') | core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698