2022-09-05 13:15:14 +00:00
|
|
|
#ifndef QPDFVALUEPROXY_HH
|
|
|
|
#define QPDFVALUEPROXY_HH
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2022-04-02 21:14:10 +00:00
|
|
|
#include <qpdf/Constants.h>
|
2009-10-19 20:17:14 +00:00
|
|
|
#include <qpdf/DLL.h>
|
2018-12-17 22:40:29 +00:00
|
|
|
#include <qpdf/JSON.hh>
|
2022-08-02 20:35:04 +00:00
|
|
|
#include <qpdf/QPDFValue.hh>
|
2022-04-02 21:14:10 +00:00
|
|
|
#include <qpdf/Types.h>
|
2009-08-06 19:00:25 +00:00
|
|
|
|
2008-04-29 12:55:25 +00:00
|
|
|
#include <string>
|
|
|
|
|
2010-06-06 13:32:08 +00:00
|
|
|
class QPDF;
|
|
|
|
class QPDFObjectHandle;
|
|
|
|
|
2022-09-05 13:15:14 +00:00
|
|
|
class QPDFValueProxy
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
2022-08-02 20:35:04 +00:00
|
|
|
friend class QPDFValue;
|
2013-01-22 14:57:07 +00:00
|
|
|
|
2022-08-02 20:35:04 +00:00
|
|
|
public:
|
2022-09-05 13:15:14 +00:00
|
|
|
QPDFValueProxy() = default;
|
2022-08-02 20:35:04 +00:00
|
|
|
|
2022-09-05 13:15:14 +00:00
|
|
|
std::shared_ptr<QPDFValueProxy>
|
2022-08-02 20:35:04 +00:00
|
|
|
shallowCopy()
|
|
|
|
{
|
|
|
|
return value->shallowCopy();
|
|
|
|
}
|
|
|
|
std::string
|
|
|
|
unparse()
|
|
|
|
{
|
|
|
|
return value->unparse();
|
|
|
|
}
|
|
|
|
JSON
|
|
|
|
getJSON(int json_version)
|
|
|
|
{
|
|
|
|
return value->getJSON(json_version);
|
|
|
|
}
|
2010-06-06 13:32:08 +00:00
|
|
|
|
2013-01-22 14:57:07 +00:00
|
|
|
// Return a unique type code for the object
|
2022-09-01 21:39:52 +00:00
|
|
|
qpdf_object_type_e
|
2022-08-02 20:35:04 +00:00
|
|
|
getTypeCode() const
|
|
|
|
{
|
2022-08-02 21:57:33 +00:00
|
|
|
return value->type_code;
|
2022-08-02 20:35:04 +00:00
|
|
|
}
|
2013-01-22 14:57:07 +00:00
|
|
|
|
|
|
|
// Return a string literal that describes the type, useful for
|
|
|
|
// debugging and testing
|
2022-08-02 20:35:04 +00:00
|
|
|
char const*
|
|
|
|
getTypeName() const
|
|
|
|
{
|
2022-08-02 21:57:33 +00:00
|
|
|
return value->type_name;
|
2022-08-02 20:35:04 +00:00
|
|
|
}
|
2022-09-07 18:11:24 +00:00
|
|
|
|
2022-08-14 10:19:00 +00:00
|
|
|
QPDF*
|
|
|
|
getQPDF() const
|
|
|
|
{
|
|
|
|
return value->qpdf;
|
|
|
|
}
|
2022-08-14 10:32:20 +00:00
|
|
|
QPDFObjGen
|
|
|
|
getObjGen() const
|
|
|
|
{
|
|
|
|
return value->og;
|
|
|
|
}
|
|
|
|
|
2022-08-02 20:35:04 +00:00
|
|
|
void
|
|
|
|
setDescription(QPDF* qpdf, std::string const& description)
|
|
|
|
{
|
|
|
|
return value->setDescription(qpdf, description);
|
|
|
|
}
|
|
|
|
bool
|
|
|
|
getDescription(QPDF*& qpdf, std::string& description)
|
|
|
|
{
|
|
|
|
return value->getDescription(qpdf, description);
|
|
|
|
}
|
|
|
|
bool
|
|
|
|
hasDescription()
|
|
|
|
{
|
|
|
|
return value->hasDescription();
|
|
|
|
}
|
|
|
|
void
|
|
|
|
setParsedOffset(qpdf_offset_t offset)
|
|
|
|
{
|
|
|
|
value->setParsedOffset(offset);
|
|
|
|
}
|
|
|
|
qpdf_offset_t
|
|
|
|
getParsedOffset()
|
|
|
|
{
|
|
|
|
return value->getParsedOffset();
|
|
|
|
}
|
|
|
|
void
|
2022-09-05 13:15:14 +00:00
|
|
|
assign(std::shared_ptr<QPDFValueProxy> o)
|
2022-08-02 20:35:04 +00:00
|
|
|
{
|
|
|
|
value = o->value;
|
|
|
|
}
|
|
|
|
void
|
2022-09-05 13:15:14 +00:00
|
|
|
swapWith(std::shared_ptr<QPDFValueProxy> o)
|
2022-08-02 20:35:04 +00:00
|
|
|
{
|
|
|
|
auto v = value;
|
|
|
|
value = o->value;
|
|
|
|
o->value = v;
|
2022-08-14 00:05:32 +00:00
|
|
|
auto og = value->og;
|
|
|
|
value->og = o->value->og;
|
|
|
|
o->value->og = og;
|
2022-08-02 20:35:04 +00:00
|
|
|
}
|
2022-08-14 00:05:32 +00:00
|
|
|
|
|
|
|
// The following two methods are for use by class QPDF only
|
|
|
|
void
|
|
|
|
setObjGen(QPDF* qpdf, QPDFObjGen const& og)
|
|
|
|
{
|
|
|
|
value->qpdf = qpdf;
|
|
|
|
value->og = og;
|
|
|
|
}
|
|
|
|
void
|
2022-09-07 20:49:31 +00:00
|
|
|
reset()
|
|
|
|
{
|
|
|
|
value->reset();
|
|
|
|
// It would be better if, rather than clearing value->qpdf and
|
|
|
|
// value->og, we completely replaced value with a null object.
|
|
|
|
// However, at the time of the release of qpdf 11, this causes
|
|
|
|
// test failures and would likely break a lot of code since it
|
|
|
|
// possible for a direct object that recursively contains no
|
|
|
|
// indirect objects to be copied into multiple QPDF objects.
|
|
|
|
// For that reason, we have to break the association with the
|
|
|
|
// owning QPDF but not otherwise mutate the object. For
|
|
|
|
// indirect objects, QPDF::~QPDF replaces the object with
|
|
|
|
// null, which clears circular references. If this code were
|
|
|
|
// able to do the null replacement, that code would not have
|
|
|
|
// to.
|
2022-08-14 00:05:32 +00:00
|
|
|
value->qpdf = nullptr;
|
|
|
|
value->og = QPDFObjGen();
|
|
|
|
}
|
|
|
|
|
2022-08-10 12:16:06 +00:00
|
|
|
bool
|
2022-08-14 09:50:30 +00:00
|
|
|
isUnresolved() const
|
2022-08-10 12:16:06 +00:00
|
|
|
{
|
|
|
|
return value->type_code == ::ot_unresolved;
|
|
|
|
}
|
2022-08-14 09:50:30 +00:00
|
|
|
void
|
|
|
|
resolve()
|
|
|
|
{
|
|
|
|
if (isUnresolved()) {
|
|
|
|
doResolve();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void doResolve();
|
|
|
|
|
2022-08-02 20:35:04 +00:00
|
|
|
template <typename T>
|
|
|
|
T*
|
|
|
|
as()
|
|
|
|
{
|
|
|
|
return dynamic_cast<T*>(value.get());
|
|
|
|
}
|
2013-01-22 14:57:07 +00:00
|
|
|
|
2018-02-16 22:25:27 +00:00
|
|
|
private:
|
2022-09-05 13:15:14 +00:00
|
|
|
QPDFValueProxy(QPDFValueProxy const&) = delete;
|
|
|
|
QPDFValueProxy& operator=(QPDFValueProxy const&) = delete;
|
2022-08-02 20:35:04 +00:00
|
|
|
std::shared_ptr<QPDFValue> value;
|
2008-04-29 12:55:25 +00:00
|
|
|
};
|
|
|
|
|
2022-09-05 13:15:14 +00:00
|
|
|
#endif // QPDFVALUEPROXY_HH
|