mirror of
https://github.com/qpdf/qpdf.git
synced 2024-06-05 11:50:53 +00:00
Rename QPDFValueProxy back to QPDFObject
QPDFValueProxy wasn't a good name for it. We decided the evil of having the header file be named QPDFObject_private.hh was less than the evil of having the class be named something other than what it should have been named.
This commit is contained in:
parent
25ccc7eae4
commit
18a583e8d9
2
TODO
2
TODO
|
@ -789,7 +789,7 @@ Rejected Ideas
|
||||||
|
|
||||||
These are some ideas I had before m-holger's changes to split
|
These are some ideas I had before m-holger's changes to split
|
||||||
QPDFValue from QPDFObject. These notes were written prior to the
|
QPDFValue from QPDFObject. These notes were written prior to the
|
||||||
split of QPDFObject into QPDFValueProxy and QPDFValue and don't work
|
split of QPDFObject into QPDFObject and QPDFValue and don't work
|
||||||
directly with the new implementation. I think they are still basic
|
directly with the new implementation. I think they are still basic
|
||||||
valid after adjusting to the new structure, but I think they would
|
valid after adjusting to the new structure, but I think they would
|
||||||
come at too high a performance cost to be worth doing.
|
come at too high a performance cost to be worth doing.
|
||||||
|
|
|
@ -842,11 +842,11 @@ class QPDF
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Resolver class is restricted to QPDFValueProxy so that only it
|
// The Resolver class is restricted to QPDFObject so that only it
|
||||||
// can resolve indirect references.
|
// can resolve indirect references.
|
||||||
class Resolver
|
class Resolver
|
||||||
{
|
{
|
||||||
friend class QPDFValueProxy;
|
friend class QPDFObject;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void
|
static void
|
||||||
|
@ -952,7 +952,7 @@ class QPDF
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
ObjCache(
|
ObjCache(
|
||||||
std::shared_ptr<QPDFValueProxy> object,
|
std::shared_ptr<QPDFObject> object,
|
||||||
qpdf_offset_t end_before_space,
|
qpdf_offset_t end_before_space,
|
||||||
qpdf_offset_t end_after_space) :
|
qpdf_offset_t end_after_space) :
|
||||||
object(object),
|
object(object),
|
||||||
|
@ -961,7 +961,7 @@ class QPDF
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy> object;
|
std::shared_ptr<QPDFObject> object;
|
||||||
qpdf_offset_t end_before_space;
|
qpdf_offset_t end_before_space;
|
||||||
qpdf_offset_t end_after_space;
|
qpdf_offset_t end_after_space;
|
||||||
};
|
};
|
||||||
|
@ -1186,12 +1186,12 @@ class QPDF
|
||||||
QPDFObjectHandle reserveObjectIfNotExists(QPDFObjGen const& og);
|
QPDFObjectHandle reserveObjectIfNotExists(QPDFObjGen const& og);
|
||||||
QPDFObjectHandle reserveStream(QPDFObjGen const& og);
|
QPDFObjectHandle reserveStream(QPDFObjGen const& og);
|
||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
newIndirect(QPDFObjGen const&, std::shared_ptr<QPDFValueProxy> const&);
|
newIndirect(QPDFObjGen const&, std::shared_ptr<QPDFObject> const&);
|
||||||
bool isCached(QPDFObjGen const& og);
|
bool isCached(QPDFObjGen const& og);
|
||||||
bool isUnresolved(QPDFObjGen const& og);
|
bool isUnresolved(QPDFObjGen const& og);
|
||||||
void updateCache(
|
void updateCache(
|
||||||
QPDFObjGen const& og,
|
QPDFObjGen const& og,
|
||||||
std::shared_ptr<QPDFValueProxy> const& object,
|
std::shared_ptr<QPDFObject> const& object,
|
||||||
qpdf_offset_t end_before_space,
|
qpdf_offset_t end_before_space,
|
||||||
qpdf_offset_t end_after_space);
|
qpdf_offset_t end_after_space);
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ class QPDF_Real;
|
||||||
class QPDF_Reserved;
|
class QPDF_Reserved;
|
||||||
class QPDF_Stream;
|
class QPDF_Stream;
|
||||||
class QPDF_String;
|
class QPDF_String;
|
||||||
class QPDFValueProxy;
|
class QPDFObject;
|
||||||
class QPDFTokenizer;
|
class QPDFTokenizer;
|
||||||
class QPDFExc;
|
class QPDFExc;
|
||||||
class Pl_QPDFTokenizer;
|
class Pl_QPDFTokenizer;
|
||||||
|
@ -1493,7 +1493,7 @@ class QPDFObjectHandle
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QPDFObjectHandle
|
static QPDFObjectHandle
|
||||||
newIndirect(std::shared_ptr<QPDFValueProxy> const& obj)
|
newIndirect(std::shared_ptr<QPDFObject> const& obj)
|
||||||
{
|
{
|
||||||
return QPDFObjectHandle(obj);
|
return QPDFObjectHandle(obj);
|
||||||
}
|
}
|
||||||
|
@ -1518,7 +1518,7 @@ class QPDFObjectHandle
|
||||||
friend class QPDF;
|
friend class QPDF;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::shared_ptr<QPDFValueProxy>
|
static std::shared_ptr<QPDFObject>
|
||||||
getObject(QPDFObjectHandle& o)
|
getObject(QPDFObjectHandle& o)
|
||||||
{
|
{
|
||||||
if (!o.dereference()) {
|
if (!o.dereference()) {
|
||||||
|
@ -1617,7 +1617,7 @@ class QPDFObjectHandle
|
||||||
bool isImage(bool exclude_imagemask = true);
|
bool isImage(bool exclude_imagemask = true);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPDFObjectHandle(std::shared_ptr<QPDFValueProxy> const& obj) :
|
QPDFObjectHandle(std::shared_ptr<QPDFObject> const& obj) :
|
||||||
obj(obj)
|
obj(obj)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1671,7 +1671,7 @@ class QPDFObjectHandle
|
||||||
// Moving members of QPDFObjectHandle into a smart pointer incurs
|
// Moving members of QPDFObjectHandle into a smart pointer incurs
|
||||||
// a substantial performance penalty since QPDFObjectHandle
|
// a substantial performance penalty since QPDFObjectHandle
|
||||||
// objects are copied around so frequently.
|
// objects are copied around so frequently.
|
||||||
std::shared_ptr<QPDFValueProxy> obj;
|
std::shared_ptr<QPDFObject> obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef QPDF_NO_QPDF_STRING
|
#ifndef QPDF_NO_QPDF_STRING
|
||||||
|
|
|
@ -2120,8 +2120,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
|
||||||
}
|
}
|
||||||
|
|
||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
QPDF::newIndirect(
|
QPDF::newIndirect(QPDFObjGen const& og, std::shared_ptr<QPDFObject> const& obj)
|
||||||
QPDFObjGen const& og, std::shared_ptr<QPDFValueProxy> const& obj)
|
|
||||||
{
|
{
|
||||||
obj->setObjGen(this, og);
|
obj->setObjGen(this, og);
|
||||||
if (!obj->hasDescription()) {
|
if (!obj->hasDescription()) {
|
||||||
|
@ -2133,7 +2132,7 @@ QPDF::newIndirect(
|
||||||
void
|
void
|
||||||
QPDF::updateCache(
|
QPDF::updateCache(
|
||||||
QPDFObjGen const& og,
|
QPDFObjGen const& og,
|
||||||
std::shared_ptr<QPDFValueProxy> const& object,
|
std::shared_ptr<QPDFObject> const& object,
|
||||||
qpdf_offset_t end_before_space,
|
qpdf_offset_t end_before_space,
|
||||||
qpdf_offset_t end_after_space)
|
qpdf_offset_t end_after_space)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,14 +4,14 @@
|
||||||
#include <qpdf/QPDF_Destroyed.hh>
|
#include <qpdf/QPDF_Destroyed.hh>
|
||||||
|
|
||||||
void
|
void
|
||||||
QPDFValueProxy::doResolve()
|
QPDFObject::doResolve()
|
||||||
{
|
{
|
||||||
auto og = value->og;
|
auto og = value->og;
|
||||||
QPDF::Resolver::resolve(value->qpdf, og);
|
QPDF::Resolver::resolve(value->qpdf, og);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QPDFValueProxy::destroy()
|
QPDFObject::destroy()
|
||||||
{
|
{
|
||||||
value = QPDF_Destroyed::getInstance();
|
value = QPDF_Destroyed::getInstance();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2287,7 +2287,7 @@ QPDFObjectHandle::copyObject(
|
||||||
" reserved object handle direct");
|
" reserved object handle direct");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy> new_obj;
|
std::shared_ptr<QPDFObject> new_obj;
|
||||||
|
|
||||||
if (isBool() || isInteger() || isName() || isNull() || isReal() ||
|
if (isBool() || isInteger() || isName() || isNull() || isReal() ||
|
||||||
isString()) {
|
isString()) {
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
#include <qpdf/QPDFObject_private.hh>
|
#include <qpdf/QPDFObject_private.hh>
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDFValue::do_create(QPDFValue* object)
|
QPDFValue::do_create(QPDFValue* object)
|
||||||
{
|
{
|
||||||
std::shared_ptr<QPDFValueProxy> obj(new QPDFValueProxy());
|
std::shared_ptr<QPDFObject> obj(new QPDFObject());
|
||||||
obj->value = std::shared_ptr<QPDFValue>(object);
|
obj->value = std::shared_ptr<QPDFValue>(object);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,19 +16,19 @@ QPDF_Array::QPDF_Array(SparseOHArray const& items) :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Array::create(std::vector<QPDFObjectHandle> const& items)
|
QPDF_Array::create(std::vector<QPDFObjectHandle> const& items)
|
||||||
{
|
{
|
||||||
return do_create(new QPDF_Array(items));
|
return do_create(new QPDF_Array(items));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Array::create(SparseOHArray const& items)
|
QPDF_Array::create(SparseOHArray const& items)
|
||||||
{
|
{
|
||||||
return do_create(new QPDF_Array(items));
|
return do_create(new QPDF_Array(items));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Array::shallowCopy()
|
QPDF_Array::shallowCopy()
|
||||||
{
|
{
|
||||||
return create(elements);
|
return create(elements);
|
||||||
|
|
|
@ -6,13 +6,13 @@ QPDF_Bool::QPDF_Bool(bool val) :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Bool::create(bool value)
|
QPDF_Bool::create(bool value)
|
||||||
{
|
{
|
||||||
return do_create(new QPDF_Bool(value));
|
return do_create(new QPDF_Bool(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Bool::shallowCopy()
|
QPDF_Bool::shallowCopy()
|
||||||
{
|
{
|
||||||
return create(val);
|
return create(val);
|
||||||
|
|
|
@ -14,7 +14,7 @@ QPDF_Destroyed::getInstance()
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Destroyed::shallowCopy()
|
QPDF_Destroyed::shallowCopy()
|
||||||
{
|
{
|
||||||
throw std::logic_error(
|
throw std::logic_error(
|
||||||
|
|
|
@ -9,13 +9,13 @@ QPDF_Dictionary::QPDF_Dictionary(
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Dictionary::create(std::map<std::string, QPDFObjectHandle> const& items)
|
QPDF_Dictionary::create(std::map<std::string, QPDFObjectHandle> const& items)
|
||||||
{
|
{
|
||||||
return do_create(new QPDF_Dictionary(items));
|
return do_create(new QPDF_Dictionary(items));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Dictionary::shallowCopy()
|
QPDF_Dictionary::shallowCopy()
|
||||||
{
|
{
|
||||||
return create(items);
|
return create(items);
|
||||||
|
|
|
@ -6,13 +6,13 @@ QPDF_InlineImage::QPDF_InlineImage(std::string const& val) :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_InlineImage::create(std::string const& val)
|
QPDF_InlineImage::create(std::string const& val)
|
||||||
{
|
{
|
||||||
return do_create(new QPDF_InlineImage(val));
|
return do_create(new QPDF_InlineImage(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_InlineImage::shallowCopy()
|
QPDF_InlineImage::shallowCopy()
|
||||||
{
|
{
|
||||||
return create(val);
|
return create(val);
|
||||||
|
|
|
@ -8,13 +8,13 @@ QPDF_Integer::QPDF_Integer(long long val) :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Integer::create(long long value)
|
QPDF_Integer::create(long long value)
|
||||||
{
|
{
|
||||||
return do_create(new QPDF_Integer(value));
|
return do_create(new QPDF_Integer(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Integer::shallowCopy()
|
QPDF_Integer::shallowCopy()
|
||||||
{
|
{
|
||||||
return create(val);
|
return create(val);
|
||||||
|
|
|
@ -10,13 +10,13 @@ QPDF_Name::QPDF_Name(std::string const& name) :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Name::create(std::string const& name)
|
QPDF_Name::create(std::string const& name)
|
||||||
{
|
{
|
||||||
return do_create(new QPDF_Name(name));
|
return do_create(new QPDF_Name(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Name::shallowCopy()
|
QPDF_Name::shallowCopy()
|
||||||
{
|
{
|
||||||
return create(name);
|
return create(name);
|
||||||
|
|
|
@ -5,13 +5,13 @@ QPDF_Null::QPDF_Null() :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Null::create()
|
QPDF_Null::create()
|
||||||
{
|
{
|
||||||
return do_create(new QPDF_Null());
|
return do_create(new QPDF_Null());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Null::shallowCopy()
|
QPDF_Null::shallowCopy()
|
||||||
{
|
{
|
||||||
return create();
|
return create();
|
||||||
|
|
|
@ -6,13 +6,13 @@ QPDF_Operator::QPDF_Operator(std::string const& val) :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Operator::create(std::string const& val)
|
QPDF_Operator::create(std::string const& val)
|
||||||
{
|
{
|
||||||
return do_create(new QPDF_Operator(val));
|
return do_create(new QPDF_Operator(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Operator::shallowCopy()
|
QPDF_Operator::shallowCopy()
|
||||||
{
|
{
|
||||||
return create(val);
|
return create(val);
|
||||||
|
|
|
@ -15,20 +15,20 @@ QPDF_Real::QPDF_Real(
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Real::create(std::string const& val)
|
QPDF_Real::create(std::string const& val)
|
||||||
{
|
{
|
||||||
return do_create(new QPDF_Real(val));
|
return do_create(new QPDF_Real(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Real::create(double value, int decimal_places, bool trim_trailing_zeroes)
|
QPDF_Real::create(double value, int decimal_places, bool trim_trailing_zeroes)
|
||||||
{
|
{
|
||||||
return do_create(
|
return do_create(
|
||||||
new QPDF_Real(value, decimal_places, trim_trailing_zeroes));
|
new QPDF_Real(value, decimal_places, trim_trailing_zeroes));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Real::shallowCopy()
|
QPDF_Real::shallowCopy()
|
||||||
{
|
{
|
||||||
return create(val);
|
return create(val);
|
||||||
|
|
|
@ -7,13 +7,13 @@ QPDF_Reserved::QPDF_Reserved() :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Reserved::create()
|
QPDF_Reserved::create()
|
||||||
{
|
{
|
||||||
return do_create(new QPDF_Reserved());
|
return do_create(new QPDF_Reserved());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Reserved::shallowCopy()
|
QPDF_Reserved::shallowCopy()
|
||||||
{
|
{
|
||||||
return create();
|
return create();
|
||||||
|
|
|
@ -130,7 +130,7 @@ QPDF_Stream::QPDF_Stream(
|
||||||
qpdf, qpdf->getFilename() + ", stream object " + og.unparse(' '));
|
qpdf, qpdf->getFilename() + ", stream object " + og.unparse(' '));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Stream::create(
|
QPDF_Stream::create(
|
||||||
QPDF* qpdf,
|
QPDF* qpdf,
|
||||||
QPDFObjGen const& og,
|
QPDFObjGen const& og,
|
||||||
|
@ -141,7 +141,7 @@ QPDF_Stream::create(
|
||||||
return do_create(new QPDF_Stream(qpdf, og, stream_dict, offset, length));
|
return do_create(new QPDF_Stream(qpdf, og, stream_dict, offset, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Stream::shallowCopy()
|
QPDF_Stream::shallowCopy()
|
||||||
{
|
{
|
||||||
throw std::logic_error("stream objects cannot be cloned");
|
throw std::logic_error("stream objects cannot be cloned");
|
||||||
|
|
|
@ -26,13 +26,13 @@ QPDF_String::QPDF_String(std::string const& val) :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_String::create(std::string const& val)
|
QPDF_String::create(std::string const& val)
|
||||||
{
|
{
|
||||||
return do_create(new QPDF_String(val));
|
return do_create(new QPDF_String(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_String::create_utf16(std::string const& utf8_val)
|
QPDF_String::create_utf16(std::string const& utf8_val)
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
|
@ -42,7 +42,7 @@ QPDF_String::create_utf16(std::string const& utf8_val)
|
||||||
return do_create(new QPDF_String(result));
|
return do_create(new QPDF_String(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_String::shallowCopy()
|
QPDF_String::shallowCopy()
|
||||||
{
|
{
|
||||||
return create(val);
|
return create(val);
|
||||||
|
|
|
@ -7,13 +7,13 @@ QPDF_Unresolved::QPDF_Unresolved(QPDF* qpdf, QPDFObjGen const& og) :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Unresolved::create(QPDF* qpdf, QPDFObjGen const& og)
|
QPDF_Unresolved::create(QPDF* qpdf, QPDFObjGen const& og)
|
||||||
{
|
{
|
||||||
return do_create(new QPDF_Unresolved(qpdf, og));
|
return do_create(new QPDF_Unresolved(qpdf, og));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
QPDF_Unresolved::shallowCopy()
|
QPDF_Unresolved::shallowCopy()
|
||||||
{
|
{
|
||||||
throw std::logic_error(
|
throw std::logic_error(
|
||||||
|
|
|
@ -16,14 +16,14 @@
|
||||||
class QPDF;
|
class QPDF;
|
||||||
class QPDFObjectHandle;
|
class QPDFObjectHandle;
|
||||||
|
|
||||||
class QPDFValueProxy
|
class QPDFObject
|
||||||
{
|
{
|
||||||
friend class QPDFValue;
|
friend class QPDFValue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QPDFValueProxy() = default;
|
QPDFObject() = default;
|
||||||
|
|
||||||
std::shared_ptr<QPDFValueProxy>
|
std::shared_ptr<QPDFObject>
|
||||||
shallowCopy()
|
shallowCopy()
|
||||||
{
|
{
|
||||||
return value->shallowCopy();
|
return value->shallowCopy();
|
||||||
|
@ -91,12 +91,12 @@ class QPDFValueProxy
|
||||||
return value->getParsedOffset();
|
return value->getParsedOffset();
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
assign(std::shared_ptr<QPDFValueProxy> o)
|
assign(std::shared_ptr<QPDFObject> o)
|
||||||
{
|
{
|
||||||
value = o->value;
|
value = o->value;
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
swapWith(std::shared_ptr<QPDFValueProxy> o)
|
swapWith(std::shared_ptr<QPDFObject> o)
|
||||||
{
|
{
|
||||||
auto v = value;
|
auto v = value;
|
||||||
value = o->value;
|
value = o->value;
|
||||||
|
@ -148,8 +148,8 @@ class QPDFValueProxy
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPDFValueProxy(QPDFValueProxy const&) = delete;
|
QPDFObject(QPDFObject const&) = delete;
|
||||||
QPDFValueProxy& operator=(QPDFValueProxy const&) = delete;
|
QPDFObject& operator=(QPDFObject const&) = delete;
|
||||||
std::shared_ptr<QPDFValue> value;
|
std::shared_ptr<QPDFValue> value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,16 +11,16 @@
|
||||||
|
|
||||||
class QPDF;
|
class QPDF;
|
||||||
class QPDFObjectHandle;
|
class QPDFObjectHandle;
|
||||||
class QPDFValueProxy;
|
class QPDFObject;
|
||||||
|
|
||||||
class QPDFValue
|
class QPDFValue
|
||||||
{
|
{
|
||||||
friend class QPDFValueProxy;
|
friend class QPDFObject;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~QPDFValue() = default;
|
virtual ~QPDFValue() = default;
|
||||||
|
|
||||||
virtual std::shared_ptr<QPDFValueProxy> shallowCopy() = 0;
|
virtual std::shared_ptr<QPDFObject> shallowCopy() = 0;
|
||||||
virtual std::string unparse() = 0;
|
virtual std::string unparse() = 0;
|
||||||
virtual JSON getJSON(int json_version) = 0;
|
virtual JSON getJSON(int json_version) = 0;
|
||||||
virtual void
|
virtual void
|
||||||
|
@ -91,7 +91,7 @@ class QPDFValue
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::shared_ptr<QPDFValueProxy> do_create(QPDFValue*);
|
static std::shared_ptr<QPDFObject> do_create(QPDFValue*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPDFValue(QPDFValue const&) = delete;
|
QPDFValue(QPDFValue const&) = delete;
|
||||||
|
|
|
@ -11,10 +11,10 @@ class QPDF_Array: public QPDFValue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~QPDF_Array() = default;
|
virtual ~QPDF_Array() = default;
|
||||||
static std::shared_ptr<QPDFValueProxy>
|
static std::shared_ptr<QPDFObject>
|
||||||
create(std::vector<QPDFObjectHandle> const& items);
|
create(std::vector<QPDFObjectHandle> const& items);
|
||||||
static std::shared_ptr<QPDFValueProxy> create(SparseOHArray const& items);
|
static std::shared_ptr<QPDFObject> create(SparseOHArray const& items);
|
||||||
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
|
virtual std::shared_ptr<QPDFObject> shallowCopy();
|
||||||
virtual std::string unparse();
|
virtual std::string unparse();
|
||||||
virtual JSON getJSON(int json_version);
|
virtual JSON getJSON(int json_version);
|
||||||
virtual void disconnect();
|
virtual void disconnect();
|
||||||
|
|
|
@ -7,8 +7,8 @@ class QPDF_Bool: public QPDFValue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~QPDF_Bool() = default;
|
virtual ~QPDF_Bool() = default;
|
||||||
static std::shared_ptr<QPDFValueProxy> create(bool val);
|
static std::shared_ptr<QPDFObject> create(bool val);
|
||||||
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
|
virtual std::shared_ptr<QPDFObject> shallowCopy();
|
||||||
virtual std::string unparse();
|
virtual std::string unparse();
|
||||||
virtual JSON getJSON(int json_version);
|
virtual JSON getJSON(int json_version);
|
||||||
bool getVal() const;
|
bool getVal() const;
|
||||||
|
|
|
@ -7,7 +7,7 @@ class QPDF_Destroyed: public QPDFValue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~QPDF_Destroyed() = default;
|
virtual ~QPDF_Destroyed() = default;
|
||||||
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
|
virtual std::shared_ptr<QPDFObject> shallowCopy();
|
||||||
virtual std::string unparse();
|
virtual std::string unparse();
|
||||||
virtual JSON getJSON(int json_version);
|
virtual JSON getJSON(int json_version);
|
||||||
static std::shared_ptr<QPDFValue> getInstance();
|
static std::shared_ptr<QPDFValue> getInstance();
|
||||||
|
|
|
@ -12,9 +12,9 @@ class QPDF_Dictionary: public QPDFValue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~QPDF_Dictionary() = default;
|
virtual ~QPDF_Dictionary() = default;
|
||||||
static std::shared_ptr<QPDFValueProxy>
|
static std::shared_ptr<QPDFObject>
|
||||||
create(std::map<std::string, QPDFObjectHandle> const& items);
|
create(std::map<std::string, QPDFObjectHandle> const& items);
|
||||||
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
|
virtual std::shared_ptr<QPDFObject> shallowCopy();
|
||||||
virtual std::string unparse();
|
virtual std::string unparse();
|
||||||
virtual JSON getJSON(int json_version);
|
virtual JSON getJSON(int json_version);
|
||||||
virtual void disconnect();
|
virtual void disconnect();
|
||||||
|
|
|
@ -7,8 +7,8 @@ class QPDF_InlineImage: public QPDFValue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~QPDF_InlineImage() = default;
|
virtual ~QPDF_InlineImage() = default;
|
||||||
static std::shared_ptr<QPDFValueProxy> create(std::string const& val);
|
static std::shared_ptr<QPDFObject> create(std::string const& val);
|
||||||
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
|
virtual std::shared_ptr<QPDFObject> shallowCopy();
|
||||||
virtual std::string unparse();
|
virtual std::string unparse();
|
||||||
virtual JSON getJSON(int json_version);
|
virtual JSON getJSON(int json_version);
|
||||||
std::string getVal() const;
|
std::string getVal() const;
|
||||||
|
|
|
@ -7,8 +7,8 @@ class QPDF_Integer: public QPDFValue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~QPDF_Integer() = default;
|
virtual ~QPDF_Integer() = default;
|
||||||
static std::shared_ptr<QPDFValueProxy> create(long long value);
|
static std::shared_ptr<QPDFObject> create(long long value);
|
||||||
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
|
virtual std::shared_ptr<QPDFObject> shallowCopy();
|
||||||
virtual std::string unparse();
|
virtual std::string unparse();
|
||||||
virtual JSON getJSON(int json_version);
|
virtual JSON getJSON(int json_version);
|
||||||
long long getVal() const;
|
long long getVal() const;
|
||||||
|
|
|
@ -7,8 +7,8 @@ class QPDF_Name: public QPDFValue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~QPDF_Name() = default;
|
virtual ~QPDF_Name() = default;
|
||||||
static std::shared_ptr<QPDFValueProxy> create(std::string const& name);
|
static std::shared_ptr<QPDFObject> create(std::string const& name);
|
||||||
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
|
virtual std::shared_ptr<QPDFObject> shallowCopy();
|
||||||
virtual std::string unparse();
|
virtual std::string unparse();
|
||||||
virtual JSON getJSON(int json_version);
|
virtual JSON getJSON(int json_version);
|
||||||
std::string getName() const;
|
std::string getName() const;
|
||||||
|
|
|
@ -7,8 +7,8 @@ class QPDF_Null: public QPDFValue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~QPDF_Null() = default;
|
virtual ~QPDF_Null() = default;
|
||||||
static std::shared_ptr<QPDFValueProxy> create();
|
static std::shared_ptr<QPDFObject> create();
|
||||||
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
|
virtual std::shared_ptr<QPDFObject> shallowCopy();
|
||||||
virtual std::string unparse();
|
virtual std::string unparse();
|
||||||
virtual JSON getJSON(int json_version);
|
virtual JSON getJSON(int json_version);
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ class QPDF_Operator: public QPDFValue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~QPDF_Operator() = default;
|
virtual ~QPDF_Operator() = default;
|
||||||
static std::shared_ptr<QPDFValueProxy> create(std::string const& val);
|
static std::shared_ptr<QPDFObject> create(std::string const& val);
|
||||||
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
|
virtual std::shared_ptr<QPDFObject> shallowCopy();
|
||||||
virtual std::string unparse();
|
virtual std::string unparse();
|
||||||
virtual JSON getJSON(int json_version);
|
virtual JSON getJSON(int json_version);
|
||||||
std::string getVal() const;
|
std::string getVal() const;
|
||||||
|
|
|
@ -7,10 +7,10 @@ class QPDF_Real: public QPDFValue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~QPDF_Real() = default;
|
virtual ~QPDF_Real() = default;
|
||||||
static std::shared_ptr<QPDFValueProxy> create(std::string const& val);
|
static std::shared_ptr<QPDFObject> create(std::string const& val);
|
||||||
static std::shared_ptr<QPDFValueProxy>
|
static std::shared_ptr<QPDFObject>
|
||||||
create(double value, int decimal_places, bool trim_trailing_zeroes);
|
create(double value, int decimal_places, bool trim_trailing_zeroes);
|
||||||
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
|
virtual std::shared_ptr<QPDFObject> shallowCopy();
|
||||||
virtual std::string unparse();
|
virtual std::string unparse();
|
||||||
virtual JSON getJSON(int json_version);
|
virtual JSON getJSON(int json_version);
|
||||||
std::string getVal();
|
std::string getVal();
|
||||||
|
|
|
@ -7,8 +7,8 @@ class QPDF_Reserved: public QPDFValue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~QPDF_Reserved() = default;
|
virtual ~QPDF_Reserved() = default;
|
||||||
static std::shared_ptr<QPDFValueProxy> create();
|
static std::shared_ptr<QPDFObject> create();
|
||||||
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
|
virtual std::shared_ptr<QPDFObject> shallowCopy();
|
||||||
virtual std::string unparse();
|
virtual std::string unparse();
|
||||||
virtual JSON getJSON(int json_version);
|
virtual JSON getJSON(int json_version);
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,13 @@ class QPDF_Stream: public QPDFValue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~QPDF_Stream() = default;
|
virtual ~QPDF_Stream() = default;
|
||||||
static std::shared_ptr<QPDFValueProxy> create(
|
static std::shared_ptr<QPDFObject> create(
|
||||||
QPDF*,
|
QPDF*,
|
||||||
QPDFObjGen const& og,
|
QPDFObjGen const& og,
|
||||||
QPDFObjectHandle stream_dict,
|
QPDFObjectHandle stream_dict,
|
||||||
qpdf_offset_t offset,
|
qpdf_offset_t offset,
|
||||||
size_t length);
|
size_t length);
|
||||||
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
|
virtual std::shared_ptr<QPDFObject> shallowCopy();
|
||||||
virtual std::string unparse();
|
virtual std::string unparse();
|
||||||
virtual JSON getJSON(int json_version);
|
virtual JSON getJSON(int json_version);
|
||||||
virtual void setDescription(QPDF*, std::string const&);
|
virtual void setDescription(QPDF*, std::string const&);
|
||||||
|
|
|
@ -11,10 +11,10 @@ class QPDF_String: public QPDFValue
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~QPDF_String() = default;
|
virtual ~QPDF_String() = default;
|
||||||
static std::shared_ptr<QPDFValueProxy> create(std::string const& val);
|
static std::shared_ptr<QPDFObject> create(std::string const& val);
|
||||||
static std::shared_ptr<QPDFValueProxy>
|
static std::shared_ptr<QPDFObject>
|
||||||
create_utf16(std::string const& utf8_val);
|
create_utf16(std::string const& utf8_val);
|
||||||
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
|
virtual std::shared_ptr<QPDFObject> shallowCopy();
|
||||||
virtual std::string unparse();
|
virtual std::string unparse();
|
||||||
std::string unparse(bool force_binary);
|
std::string unparse(bool force_binary);
|
||||||
virtual JSON getJSON(int json_version);
|
virtual JSON getJSON(int json_version);
|
||||||
|
|
|
@ -7,9 +7,8 @@ class QPDF_Unresolved: public QPDFValue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~QPDF_Unresolved() = default;
|
virtual ~QPDF_Unresolved() = default;
|
||||||
static std::shared_ptr<QPDFValueProxy>
|
static std::shared_ptr<QPDFObject> create(QPDF* qpdf, QPDFObjGen const& og);
|
||||||
create(QPDF* qpdf, QPDFObjGen const& og);
|
virtual std::shared_ptr<QPDFObject> shallowCopy();
|
||||||
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
|
|
||||||
virtual std::string unparse();
|
virtual std::string unparse();
|
||||||
virtual JSON getJSON(int json_version);
|
virtual JSON getJSON(int json_version);
|
||||||
|
|
||||||
|
|
|
@ -349,18 +349,18 @@ Objects in qpdf 11 and Newer
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
The object cache in ``QPDF`` contains a shared pointer to
|
The object cache in ``QPDF`` contains a shared pointer to
|
||||||
``QPDFValueProxy``. Any ``QPDFObjectHandle`` resolved from an indirect
|
``QPDFObject``. Any ``QPDFObjectHandle`` resolved from an indirect
|
||||||
reference to that object has a copy of that shared pointer. Each
|
reference to that object has a copy of that shared pointer. Each
|
||||||
``QPDFValueProxy`` object contains a shared pointer to an object of
|
``QPDFObject`` object contains a shared pointer to an object of type
|
||||||
type ``QPDFValue``. The ``QPDFValue`` type is an abstract base class.
|
``QPDFValue``. The ``QPDFValue`` type is an abstract base class. There
|
||||||
There is an implementation for each of the basic object types (array,
|
is an implementation for each of the basic object types (array,
|
||||||
dictionary, null, boolean, string, number, etc.) as well as a few
|
dictionary, null, boolean, string, number, etc.) as well as a few
|
||||||
special ones including ``uninitialized``, ``unresolved``, and
|
special ones including ``uninitialized``, ``unresolved``,
|
||||||
``reserved``. When an object is first referenced, its underlying
|
``reserved``, and ``destroyed``. When an object is first referenced,
|
||||||
``QPDFValue`` has type ``unresolved``. When the object is first
|
its underlying ``QPDFValue`` has type ``unresolved``. When the object
|
||||||
resolved, the ``QPDFValueProxy`` in the cache has its internal
|
is first resolved, the ``QPDFObject`` in the cache has its internal
|
||||||
``QPDFValue`` replaced with the object as read from the file. Since it
|
``QPDFValue`` replaced with the object as read from the file. Since it
|
||||||
is the ``QPDFValueProxy`` object that is shared by all referencing
|
is the ``QPDFObject`` object that is shared by all referencing
|
||||||
``QPDFObjectHandle`` objects as well as by the owning ``QPDF`` object,
|
``QPDFObjectHandle`` objects as well as by the owning ``QPDF`` object,
|
||||||
this ensures that any future changes to the object, including
|
this ensures that any future changes to the object, including
|
||||||
replacing the object with a completely different one, will be
|
replacing the object with a completely different one, will be
|
||||||
|
@ -368,22 +368,24 @@ reflected across all ``QPDFObjectHandle`` objects that reference it.
|
||||||
|
|
||||||
A ``QPDFValue`` that originated from a PDF input source maintains a
|
A ``QPDFValue`` that originated from a PDF input source maintains a
|
||||||
pointer to the ``QPDF`` object that read it (its *owner*). When that
|
pointer to the ``QPDF`` object that read it (its *owner*). When that
|
||||||
``QPDF`` object is destroyed, it replaces the value of each
|
``QPDF`` object is destroyed, it disconnects all reachable from it by
|
||||||
``QPDFValueProxy`` in its cache with a direct ``null`` object and
|
clearing their owner. For indirect objects (all objects in the object
|
||||||
clears the pointer to the owning ``QPDF``. This means that, if there
|
cache), it also replaces the object's value with an object of type
|
||||||
are still any referencing ``QPDFObjectHandle`` objects floating
|
``destroyed``. This means that, if there are still any referencing
|
||||||
around, requesting their owning ``QPDF`` will return a null pointer
|
``QPDFObjectHandle`` objects floating around, requesting their owning
|
||||||
rather than a pointer to a ``QPDF`` object that is either invalid or
|
``QPDF`` will return a null pointer rather than a pointer to a
|
||||||
points to something else. This operation also has the effect of
|
``QPDF`` object that is either invalid or points to something else,
|
||||||
breaking any circular references (which are common and, in some cases,
|
and any attempt to access an indirect object that is associated with a
|
||||||
required by the PDF specification), thus preventing memory leaks when
|
destroyed ``QPDF`` object will throw an exception. This operation also
|
||||||
``QPDF`` objects are destroyed.
|
has the effect of breaking any circular references (which are common
|
||||||
|
and, in some cases, required by the PDF specification), thus
|
||||||
|
preventing memory leaks when ``QPDF`` objects are destroyed.
|
||||||
|
|
||||||
Objects prior to qpdf 11
|
Objects prior to qpdf 11
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Prior to qpdf 11, the functionality of the ``QPDFValue`` and
|
Prior to qpdf 11, the functionality of the ``QPDFValue`` and
|
||||||
``QPDFValueProxy`` classes were combined into a single ``QPDFObject``
|
``QPDFObject`` classes were contained in a single ``QPDFObject``
|
||||||
class, which served the dual purpose of being the cache entry for
|
class, which served the dual purpose of being the cache entry for
|
||||||
``QPDF`` and being the abstract base class for all the different PDF
|
``QPDF`` and being the abstract base class for all the different PDF
|
||||||
object types. The behavior was nearly the same, but there were a few
|
object types. The behavior was nearly the same, but there were a few
|
||||||
|
@ -415,7 +417,7 @@ problems:
|
||||||
was still valid.
|
was still valid.
|
||||||
|
|
||||||
All of these problems were effectively solved by splitting
|
All of these problems were effectively solved by splitting
|
||||||
``QPDFObject`` into ``QPDFValueProxy`` and ``QPDFValue``.
|
``QPDFObject`` into ``QPDFObject`` and ``QPDFValue``.
|
||||||
|
|
||||||
.. _casting:
|
.. _casting:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user