aboutsummaryrefslogtreecommitdiffstats
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
parenta844c2a3ab9bc0337fa189954efaf515148b5f0a (diff)
downloadqpdf-1d88955fa68fb7fb0fd2d705bc80655edb7a5972.tar.zst
Added new QPDFObjectHandle types Keyword and InlineImage
These object types are to facilitate content stream parsing.
-rw-r--r--ChangeLog6
-rw-r--r--TODO6
-rw-r--r--include/qpdf/QPDFObjectHandle.hh24
-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
9 files changed, 178 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index fd078f98..e4919ca6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-01-20 Jay Berkenbilt <ejb@ql.org>
+
+ * Added QPDF_Keyword and QPDF_InlineImage types along with
+ appropriate wrapper methods in QPDFObjectHandle. These new object
+ types are to facilitate content stream parsing.
+
2013-01-17 Jay Berkenbilt <ejb@ql.org>
* 4.0.1: release
diff --git a/TODO b/TODO
index ec797aaf..9ac85911 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,9 @@
+4.1.0
+=====
+
+ * New public interfaces have been added.
+
+
General
=======
diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh
index 75912e79..932a6678 100644
--- a/include/qpdf/QPDFObjectHandle.hh
+++ b/include/qpdf/QPDFObjectHandle.hh
@@ -76,7 +76,8 @@ class QPDFObjectHandle
QPDF_DLL
bool isInitialized() const;
- // Exactly one of these will return true for any object.
+ // Exactly one of these will return true for any object. Keyword
+ // and InlineImage are only allowed in content streams.
QPDF_DLL
bool isBool();
QPDF_DLL
@@ -90,6 +91,10 @@ class QPDFObjectHandle
QPDF_DLL
bool isString();
QPDF_DLL
+ bool isKeyword();
+ QPDF_DLL
+ bool isInlineImage();
+ QPDF_DLL
bool isArray();
QPDF_DLL
bool isDictionary();
@@ -103,7 +108,8 @@ class QPDFObjectHandle
QPDF_DLL
bool isIndirect();
- // True for everything except array, dictionary, and stream
+ // True for everything except array, dictionary, stream, word, and
+ // inline image.
QPDF_DLL
bool isScalar();
@@ -148,6 +154,10 @@ class QPDFObjectHandle
QPDF_DLL
static QPDFObjectHandle newString(std::string const& str);
QPDF_DLL
+ static QPDFObjectHandle newKeyword(std::string const&);
+ QPDF_DLL
+ static QPDFObjectHandle newInlineImage(std::string const&);
+ QPDF_DLL
static QPDFObjectHandle newArray();
QPDF_DLL
static QPDFObjectHandle newArray(
@@ -239,6 +249,12 @@ class QPDFObjectHandle
QPDF_DLL
std::string getUTF8Value();
+ // Methods for content stream objects
+ QPDF_DLL
+ std::string getKeywordValue();
+ QPDF_DLL
+ std::string getInlineImageValue();
+
// Methods for array objects; see also name and array objects
QPDF_DLL
int getArrayNItems();
@@ -510,6 +526,10 @@ class QPDFObjectHandle
QPDF_DLL
void assertString();
QPDF_DLL
+ void assertKeyword();
+ QPDF_DLL
+ void assertInlineImage();
+ QPDF_DLL
void assertArray();
QPDF_DLL
void assertDictionary();
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__