From 1d88955fa68fb7fb0fd2d705bc80655edb7a5972 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 20 Jan 2013 14:55:01 -0500 Subject: Added new QPDFObjectHandle types Keyword and InlineImage These object types are to facilitate content stream parsing. --- libqpdf/QPDFObjectHandle.cc | 59 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) (limited to 'libqpdf/QPDFObjectHandle.cc') diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index 54897b83..9b51a0cb 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include #include #include @@ -151,6 +153,20 @@ QPDFObjectHandle::isString() return QPDFObjectTypeAccessor::check(obj.getPointer()); } +bool +QPDFObjectHandle::isKeyword() +{ + dereference(); + return QPDFObjectTypeAccessor::check(obj.getPointer()); +} + +bool +QPDFObjectHandle::isInlineImage() +{ + dereference(); + return QPDFObjectTypeAccessor::check(obj.getPointer()); +} + bool QPDFObjectHandle::isArray() { @@ -190,7 +206,8 @@ QPDFObjectHandle::isIndirect() bool QPDFObjectHandle::isScalar() { - return (! (isArray() || isDictionary() || isStream())); + return (! (isArray() || isDictionary() || isStream() || + isKeyword() || isInlineImage())); } // Bool accessors @@ -245,6 +262,22 @@ QPDFObjectHandle::getUTF8Value() return dynamic_cast(obj.getPointer())->getUTF8Val(); } +// Keyword and Inline Image accessors + +std::string +QPDFObjectHandle::getKeywordValue() +{ + assertKeyword(); + return dynamic_cast(obj.getPointer())->getVal(); +} + +std::string +QPDFObjectHandle::getInlineImageValue() +{ + assertInlineImage(); + return dynamic_cast(obj.getPointer())->getVal(); +} + // Array accessors int @@ -928,6 +961,18 @@ QPDFObjectHandle::newString(std::string const& str) return QPDFObjectHandle(new QPDF_String(str)); } +QPDFObjectHandle +QPDFObjectHandle::newKeyword(std::string const& value) +{ + return QPDFObjectHandle(new QPDF_Keyword(value)); +} + +QPDFObjectHandle +QPDFObjectHandle::newInlineImage(std::string const& value) +{ + return QPDFObjectHandle(new QPDF_InlineImage(value)); +} + QPDFObjectHandle QPDFObjectHandle::newArray() { @@ -1212,6 +1257,18 @@ QPDFObjectHandle::assertString() assertType("String", isString()); } +void +QPDFObjectHandle::assertKeyword() +{ + assertType("Keyword", isKeyword()); +} + +void +QPDFObjectHandle::assertInlineImage() +{ + assertType("InlineImage", isInlineImage()); +} + void QPDFObjectHandle::assertArray() { -- cgit v1.2.3-54-g00ecf