From 25ccc7eae4b78e90d0fe6400abeba22ca4cd648e Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Thu, 8 Sep 2022 11:12:10 -0400 Subject: Rename QPDFValueProxy.hh and QPDFValueProxy.cc Preparing to change the class name back to QPDFObject --- 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 ------------------------------------ 8 files changed, 177 insertions(+), 173 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 (limited to 'libqpdf') diff --git a/libqpdf/CMakeLists.txt b/libqpdf/CMakeLists.txt index 3084813d..1323e60c 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 1b1ee784..d56fb29d 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 00000000..b5d073ab --- /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 d31af881..ab54b808 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 957cc350..99fd77d7 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 c315128c..00000000 --- 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 00000000..84aaabe4 --- /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 ff3f80b6..00000000 --- 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 -- cgit v1.2.3-54-g00ecf