From 1d57772b76ee0947db209d71639c1d955b93eb6e Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Thu, 1 Sep 2022 17:45:17 -0400 Subject: [PATCH] Remove QPDFObject and QPDFValue from public include directory --- include/qpdf/QPDFObject.hh | 193 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- include/qpdf/QPDFValue.hh | 130 ---------------------------------------------------------------------------------------------------------------------------------- libqpdf/qpdf/QPDFObject.hh | 193 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ libqpdf/qpdf/QPDFValue.hh | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 323 insertions(+), 323 deletions(-) delete mode 100644 include/qpdf/QPDFObject.hh delete mode 100644 include/qpdf/QPDFValue.hh create mode 100644 libqpdf/qpdf/QPDFObject.hh create mode 100644 libqpdf/qpdf/QPDFValue.hh diff --git a/include/qpdf/QPDFObject.hh b/include/qpdf/QPDFObject.hh deleted file mode 100644 index 310b2c2..0000000 --- a/include/qpdf/QPDFObject.hh +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (c) 2005-2022 Jay Berkenbilt -// -// This file is part of qpdf. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Versions of qpdf prior to version 7 were released under the terms -// of version 2.0 of the Artistic License. At your option, you may -// continue to consider qpdf to be licensed under those terms. Please -// see the manual for additional information. - -#ifndef QPDFOBJECT_HH -#define QPDFOBJECT_HH - -#include -#include -#include -#include -#include - -#include - -class QPDF; -class QPDFObjectHandle; - -class QPDFObject -{ - friend class QPDFValue; - - public: - QPDFObject() = default; - virtual ~QPDFObject() = 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; - } - // Returns nullptr for direct objects - 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; - } - - // 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 - resetObjGen() - { - value->qpdf = nullptr; - value->og = QPDFObjGen(); - } - - bool - isUnresolved() const - { - return value->type_code == ::ot_unresolved; - } - void - resolve() - { - if (isUnresolved()) { - doResolve(); - } - } - void doResolve(); - - template - T* - as() - { - return dynamic_cast(value.get()); - } - - // Accessor to give specific access to non-public methods - class ObjAccessor - { - friend class QPDF; - friend class QPDFObjectHandle; - - private: - static void - releaseResolved(QPDFObject* o) - { - if (o) { - o->releaseResolved(); - } - } - }; - - friend class ObjAccessor; - - protected: - virtual void - releaseResolved() - { - value->releaseResolved(); - } - - private: - QPDFObject(QPDFObject const&) = delete; - QPDFObject& operator=(QPDFObject const&) = delete; - std::shared_ptr value; -}; - -#endif // QPDFOBJECT_HH diff --git a/include/qpdf/QPDFValue.hh b/include/qpdf/QPDFValue.hh deleted file mode 100644 index 8b4f53b..0000000 --- a/include/qpdf/QPDFValue.hh +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (c) 2005-2022 Jay Berkenbilt -// -// This file is part of qpdf. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Versions of qpdf prior to version 7 were released under the terms -// of version 2.0 of the Artistic License. At your option, you may -// continue to consider qpdf to be licensed under those terms. Please -// see the manual for additional information. - -#ifndef QPDFVALUE_HH -#define QPDFVALUE_HH - -#include -#include -#include -#include -#include - -#include - -class QPDF; -class QPDFObjectHandle; -class QPDFObject; - -class QPDFValue -{ - friend class QPDFObject; - - public: - virtual ~QPDFValue() = default; - - virtual std::shared_ptr shallowCopy() = 0; - virtual std::string unparse() = 0; - virtual JSON getJSON(int json_version) = 0; - virtual void - setDescription(QPDF* qpdf, std::string const& description) - { - owning_qpdf = qpdf; - object_description = description; - } - bool - getDescription(QPDF*& qpdf, std::string& description) - { - qpdf = owning_qpdf; - description = object_description; - return owning_qpdf != nullptr; - } - bool - hasDescription() - { - return owning_qpdf != nullptr; - } - void - setParsedOffset(qpdf_offset_t offset) - { - if (parsed_offset < 0) { - parsed_offset = offset; - } - } - qpdf_offset_t - getParsedOffset() - { - return parsed_offset; - } - QPDF* - getQPDF() - { - return qpdf; - } - QPDFObjGen - getObjGen() - { - return og; - } - - protected: - QPDFValue() : - type_code(::ot_uninitialized), - type_name("uninitialized") - { - } - QPDFValue(qpdf_object_type_e type_code, char const* type_name) : - type_code(type_code), - type_name(type_name) - { - } - QPDFValue( - qpdf_object_type_e type_code, - char const* type_name, - QPDF* qpdf, - QPDFObjGen const& og) : - type_code(type_code), - type_name(type_name), - qpdf(qpdf), - og(og) - { - } - virtual void - releaseResolved() - { - } - static std::shared_ptr do_create(QPDFValue*); - - private: - QPDFValue(QPDFValue const&) = delete; - QPDFValue& operator=(QPDFValue const&) = delete; - QPDF* owning_qpdf{nullptr}; - std::string object_description; - qpdf_offset_t parsed_offset{-1}; - const qpdf_object_type_e type_code; - char const* type_name; - - protected: - QPDF* qpdf{nullptr}; - QPDFObjGen og; -}; - -#endif // QPDFVALUE_HH diff --git a/libqpdf/qpdf/QPDFObject.hh b/libqpdf/qpdf/QPDFObject.hh new file mode 100644 index 0000000..310b2c2 --- /dev/null +++ b/libqpdf/qpdf/QPDFObject.hh @@ -0,0 +1,193 @@ +// Copyright (c) 2005-2022 Jay Berkenbilt +// +// This file is part of qpdf. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Versions of qpdf prior to version 7 were released under the terms +// of version 2.0 of the Artistic License. At your option, you may +// continue to consider qpdf to be licensed under those terms. Please +// see the manual for additional information. + +#ifndef QPDFOBJECT_HH +#define QPDFOBJECT_HH + +#include +#include +#include +#include +#include + +#include + +class QPDF; +class QPDFObjectHandle; + +class QPDFObject +{ + friend class QPDFValue; + + public: + QPDFObject() = default; + virtual ~QPDFObject() = 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; + } + // Returns nullptr for direct objects + 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; + } + + // 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 + resetObjGen() + { + value->qpdf = nullptr; + value->og = QPDFObjGen(); + } + + bool + isUnresolved() const + { + return value->type_code == ::ot_unresolved; + } + void + resolve() + { + if (isUnresolved()) { + doResolve(); + } + } + void doResolve(); + + template + T* + as() + { + return dynamic_cast(value.get()); + } + + // Accessor to give specific access to non-public methods + class ObjAccessor + { + friend class QPDF; + friend class QPDFObjectHandle; + + private: + static void + releaseResolved(QPDFObject* o) + { + if (o) { + o->releaseResolved(); + } + } + }; + + friend class ObjAccessor; + + protected: + virtual void + releaseResolved() + { + value->releaseResolved(); + } + + private: + QPDFObject(QPDFObject const&) = delete; + QPDFObject& operator=(QPDFObject const&) = delete; + std::shared_ptr value; +}; + +#endif // QPDFOBJECT_HH diff --git a/libqpdf/qpdf/QPDFValue.hh b/libqpdf/qpdf/QPDFValue.hh new file mode 100644 index 0000000..8b4f53b --- /dev/null +++ b/libqpdf/qpdf/QPDFValue.hh @@ -0,0 +1,130 @@ +// Copyright (c) 2005-2022 Jay Berkenbilt +// +// This file is part of qpdf. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Versions of qpdf prior to version 7 were released under the terms +// of version 2.0 of the Artistic License. At your option, you may +// continue to consider qpdf to be licensed under those terms. Please +// see the manual for additional information. + +#ifndef QPDFVALUE_HH +#define QPDFVALUE_HH + +#include +#include +#include +#include +#include + +#include + +class QPDF; +class QPDFObjectHandle; +class QPDFObject; + +class QPDFValue +{ + friend class QPDFObject; + + public: + virtual ~QPDFValue() = default; + + virtual std::shared_ptr shallowCopy() = 0; + virtual std::string unparse() = 0; + virtual JSON getJSON(int json_version) = 0; + virtual void + setDescription(QPDF* qpdf, std::string const& description) + { + owning_qpdf = qpdf; + object_description = description; + } + bool + getDescription(QPDF*& qpdf, std::string& description) + { + qpdf = owning_qpdf; + description = object_description; + return owning_qpdf != nullptr; + } + bool + hasDescription() + { + return owning_qpdf != nullptr; + } + void + setParsedOffset(qpdf_offset_t offset) + { + if (parsed_offset < 0) { + parsed_offset = offset; + } + } + qpdf_offset_t + getParsedOffset() + { + return parsed_offset; + } + QPDF* + getQPDF() + { + return qpdf; + } + QPDFObjGen + getObjGen() + { + return og; + } + + protected: + QPDFValue() : + type_code(::ot_uninitialized), + type_name("uninitialized") + { + } + QPDFValue(qpdf_object_type_e type_code, char const* type_name) : + type_code(type_code), + type_name(type_name) + { + } + QPDFValue( + qpdf_object_type_e type_code, + char const* type_name, + QPDF* qpdf, + QPDFObjGen const& og) : + type_code(type_code), + type_name(type_name), + qpdf(qpdf), + og(og) + { + } + virtual void + releaseResolved() + { + } + static std::shared_ptr do_create(QPDFValue*); + + private: + QPDFValue(QPDFValue const&) = delete; + QPDFValue& operator=(QPDFValue const&) = delete; + QPDF* owning_qpdf{nullptr}; + std::string object_description; + qpdf_offset_t parsed_offset{-1}; + const qpdf_object_type_e type_code; + char const* type_name; + + protected: + QPDF* qpdf{nullptr}; + QPDFObjGen og; +}; + +#endif // QPDFVALUE_HH -- libgit2 0.21.4