mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 02:49:00 +00:00
Added new QPDFObjectHandle types Keyword and InlineImage
These object types are to facilitate content stream parsing.
This commit is contained in:
parent
a844c2a3ab
commit
1d88955fa6
@ -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
|
||||
|
6
TODO
6
TODO
@ -1,3 +1,9 @@
|
||||
4.1.0
|
||||
=====
|
||||
|
||||
* New public interfaces have been added.
|
||||
|
||||
|
||||
General
|
||||
=======
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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>
|
||||
@ -151,6 +153,20 @@ QPDFObjectHandle::isString()
|
||||
return QPDFObjectTypeAccessor<QPDF_String>::check(obj.getPointer());
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
@ -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
|
||||
@ -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()
|
||||
{
|
||||
|
24
libqpdf/QPDF_InlineImage.cc
Normal file
24
libqpdf/QPDF_InlineImage.cc
Normal file
@ -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;
|
||||
}
|
24
libqpdf/QPDF_Keyword.cc
Normal file
24
libqpdf/QPDF_Keyword.cc
Normal file
@ -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;
|
||||
}
|
@ -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 \
|
||||
|
18
libqpdf/qpdf/QPDF_InlineImage.hh
Normal file
18
libqpdf/qpdf/QPDF_InlineImage.hh
Normal file
@ -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__
|
18
libqpdf/qpdf/QPDF_Keyword.hh
Normal file
18
libqpdf/qpdf/QPDF_Keyword.hh
Normal file
@ -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__
|
Loading…
Reference in New Issue
Block a user