From 25ccc7eae4b78e90d0fe6400abeba22ca4cd648e Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Thu, 8 Sep 2022 11:12:10 -0400 Subject: [PATCH] Rename QPDFValueProxy.hh and QPDFValueProxy.cc --- cSpell.json | 1 - include/qpdf/QPDFObject.hh | 18 ++++++++++++++---- libqpdf/CMakeLists.txt | 2 +- libqpdf/QPDF.cc | 2 +- libqpdf/QPDFObject.cc | 17 +++++++++++++++++ libqpdf/QPDFObjectHandle.cc | 2 +- libqpdf/QPDFValue.cc | 2 +- libqpdf/QPDFValueProxy.cc | 17 ----------------- libqpdf/qpdf/QPDFObject_private.hh | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ libqpdf/qpdf/QPDFValueProxy.hh | 152 -------------------------------------------------------------------------------------------------------------------------------------------------------- 10 files changed, 191 insertions(+), 178 deletions(-) create mode 100644 libqpdf/QPDFObject.cc delete mode 100644 libqpdf/QPDFValueProxy.cc create mode 100644 libqpdf/qpdf/QPDFObject_private.hh delete mode 100644 libqpdf/qpdf/QPDFValueProxy.hh diff --git a/cSpell.json b/cSpell.json index 3c78fc5..2e33690 100644 --- a/cSpell.json +++ b/cSpell.json @@ -425,7 +425,6 @@ "qpdftypes", "qpdfusage", "qpdfvalue", - "qpdfvalueproxy", "qpdfwriter", "qpdfx", "qpdfxrefentry", diff --git a/include/qpdf/QPDFObject.hh b/include/qpdf/QPDFObject.hh index 619f27f..b46b282 100644 --- a/include/qpdf/QPDFObject.hh +++ b/include/qpdf/QPDFObject.hh @@ -19,14 +19,24 @@ // continue to consider qpdf to be licensed under those terms. Please // see the manual for additional information. -#ifndef QPDFOBJECT_HH -#define QPDFOBJECT_HH +#ifndef QPDFOBJECT_OLD_HH +#define QPDFOBJECT_OLD_HH + +// ********************************************************************** +// +// This file is for backward compatibility. The header file for the +// internal QPDFObject class (not part of the public API) is in +// QPDFObject_private.hh (not installed). +// +// ********************************************************************** // ABI: in qpdf 12, leave this file in place and have it generate an // error. This is to prevent someone from being able to successfully // include this file and get a copy from a previous installation // thereby accidentally creating sources depend on having an older -// version installed. +// version installed. When enough time has passed, this file can be +// removed, and libqpdf/qpdf/QPDFObject_private.hh can be renamed to +// libqpdf/qpdf/QPDFObject.hh. #ifndef QPDF_OBJECT_NOWARN // ABI: remove this file in qpdf 12 @@ -66,4 +76,4 @@ class QPDFObject QPDFObject& operator=(QPDFObject const&) = delete; }; -#endif // QPDFOBJECT_HH +#endif // QPDFOBJECT_OLD_HH diff --git a/libqpdf/CMakeLists.txt b/libqpdf/CMakeLists.txt index 3084813..1323e60 100644 --- a/libqpdf/CMakeLists.txt +++ b/libqpdf/CMakeLists.txt @@ -72,6 +72,7 @@ set(libqpdf_SOURCES QPDFMatrix.cc QPDFNameTreeObjectHelper.cc QPDFNumberTreeObjectHelper.cc + QPDFObject.cc QPDFObjectHandle.cc QPDFObjGen.cc QPDFOutlineDocumentHelper.cc @@ -85,7 +86,6 @@ set(libqpdf_SOURCES QPDFTokenizer.cc QPDFUsage.cc QPDFValue.cc - QPDFValueProxy.cc QPDFWriter.cc QPDFXRefEntry.cc QPDF_Array.cc diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 1b1ee78..d56fb29 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/libqpdf/QPDFObject.cc b/libqpdf/QPDFObject.cc new file mode 100644 index 0000000..b5d073a --- /dev/null +++ b/libqpdf/QPDFObject.cc @@ -0,0 +1,17 @@ +#include + +#include +#include + +void +QPDFValueProxy::doResolve() +{ + auto og = value->og; + QPDF::Resolver::resolve(value->qpdf, og); +} + +void +QPDFValueProxy::destroy() +{ + value = QPDF_Destroyed::getInstance(); +} diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index d31af88..ab54b80 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -7,9 +7,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/libqpdf/QPDFValue.cc b/libqpdf/QPDFValue.cc index 957cc35..99fd77d 100644 --- a/libqpdf/QPDFValue.cc +++ b/libqpdf/QPDFValue.cc @@ -1,6 +1,6 @@ #include -#include +#include std::shared_ptr QPDFValue::do_create(QPDFValue* object) diff --git a/libqpdf/QPDFValueProxy.cc b/libqpdf/QPDFValueProxy.cc deleted file mode 100644 index c315128..0000000 --- a/libqpdf/QPDFValueProxy.cc +++ /dev/null @@ -1,17 +0,0 @@ -#include - -#include -#include - -void -QPDFValueProxy::doResolve() -{ - auto og = value->og; - QPDF::Resolver::resolve(value->qpdf, og); -} - -void -QPDFValueProxy::destroy() -{ - value = QPDF_Destroyed::getInstance(); -} diff --git a/libqpdf/qpdf/QPDFObject_private.hh b/libqpdf/qpdf/QPDFObject_private.hh new file mode 100644 index 0000000..84aaabe --- /dev/null +++ b/libqpdf/qpdf/QPDFObject_private.hh @@ -0,0 +1,156 @@ +#ifndef QPDFOBJECT_HH +#define QPDFOBJECT_HH + +// NOTE: This file is called QPDFObject_private.hh instead of +// QPDFObject.hh because of include/qpdf/QPDFObject.hh. See comments +// there for an explanation. + +#include +#include +#include +#include +#include + +#include + +class QPDF; +class QPDFObjectHandle; + +class QPDFValueProxy +{ + friend class QPDFValue; + + public: + QPDFValueProxy() = default; + + std::shared_ptr + shallowCopy() + { + return value->shallowCopy(); + } + std::string + unparse() + { + return value->unparse(); + } + JSON + getJSON(int json_version) + { + return value->getJSON(json_version); + } + + // Return a unique type code for the object + qpdf_object_type_e + getTypeCode() const + { + return value->type_code; + } + + // Return a string literal that describes the type, useful for + // debugging and testing + char const* + getTypeName() const + { + return value->type_name; + } + + QPDF* + getQPDF() const + { + return value->qpdf; + } + QPDFObjGen + getObjGen() const + { + return value->og; + } + + 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 + assign(std::shared_ptr o) + { + value = o->value; + } + void + swapWith(std::shared_ptr o) + { + auto v = value; + value = o->value; + o->value = v; + auto og = value->og; + value->og = o->value->og; + o->value->og = og; + } + + void + setObjGen(QPDF* qpdf, QPDFObjGen const& og) + { + // Intended for use by the QPDF class + value->qpdf = qpdf; + value->og = og; + } + void + disconnect() + { + // Disconnect an object from its owning QPDF. This is called + // by QPDF's destructor. + value->disconnect(); + value->qpdf = nullptr; + value->og = QPDFObjGen(); + } + // Mark an object as destroyed. Used by QPDF's destructor for its + // indirect objects. + void destroy(); + + bool + isUnresolved() const + { + return value->type_code == ::ot_unresolved; + } + void + resolve() + { + if (isUnresolved()) { + doResolve(); + } + } + void doResolve(); + + template + T* + as() + { + return dynamic_cast(value.get()); + } + + private: + QPDFValueProxy(QPDFValueProxy const&) = delete; + QPDFValueProxy& operator=(QPDFValueProxy const&) = delete; + std::shared_ptr value; +}; + +#endif // QPDFOBJECT_HH diff --git a/libqpdf/qpdf/QPDFValueProxy.hh b/libqpdf/qpdf/QPDFValueProxy.hh deleted file mode 100644 index ff3f80b..0000000 --- a/libqpdf/qpdf/QPDFValueProxy.hh +++ /dev/null @@ -1,152 +0,0 @@ -#ifndef QPDFVALUEPROXY_HH -#define QPDFVALUEPROXY_HH - -#include -#include -#include -#include -#include - -#include - -class QPDF; -class QPDFObjectHandle; - -class QPDFValueProxy -{ - friend class QPDFValue; - - public: - QPDFValueProxy() = default; - - std::shared_ptr - shallowCopy() - { - return value->shallowCopy(); - } - std::string - unparse() - { - return value->unparse(); - } - JSON - getJSON(int json_version) - { - return value->getJSON(json_version); - } - - // Return a unique type code for the object - qpdf_object_type_e - getTypeCode() const - { - return value->type_code; - } - - // Return a string literal that describes the type, useful for - // debugging and testing - char const* - getTypeName() const - { - return value->type_name; - } - - QPDF* - getQPDF() const - { - return value->qpdf; - } - QPDFObjGen - getObjGen() const - { - return value->og; - } - - 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 - assign(std::shared_ptr o) - { - value = o->value; - } - void - swapWith(std::shared_ptr o) - { - auto v = value; - value = o->value; - o->value = v; - auto og = value->og; - value->og = o->value->og; - o->value->og = og; - } - - void - setObjGen(QPDF* qpdf, QPDFObjGen const& og) - { - // Intended for use by the QPDF class - value->qpdf = qpdf; - value->og = og; - } - void - disconnect() - { - // Disconnect an object from its owning QPDF. This is called - // by QPDF's destructor. - value->disconnect(); - value->qpdf = nullptr; - value->og = QPDFObjGen(); - } - // Mark an object as destroyed. Used by QPDF's destructor for its - // indirect objects. - void destroy(); - - bool - isUnresolved() const - { - return value->type_code == ::ot_unresolved; - } - void - resolve() - { - if (isUnresolved()) { - doResolve(); - } - } - void doResolve(); - - template - T* - as() - { - return dynamic_cast(value.get()); - } - - private: - QPDFValueProxy(QPDFValueProxy const&) = delete; - QPDFValueProxy& operator=(QPDFValueProxy const&) = delete; - std::shared_ptr value; -}; - -#endif // QPDFVALUEPROXY_HH -- libgit2 0.21.4