Rename QPDFObject -> QPDFValueProxy

This is in preparation for restoring a QPDFObject.hh to ease the
transition on qpdf_object_type_e.

This commit was created by
* Renaming QPDFObject.cc and QPDFObject.hh
* Replacing QPDFObject\b with QPDFValueProxy (where \b is word
  boundary)
* Running format-code
* Manually resorting files in libqpdf/CMakeLists.txt
* Manually refilling the comment in QPDF.hh near class Resolver
This commit is contained in:
Jay Berkenbilt 2022-09-05 09:15:14 -04:00
parent 5d65e73ca7
commit 6c61be00e8
36 changed files with 99 additions and 95 deletions

View File

@ -300,6 +300,7 @@
"nodefaultlib",
"noout",
"notfound",
"nowarn",
"npages",
"nproc",
"nrounds",
@ -423,6 +424,7 @@
"qpdftypes",
"qpdfusage",
"qpdfvalue",
"qpdfvalueproxy",
"qpdfwriter",
"qpdfx",
"qpdfxrefentry",

View File

@ -842,11 +842,11 @@ class QPDF
}
};
// Resolver class is restricted to QPDFObject so that only it can
// resolve indirect references.
// Resolver class is restricted to QPDFValueProxy so that only it
// can resolve indirect references.
class Resolver
{
friend class QPDFObject;
friend class QPDFValueProxy;
private:
static void
@ -952,7 +952,7 @@ class QPDF
{
}
ObjCache(
std::shared_ptr<QPDFObject> object,
std::shared_ptr<QPDFValueProxy> object,
qpdf_offset_t end_before_space,
qpdf_offset_t end_after_space) :
object(object),
@ -961,7 +961,7 @@ class QPDF
{
}
std::shared_ptr<QPDFObject> object;
std::shared_ptr<QPDFValueProxy> object;
qpdf_offset_t end_before_space;
qpdf_offset_t end_after_space;
};
@ -1186,12 +1186,12 @@ class QPDF
QPDFObjectHandle reserveObjectIfNotExists(QPDFObjGen const& og);
QPDFObjectHandle reserveStream(QPDFObjGen const& og);
QPDFObjectHandle
newIndirect(QPDFObjGen const&, std::shared_ptr<QPDFObject> const&);
newIndirect(QPDFObjGen const&, std::shared_ptr<QPDFValueProxy> const&);
bool isCached(QPDFObjGen const& og);
bool isUnresolved(QPDFObjGen const& og);
void updateCache(
QPDFObjGen const& og,
std::shared_ptr<QPDFObject> const& object,
std::shared_ptr<QPDFValueProxy> const& object,
qpdf_offset_t end_before_space,
qpdf_offset_t end_after_space);

View File

@ -54,7 +54,7 @@ class QPDF_Real;
class QPDF_Reserved;
class QPDF_Stream;
class QPDF_String;
class QPDFObject;
class QPDFValueProxy;
class QPDFTokenizer;
class QPDFExc;
class Pl_QPDFTokenizer;
@ -1453,7 +1453,7 @@ class QPDFObjectHandle
private:
static QPDFObjectHandle
newIndirect(std::shared_ptr<QPDFObject> const& obj)
newIndirect(std::shared_ptr<QPDFValueProxy> const& obj)
{
return QPDFObjectHandle(obj);
}
@ -1478,7 +1478,7 @@ class QPDFObjectHandle
friend class QPDF;
private:
static std::shared_ptr<QPDFObject>
static std::shared_ptr<QPDFValueProxy>
getObject(QPDFObjectHandle& o)
{
if (!o.dereference()) {
@ -1560,7 +1560,7 @@ class QPDFObjectHandle
bool isImage(bool exclude_imagemask = true);
private:
QPDFObjectHandle(std::shared_ptr<QPDFObject> const& obj) :
QPDFObjectHandle(std::shared_ptr<QPDFValueProxy> const& obj) :
obj(obj)
{
}
@ -1613,7 +1613,7 @@ class QPDFObjectHandle
// Moving members of QPDFObjectHandle into a smart pointer incurs
// a substantial performance penalty since QPDFObjectHandle
// objects are copied around so frequently.
std::shared_ptr<QPDFObject> obj;
std::shared_ptr<QPDFValueProxy> obj;
};
#ifndef QPDF_NO_QPDF_STRING

View File

@ -72,7 +72,6 @@ set(libqpdf_SOURCES
QPDFMatrix.cc
QPDFNameTreeObjectHelper.cc
QPDFNumberTreeObjectHelper.cc
QPDFObject.cc
QPDFObjectHandle.cc
QPDFObjGen.cc
QPDFOutlineDocumentHelper.cc
@ -86,6 +85,7 @@ set(libqpdf_SOURCES
QPDFTokenizer.cc
QPDFUsage.cc
QPDFValue.cc
QPDFValueProxy.cc
QPDFWriter.cc
QPDFXRefEntry.cc
QPDF_Array.cc

View File

@ -21,7 +21,7 @@
#include <qpdf/Pl_OStream.hh>
#include <qpdf/QPDFExc.hh>
#include <qpdf/QPDFLogger.hh>
#include <qpdf/QPDFObject.hh>
#include <qpdf/QPDFValueProxy.hh>
#include <qpdf/QPDF_Array.hh>
#include <qpdf/QPDF_Dictionary.hh>
#include <qpdf/QPDF_Null.hh>
@ -2114,7 +2114,8 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
}
QPDFObjectHandle
QPDF::newIndirect(QPDFObjGen const& og, std::shared_ptr<QPDFObject> const& obj)
QPDF::newIndirect(
QPDFObjGen const& og, std::shared_ptr<QPDFValueProxy> const& obj)
{
obj->setObjGen(this, og);
if (!obj->hasDescription()) {
@ -2126,7 +2127,7 @@ QPDF::newIndirect(QPDFObjGen const& og, std::shared_ptr<QPDFObject> const& obj)
void
QPDF::updateCache(
QPDFObjGen const& og,
std::shared_ptr<QPDFObject> const& object,
std::shared_ptr<QPDFValueProxy> const& object,
qpdf_offset_t end_before_space,
qpdf_offset_t end_after_space)
{

View File

@ -7,9 +7,9 @@
#include <qpdf/QPDFExc.hh>
#include <qpdf/QPDFLogger.hh>
#include <qpdf/QPDFMatrix.hh>
#include <qpdf/QPDFObject.hh>
#include <qpdf/QPDFPageObjectHelper.hh>
#include <qpdf/QPDFParser.hh>
#include <qpdf/QPDFValueProxy.hh>
#include <qpdf/QPDF_Array.hh>
#include <qpdf/QPDF_Bool.hh>
#include <qpdf/QPDF_Dictionary.hh>
@ -2257,7 +2257,7 @@ QPDFObjectHandle::copyObject(
" reserved object handle direct");
}
std::shared_ptr<QPDFObject> new_obj;
std::shared_ptr<QPDFValueProxy> new_obj;
if (isBool() || isInteger() || isName() || isNull() || isReal() ||
isString()) {

View File

@ -1,11 +1,11 @@
#include <qpdf/QPDFValue.hh>
#include <qpdf/QPDFObject.hh>
#include <qpdf/QPDFValueProxy.hh>
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDFValue::do_create(QPDFValue* object)
{
std::shared_ptr<QPDFObject> obj(new QPDFObject());
std::shared_ptr<QPDFValueProxy> obj(new QPDFValueProxy());
obj->value = std::shared_ptr<QPDFValue>(object);
return obj;
}

View File

@ -1,9 +1,9 @@
#include <qpdf/QPDFObject.hh>
#include <qpdf/QPDFValueProxy.hh>
#include <qpdf/QPDF.hh>
void
QPDFObject::doResolve()
QPDFValueProxy::doResolve()
{
auto og = value->og;
QPDF::Resolver::resolve(value->qpdf, og);

View File

@ -16,19 +16,19 @@ QPDF_Array::QPDF_Array(SparseOHArray const& items) :
{
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Array::create(std::vector<QPDFObjectHandle> const& items)
{
return do_create(new QPDF_Array(items));
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Array::create(SparseOHArray const& items)
{
return do_create(new QPDF_Array(items));
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Array::shallowCopy()
{
return create(elements);

View File

@ -6,13 +6,13 @@ QPDF_Bool::QPDF_Bool(bool val) :
{
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Bool::create(bool value)
{
return do_create(new QPDF_Bool(value));
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Bool::shallowCopy()
{
return create(val);

View File

@ -9,13 +9,13 @@ QPDF_Dictionary::QPDF_Dictionary(
{
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Dictionary::create(std::map<std::string, QPDFObjectHandle> const& items)
{
return do_create(new QPDF_Dictionary(items));
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Dictionary::shallowCopy()
{
return create(items);

View File

@ -6,13 +6,13 @@ QPDF_InlineImage::QPDF_InlineImage(std::string const& val) :
{
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_InlineImage::create(std::string const& val)
{
return do_create(new QPDF_InlineImage(val));
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_InlineImage::shallowCopy()
{
return create(val);

View File

@ -8,13 +8,13 @@ QPDF_Integer::QPDF_Integer(long long val) :
{
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Integer::create(long long value)
{
return do_create(new QPDF_Integer(value));
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Integer::shallowCopy()
{
return create(val);

View File

@ -10,13 +10,13 @@ QPDF_Name::QPDF_Name(std::string const& name) :
{
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Name::create(std::string const& name)
{
return do_create(new QPDF_Name(name));
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Name::shallowCopy()
{
return create(name);

View File

@ -5,13 +5,13 @@ QPDF_Null::QPDF_Null() :
{
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Null::create()
{
return do_create(new QPDF_Null());
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Null::shallowCopy()
{
return create();

View File

@ -6,13 +6,13 @@ QPDF_Operator::QPDF_Operator(std::string const& val) :
{
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Operator::create(std::string const& val)
{
return do_create(new QPDF_Operator(val));
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Operator::shallowCopy()
{
return create(val);

View File

@ -15,20 +15,20 @@ QPDF_Real::QPDF_Real(
{
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Real::create(std::string const& val)
{
return do_create(new QPDF_Real(val));
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Real::create(double value, int decimal_places, bool trim_trailing_zeroes)
{
return do_create(
new QPDF_Real(value, decimal_places, trim_trailing_zeroes));
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Real::shallowCopy()
{
return create(val);

View File

@ -7,13 +7,13 @@ QPDF_Reserved::QPDF_Reserved() :
{
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Reserved::create()
{
return do_create(new QPDF_Reserved());
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Reserved::shallowCopy()
{
return create();

View File

@ -130,7 +130,7 @@ QPDF_Stream::QPDF_Stream(
qpdf, qpdf->getFilename() + ", stream object " + og.unparse(' '));
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Stream::create(
QPDF* qpdf,
QPDFObjGen const& og,
@ -141,7 +141,7 @@ QPDF_Stream::create(
return do_create(new QPDF_Stream(qpdf, og, stream_dict, offset, length));
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Stream::shallowCopy()
{
throw std::logic_error("stream objects cannot be cloned");

View File

@ -26,13 +26,13 @@ QPDF_String::QPDF_String(std::string const& val) :
{
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_String::create(std::string const& val)
{
return do_create(new QPDF_String(val));
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_String::create_utf16(std::string const& utf8_val)
{
std::string result;
@ -42,7 +42,7 @@ QPDF_String::create_utf16(std::string const& utf8_val)
return do_create(new QPDF_String(result));
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_String::shallowCopy()
{
return create(val);

View File

@ -7,13 +7,13 @@ QPDF_Unresolved::QPDF_Unresolved(QPDF* qpdf, QPDFObjGen const& og) :
{
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Unresolved::create(QPDF* qpdf, QPDFObjGen const& og)
{
return do_create(new QPDF_Unresolved(qpdf, og));
}
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
QPDF_Unresolved::shallowCopy()
{
throw std::logic_error(

View File

@ -11,16 +11,16 @@
class QPDF;
class QPDFObjectHandle;
class QPDFObject;
class QPDFValueProxy;
class QPDFValue
{
friend class QPDFObject;
friend class QPDFValueProxy;
public:
virtual ~QPDFValue() = default;
virtual std::shared_ptr<QPDFObject> shallowCopy() = 0;
virtual std::shared_ptr<QPDFValueProxy> shallowCopy() = 0;
virtual std::string unparse() = 0;
virtual JSON getJSON(int json_version) = 0;
virtual void
@ -87,7 +87,7 @@ class QPDFValue
{
}
static std::shared_ptr<QPDFObject> do_create(QPDFValue*);
static std::shared_ptr<QPDFValueProxy> do_create(QPDFValue*);
private:
QPDFValue(QPDFValue const&) = delete;

View File

@ -1,5 +1,5 @@
#ifndef QPDFOBJECT_HH
#define QPDFOBJECT_HH
#ifndef QPDFVALUEPROXY_HH
#define QPDFVALUEPROXY_HH
#include <qpdf/Constants.h>
#include <qpdf/DLL.h>
@ -12,14 +12,14 @@
class QPDF;
class QPDFObjectHandle;
class QPDFObject
class QPDFValueProxy
{
friend class QPDFValue;
public:
QPDFObject() = default;
QPDFValueProxy() = default;
std::shared_ptr<QPDFObject>
std::shared_ptr<QPDFValueProxy>
shallowCopy()
{
return value->shallowCopy();
@ -87,12 +87,12 @@ class QPDFObject
return value->getParsedOffset();
}
void
assign(std::shared_ptr<QPDFObject> o)
assign(std::shared_ptr<QPDFValueProxy> o)
{
value = o->value;
}
void
swapWith(std::shared_ptr<QPDFObject> o)
swapWith(std::shared_ptr<QPDFValueProxy> o)
{
auto v = value;
value = o->value;
@ -138,9 +138,9 @@ class QPDFObject
}
private:
QPDFObject(QPDFObject const&) = delete;
QPDFObject& operator=(QPDFObject const&) = delete;
QPDFValueProxy(QPDFValueProxy const&) = delete;
QPDFValueProxy& operator=(QPDFValueProxy const&) = delete;
std::shared_ptr<QPDFValue> value;
};
#endif // QPDFOBJECT_HH
#endif // QPDFVALUEPROXY_HH

View File

@ -11,10 +11,10 @@ class QPDF_Array: public QPDFValue
{
public:
virtual ~QPDF_Array() = default;
static std::shared_ptr<QPDFObject>
static std::shared_ptr<QPDFValueProxy>
create(std::vector<QPDFObjectHandle> const& items);
static std::shared_ptr<QPDFObject> create(SparseOHArray const& items);
virtual std::shared_ptr<QPDFObject> shallowCopy();
static std::shared_ptr<QPDFValueProxy> create(SparseOHArray const& items);
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
virtual std::string unparse();
virtual JSON getJSON(int json_version);

View File

@ -7,8 +7,8 @@ class QPDF_Bool: public QPDFValue
{
public:
virtual ~QPDF_Bool() = default;
static std::shared_ptr<QPDFObject> create(bool val);
virtual std::shared_ptr<QPDFObject> shallowCopy();
static std::shared_ptr<QPDFValueProxy> create(bool val);
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
virtual std::string unparse();
virtual JSON getJSON(int json_version);
bool getVal() const;

View File

@ -12,9 +12,9 @@ class QPDF_Dictionary: public QPDFValue
{
public:
virtual ~QPDF_Dictionary() = default;
static std::shared_ptr<QPDFObject>
static std::shared_ptr<QPDFValueProxy>
create(std::map<std::string, QPDFObjectHandle> const& items);
virtual std::shared_ptr<QPDFObject> shallowCopy();
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
virtual std::string unparse();
virtual JSON getJSON(int json_version);

View File

@ -7,8 +7,8 @@ class QPDF_InlineImage: public QPDFValue
{
public:
virtual ~QPDF_InlineImage() = default;
static std::shared_ptr<QPDFObject> create(std::string const& val);
virtual std::shared_ptr<QPDFObject> shallowCopy();
static std::shared_ptr<QPDFValueProxy> create(std::string const& val);
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
virtual std::string unparse();
virtual JSON getJSON(int json_version);
std::string getVal() const;

View File

@ -7,8 +7,8 @@ class QPDF_Integer: public QPDFValue
{
public:
virtual ~QPDF_Integer() = default;
static std::shared_ptr<QPDFObject> create(long long value);
virtual std::shared_ptr<QPDFObject> shallowCopy();
static std::shared_ptr<QPDFValueProxy> create(long long value);
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
virtual std::string unparse();
virtual JSON getJSON(int json_version);
long long getVal() const;

View File

@ -7,8 +7,8 @@ class QPDF_Name: public QPDFValue
{
public:
virtual ~QPDF_Name() = default;
static std::shared_ptr<QPDFObject> create(std::string const& name);
virtual std::shared_ptr<QPDFObject> shallowCopy();
static std::shared_ptr<QPDFValueProxy> create(std::string const& name);
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
virtual std::string unparse();
virtual JSON getJSON(int json_version);
std::string getName() const;

View File

@ -7,8 +7,8 @@ class QPDF_Null: public QPDFValue
{
public:
virtual ~QPDF_Null() = default;
static std::shared_ptr<QPDFObject> create();
virtual std::shared_ptr<QPDFObject> shallowCopy();
static std::shared_ptr<QPDFValueProxy> create();
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
virtual std::string unparse();
virtual JSON getJSON(int json_version);

View File

@ -7,8 +7,8 @@ class QPDF_Operator: public QPDFValue
{
public:
virtual ~QPDF_Operator() = default;
static std::shared_ptr<QPDFObject> create(std::string const& val);
virtual std::shared_ptr<QPDFObject> shallowCopy();
static std::shared_ptr<QPDFValueProxy> create(std::string const& val);
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
virtual std::string unparse();
virtual JSON getJSON(int json_version);
std::string getVal() const;

View File

@ -7,10 +7,10 @@ class QPDF_Real: public QPDFValue
{
public:
virtual ~QPDF_Real() = default;
static std::shared_ptr<QPDFObject> create(std::string const& val);
static std::shared_ptr<QPDFObject>
static std::shared_ptr<QPDFValueProxy> create(std::string const& val);
static std::shared_ptr<QPDFValueProxy>
create(double value, int decimal_places, bool trim_trailing_zeroes);
virtual std::shared_ptr<QPDFObject> shallowCopy();
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
virtual std::string unparse();
virtual JSON getJSON(int json_version);
std::string getVal();

View File

@ -7,8 +7,8 @@ class QPDF_Reserved: public QPDFValue
{
public:
virtual ~QPDF_Reserved() = default;
static std::shared_ptr<QPDFObject> create();
virtual std::shared_ptr<QPDFObject> shallowCopy();
static std::shared_ptr<QPDFValueProxy> create();
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
virtual std::string unparse();
virtual JSON getJSON(int json_version);

View File

@ -17,13 +17,13 @@ class QPDF_Stream: public QPDFValue
{
public:
virtual ~QPDF_Stream() = default;
static std::shared_ptr<QPDFObject> create(
static std::shared_ptr<QPDFValueProxy> create(
QPDF*,
QPDFObjGen const& og,
QPDFObjectHandle stream_dict,
qpdf_offset_t offset,
size_t length);
virtual std::shared_ptr<QPDFObject> shallowCopy();
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
virtual std::string unparse();
virtual JSON getJSON(int json_version);
virtual void setDescription(QPDF*, std::string const&);

View File

@ -11,10 +11,10 @@ class QPDF_String: public QPDFValue
public:
virtual ~QPDF_String() = default;
static std::shared_ptr<QPDFObject> create(std::string const& val);
static std::shared_ptr<QPDFObject>
static std::shared_ptr<QPDFValueProxy> create(std::string const& val);
static std::shared_ptr<QPDFValueProxy>
create_utf16(std::string const& utf8_val);
virtual std::shared_ptr<QPDFObject> shallowCopy();
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
virtual std::string unparse();
std::string unparse(bool force_binary);
virtual JSON getJSON(int json_version);

View File

@ -7,8 +7,9 @@ class QPDF_Unresolved: public QPDFValue
{
public:
virtual ~QPDF_Unresolved() = default;
static std::shared_ptr<QPDFObject> create(QPDF* qpdf, QPDFObjGen const& og);
virtual std::shared_ptr<QPDFObject> shallowCopy();
static std::shared_ptr<QPDFValueProxy>
create(QPDF* qpdf, QPDFObjGen const& og);
virtual std::shared_ptr<QPDFValueProxy> shallowCopy();
virtual std::string unparse();
virtual JSON getJSON(int json_version);