summaryrefslogtreecommitdiff
path: root/core/include
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-10-22 16:45:48 -0400
committerDan Sinclair <dsinclair@chromium.org>2015-10-22 16:45:48 -0400
commitaa435ba7fe0aacd9102e8c73311c5382ca112439 (patch)
treed37573646c6135126d3971358024a70ee222fb21 /core/include
parent2b11dc1220746d2f6f97a940fc9e4235c8ed4975 (diff)
downloadpdfium-aa435ba7fe0aacd9102e8c73311c5382ca112439.tar.xz
Merge to XFA: Add type cast definitions for CPDF_Stream.
This Cl adds ToStream, CPDF_Object::AsStream and CPDF_Object::IsStream and updates the src to use them as needed. BUG=pdfium:201 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1402413004 . (cherry picked from commit 338805f1366dcdf9a5b48cf591541cf98d7490f1) Review URL: https://codereview.chromium.org/1422513004 .
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 dbd44952ae..332d3ff485 100644
--- a/core/include/fpdfapi/fpdf_objects.h
+++ b/core/include/fpdfapi/fpdf_objects.h
@@ -86,6 +86,7 @@ class CPDF_Object {
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 IsStream() const { return m_Type == PDFOBJ_STREAM; }
bool IsString() const { return m_Type == PDFOBJ_STRING; }
CPDF_Array* AsArray();
@@ -103,6 +104,9 @@ class CPDF_Object {
CPDF_Number* AsNumber();
const CPDF_Number* AsNumber() const;
+ CPDF_Stream* AsStream();
+ const CPDF_Stream* AsStream() const;
+
CPDF_String* AsString();
const CPDF_String* AsString() const;
@@ -527,6 +531,13 @@ class CPDF_Stream : public CPDF_Object {
friend class CPDF_StreamAcc;
friend class CPDF_AttachmentAcc;
};
+inline CPDF_Stream* ToStream(CPDF_Object* obj) {
+ return obj ? obj->AsStream() : nullptr;
+}
+inline const CPDF_Stream* ToStream(const CPDF_Object* obj) {
+ return obj ? obj->AsStream() : nullptr;
+}
+
class CPDF_StreamAcc {
public:
CPDF_StreamAcc();