2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 19:08:59 +00:00

Add class QPDF_Unresolved

Allow QPDFObjectHandle::obj to be set prior resolving object.

ot_unresolved has been appended to the list object types in order to
preserve the output of existing test cases.
This commit is contained in:
m-holger 2022-08-02 13:12:17 +01:00
parent bd300be08d
commit 7248cab71b
5 changed files with 66 additions and 0 deletions

View File

@ -82,6 +82,8 @@ enum qpdf_object_type_e {
/* Additional object types that can occur in content streams */ /* Additional object types that can occur in content streams */
ot_operator, ot_operator,
ot_inlineimage, ot_inlineimage,
/* Object types internal to qpdf */
ot_unresolved,
/* NOTE: if adding to this list, update QPDFObject.hh */ /* NOTE: if adding to this list, update QPDFObject.hh */
}; };

View File

@ -61,6 +61,7 @@ class QPDFObject
static constexpr object_type_e ot_stream = ::ot_stream; static constexpr object_type_e ot_stream = ::ot_stream;
static constexpr object_type_e ot_operator = ::ot_operator; static constexpr object_type_e ot_operator = ::ot_operator;
static constexpr object_type_e ot_inlineimage = ::ot_inlineimage; static constexpr object_type_e ot_inlineimage = ::ot_inlineimage;
static constexpr object_type_e ot_unresolved = ::ot_unresolved;
virtual ~QPDFObject() = default; virtual ~QPDFObject() = default;
virtual std::shared_ptr<QPDFObject> shallowCopy() = 0; virtual std::shared_ptr<QPDFObject> shallowCopy() = 0;

View File

@ -99,6 +99,7 @@ set(libqpdf_SOURCES
QPDF_Reserved.cc QPDF_Reserved.cc
QPDF_Stream.cc QPDF_Stream.cc
QPDF_String.cc QPDF_String.cc
QPDF_Unresolved.cc
QPDF_encryption.cc QPDF_encryption.cc
QPDF_json.cc QPDF_json.cc
QPDF_linearization.cc QPDF_linearization.cc

View File

@ -0,0 +1,41 @@
#include <qpdf/QPDF_Unresolved.hh>
#include <stdexcept>
std::shared_ptr<QPDFObject>
QPDF_Unresolved::create()
{
return do_create(new QPDF_Unresolved());
}
std::shared_ptr<QPDFObject>
QPDF_Unresolved::shallowCopy()
{
return create();
}
std::string
QPDF_Unresolved::unparse()
{
throw std::logic_error(
"attempted to unparse an unresolveded QPDFObjectHandle");
return "";
}
JSON
QPDF_Unresolved::getJSON(int json_version)
{
return JSON::makeNull();
}
QPDFObject::object_type_e
QPDF_Unresolved::getTypeCode() const
{
return QPDFObject::ot_unresolved;
}
char const*
QPDF_Unresolved::getTypeName() const
{
return "unresolved";
}

View File

@ -0,0 +1,21 @@
#ifndef QPDF_UNRESOLVED_HH
#define QPDF_UNRESOLVED_HH
#include <qpdf/QPDFObject.hh>
class QPDF_Unresolved: public QPDFObject
{
public:
virtual ~QPDF_Unresolved() = default;
static std::shared_ptr<QPDFObject> create();
virtual std::shared_ptr<QPDFObject> shallowCopy();
virtual std::string unparse();
virtual JSON getJSON(int json_version);
virtual QPDFObject::object_type_e getTypeCode() const;
virtual char const* getTypeName() const;
private:
QPDF_Unresolved() = default;
};
#endif // QPDF_UNRESOLVED_HH