aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2013-01-20 20:55:01 +0100
committerJay Berkenbilt <ejb@ql.org>2013-01-20 21:35:39 +0100
commit1d88955fa68fb7fb0fd2d705bc80655edb7a5972 (patch)
tree759fd39c25d449d77294e358efe59d92d9fac879 /libqpdf
parenta844c2a3ab9bc0337fa189954efaf515148b5f0a (diff)
downloadqpdf-1d88955fa68fb7fb0fd2d705bc80655edb7a5972.tar.zst
Added new QPDFObjectHandle types Keyword and InlineImage
These object types are to facilitate content stream parsing.
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDFObjectHandle.cc59
-rw-r--r--libqpdf/QPDF_InlineImage.cc24
-rw-r--r--libqpdf/QPDF_Keyword.cc24
-rw-r--r--libqpdf/build.mk2
-rw-r--r--libqpdf/qpdf/QPDF_InlineImage.hh18
-rw-r--r--libqpdf/qpdf/QPDF_Keyword.hh18
6 files changed, 144 insertions, 1 deletions
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 <qpdf/QPDF_Real.hh>
#include <qpdf/QPDF_Name.hh>
#include <qpdf/QPDF_String.hh>
+#include <qpdf/QPDF_Keyword.hh>
+#include <qpdf/QPDF_InlineImage.hh>
#include <qpdf/QPDF_Array.hh>
#include <qpdf/QPDF_Dictionary.hh>
#include <qpdf/QPDF_Stream.hh>
@@ -152,6 +154,20 @@ QPDFObjectHandle::isString()
}
bool
+QPDFObjectHandle::isKeyword()
+{
+ dereference();
+ return QPDFObjectTypeAccessor<QPDF_Keyword>::check(obj.getPointer());
+}
+
+bool
+QPDFObjectHandle::isInlineImage()
+{
+ dereference();
+ return QPDFObjectTypeAccessor<QPDF_InlineImage>::check(obj.getPointer());
+}
+
+bool
QPDFObjectHandle::isArray()
{
dereference();
@@ -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<QPDF_String*>(obj.getPointer())->getUTF8Val();
}
+// Keyword and Inline Image accessors
+
+std::string
+QPDFObjectHandle::getKeywordValue()
+{
+ assertKeyword();
+ return dynamic_cast<QPDF_Keyword*>(obj.getPointer())->getVal();
+}
+
+std::string
+QPDFObjectHandle::getInlineImageValue()
+{
+ assertInlineImage();
+ return dynamic_cast<QPDF_InlineImage*>(obj.getPointer())->getVal();
+}
+
// Array accessors
int
@@ -929,6 +962,18 @@ QPDFObjectHandle::newString(std::string const& 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()
{
return newArray(std::vector<QPDFObjectHandle>());
@@ -1213,6 +1258,18 @@ QPDFObjectHandle::assertString()
}
void
+QPDFObjectHandle::assertKeyword()
+{
+ assertType("Keyword", isKeyword());
+}
+
+void
+QPDFObjectHandle::assertInlineImage()
+{
+ assertType("InlineImage", isInlineImage());
+}
+
+void
QPDFObjectHandle::assertArray()
{
assertType("Array", isArray());
diff --git a/libqpdf/QPDF_InlineImage.cc b/libqpdf/QPDF_InlineImage.cc
new file mode 100644
index 00000000..e42ddbf2
--- /dev/null
+++ b/libqpdf/QPDF_InlineImage.cc
@@ -0,0 +1,24 @@
+#include <qpdf/QPDF_InlineImage.hh>
+
+#include <qpdf/QUtil.hh>
+
+QPDF_InlineImage::QPDF_InlineImage(std::string const& val) :
+ val(val)
+{
+}
+
+QPDF_InlineImage::~QPDF_InlineImage()
+{
+}
+
+std::string
+QPDF_InlineImage::unparse()
+{
+ return this->val;
+}
+
+std::string
+QPDF_InlineImage::getVal() const
+{
+ return this->val;
+}
diff --git a/libqpdf/QPDF_Keyword.cc b/libqpdf/QPDF_Keyword.cc
new file mode 100644
index 00000000..e2537842
--- /dev/null
+++ b/libqpdf/QPDF_Keyword.cc
@@ -0,0 +1,24 @@
+#include <qpdf/QPDF_Keyword.hh>
+
+#include <qpdf/QUtil.hh>
+
+QPDF_Keyword::QPDF_Keyword(std::string const& val) :
+ val(val)
+{
+}
+
+QPDF_Keyword::~QPDF_Keyword()
+{
+}
+
+std::string
+QPDF_Keyword::unparse()
+{
+ return this->val;
+}
+
+std::string
+QPDF_Keyword::getVal() const
+{
+ return this->val;
+}
diff --git a/libqpdf/build.mk b/libqpdf/build.mk
index a12a0b2c..0b248a91 100644
--- a/libqpdf/build.mk
+++ b/libqpdf/build.mk
@@ -40,8 +40,10 @@ SRCS_libqpdf = \
libqpdf/QPDF_Array.cc \
libqpdf/QPDF_Bool.cc \
libqpdf/QPDF_Dictionary.cc \
+ libqpdf/QPDF_InlineImage.cc \
libqpdf/QPDF_Integer.cc \
libqpdf/QPDF_Name.cc \
+ libqpdf/QPDF_Keyword.cc \
libqpdf/QPDF_Null.cc \
libqpdf/QPDF_Real.cc \
libqpdf/QPDF_Reserved.cc \
diff --git a/libqpdf/qpdf/QPDF_InlineImage.hh b/libqpdf/qpdf/QPDF_InlineImage.hh
new file mode 100644
index 00000000..6408a2f1
--- /dev/null
+++ b/libqpdf/qpdf/QPDF_InlineImage.hh
@@ -0,0 +1,18 @@
+#ifndef __QPDF_INLINEIMAGE_HH__
+#define __QPDF_INLINEIMAGE_HH__
+
+#include <qpdf/QPDFObject.hh>
+
+class QPDF_InlineImage: public QPDFObject
+{
+ public:
+ QPDF_InlineImage(std::string const& val);
+ virtual ~QPDF_InlineImage();
+ virtual std::string unparse();
+ std::string getVal() const;
+
+ private:
+ std::string val;
+};
+
+#endif // __QPDF_INLINEIMAGE_HH__
diff --git a/libqpdf/qpdf/QPDF_Keyword.hh b/libqpdf/qpdf/QPDF_Keyword.hh
new file mode 100644
index 00000000..1a5c0ee6
--- /dev/null
+++ b/libqpdf/qpdf/QPDF_Keyword.hh
@@ -0,0 +1,18 @@
+#ifndef __QPDF_KEYWORD_HH__
+#define __QPDF_KEYWORD_HH__
+
+#include <qpdf/QPDFObject.hh>
+
+class QPDF_Keyword: public QPDFObject
+{
+ public:
+ QPDF_Keyword(std::string const& val);
+ virtual ~QPDF_Keyword();
+ virtual std::string unparse();
+ std::string getVal() const;
+
+ private:
+ std::string val;
+};
+
+#endif // __QPDF_KEYWORD_HH__