Commit 55cc2ab68094984f4550f75feb0124726146d27e
1 parent
6c61be00
Re-introduce QPDFObject.hh as deprecated
* Just removing a header file would cause build errors with no hint as to what happened. This way, people get a warning rather than error for the life of qpdf 11, and the warning tells them what to do. * This avoids build surprises resulting from having two versions of QPDF headers installed at once. If you were building code out of a checkout of qpdf but had an older version installed on your system, if your code included <qpdf/QPDFObject.hh>, everything would work, but then your code would break without QPDFObject.hh later.
Showing
3 changed files
with
82 additions
and
11 deletions
include/qpdf/QPDFObject.hh
0 → 100644
| 1 | +// Copyright (c) 2005-2022 Jay Berkenbilt | ||
| 2 | +// | ||
| 3 | +// This file is part of qpdf. | ||
| 4 | +// | ||
| 5 | +// Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 6 | +// you may not use this file except in compliance with the License. | ||
| 7 | +// You may obtain a copy of the License at | ||
| 8 | +// | ||
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 | ||
| 10 | +// | ||
| 11 | +// Unless required by applicable law or agreed to in writing, software | ||
| 12 | +// distributed under the License is distributed on an "AS IS" BASIS, | ||
| 13 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 14 | +// See the License for the specific language governing permissions and | ||
| 15 | +// limitations under the License. | ||
| 16 | +// | ||
| 17 | +// Versions of qpdf prior to version 7 were released under the terms | ||
| 18 | +// of version 2.0 of the Artistic License. At your option, you may | ||
| 19 | +// continue to consider qpdf to be licensed under those terms. Please | ||
| 20 | +// see the manual for additional information. | ||
| 21 | + | ||
| 22 | +#ifndef QPDFOBJECT_HH | ||
| 23 | +#define QPDFOBJECT_HH | ||
| 24 | + | ||
| 25 | +#ifndef QPDF_OBJECT_NOWARN | ||
| 26 | +// ABI: remove this file in qpdf 12 | ||
| 27 | +# warning "QPDFObject.hh is deprecated see comments in QPDFObject.hh" | ||
| 28 | +#endif | ||
| 29 | + | ||
| 30 | +#include <qpdf/Constants.h> | ||
| 31 | +class QPDFObject | ||
| 32 | +{ | ||
| 33 | + public: | ||
| 34 | + // This file and these symbols will be removed in QPDF 12. Instead | ||
| 35 | + // of including this header, include <qpdf/Constants.h>. Replace | ||
| 36 | + // `QPDFObject::ot_` with `::ot_` in your code. | ||
| 37 | + | ||
| 38 | + // Prior to qpdf 10.5, qpdf_object_type_e was | ||
| 39 | + // QPDFObject::object_type_e but was moved to make it accessible | ||
| 40 | + // to the C API. The code below is for backward compatibility | ||
| 41 | + // until qpdf 12. | ||
| 42 | + typedef enum qpdf_object_type_e object_type_e; | ||
| 43 | + static constexpr object_type_e ot_uninitialized = ::ot_uninitialized; | ||
| 44 | + static constexpr object_type_e ot_reserved = ::ot_reserved; | ||
| 45 | + static constexpr object_type_e ot_null = ::ot_null; | ||
| 46 | + static constexpr object_type_e ot_boolean = ::ot_boolean; | ||
| 47 | + static constexpr object_type_e ot_integer = ::ot_integer; | ||
| 48 | + static constexpr object_type_e ot_real = ::ot_real; | ||
| 49 | + static constexpr object_type_e ot_string = ::ot_string; | ||
| 50 | + static constexpr object_type_e ot_name = ::ot_name; | ||
| 51 | + static constexpr object_type_e ot_array = ::ot_array; | ||
| 52 | + static constexpr object_type_e ot_dictionary = ::ot_dictionary; | ||
| 53 | + static constexpr object_type_e ot_stream = ::ot_stream; | ||
| 54 | + static constexpr object_type_e ot_operator = ::ot_operator; | ||
| 55 | + static constexpr object_type_e ot_inlineimage = ::ot_inlineimage; | ||
| 56 | + static constexpr object_type_e ot_unresolved = ::ot_unresolved; | ||
| 57 | + | ||
| 58 | + private: | ||
| 59 | + QPDFObject() = delete; | ||
| 60 | + QPDFObject(QPDFObject const&) = delete; | ||
| 61 | + QPDFObject& operator=(QPDFObject const&) = delete; | ||
| 62 | +}; | ||
| 63 | + | ||
| 64 | +#endif // QPDFOBJECT_HH |
manual/release-notes.rst
| @@ -95,17 +95,17 @@ For a detailed list of changes, please see the file | @@ -95,17 +95,17 @@ For a detailed list of changes, please see the file | ||
| 95 | 95 | ||
| 96 | - API: breaking changes | 96 | - API: breaking changes |
| 97 | 97 | ||
| 98 | - - Remove ``QPDFObject.hh`` from the public ``include/qpdf`` | ||
| 99 | - directory. The only use case for including | ||
| 100 | - ``qpdf/QPDFObject.hh`` was to get ``QPDFObject::object_type_e``. | ||
| 101 | - Since 10.5.0, this has been an alias to ``qpdf_object_type_e``, | ||
| 102 | - defined in ``qpdf/Constants.h``. To fix your code, replace any | ||
| 103 | - includes of ``qpdf/QPDFObject.hh`` with ``qpdf/Constants.h``, | ||
| 104 | - and replace all occurrences of ``QPDFObject::ot_`` with | ||
| 105 | - ``::ot_``. If you need your code to be backward compatible to | ||
| 106 | - qpdf versions prior to 10.5.0, you can check that the | ||
| 107 | - preprocessor symbol ``QPDF_MAJOR_VERSION`` is defined and ``>= | ||
| 108 | - 11``. | 98 | + - Deprecate ``QPDFObject.hh`` for removal in qpdf 12. The only use |
| 99 | + case for including ``qpdf/QPDFObject.hh`` was to get | ||
| 100 | + ``QPDFObject::object_type_e``. Since 10.5.0, this has been an | ||
| 101 | + alias to ``qpdf_object_type_e``, defined in | ||
| 102 | + ``qpdf/Constants.h``. To fix your code, replace any includes of | ||
| 103 | + ``qpdf/QPDFObject.hh`` with ``qpdf/Constants.h``, and replace | ||
| 104 | + all occurrences of ``QPDFObject::ot_`` with ``::ot_``. If you | ||
| 105 | + need your code to be backward compatible to qpdf versions prior | ||
| 106 | + to 10.5.0, you can check that the preprocessor symbol | ||
| 107 | + ``QPDF_MAJOR_VERSION`` is defined and ``>= 11``. As a stop-gap, | ||
| 108 | + you can `#define QPDF_OBJECT_NOWARN` to suppress the warning. | ||
| 109 | 109 | ||
| 110 | - Pipeline::write now takes ``unsigned char const*`` instead of | 110 | - Pipeline::write now takes ``unsigned char const*`` instead of |
| 111 | ``unsigned char*``. Callers don't need to change anything, but | 111 | ``unsigned char*``. Callers don't need to change anything, but |
qpdf/test_driver.cc
| @@ -35,6 +35,9 @@ | @@ -35,6 +35,9 @@ | ||
| 35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
| 36 | #include <string.h> | 36 | #include <string.h> |
| 37 | 37 | ||
| 38 | +#define QPDF_OBJECT_NOWARN | ||
| 39 | +#include <qpdf/QPDFObject.hh> | ||
| 40 | + | ||
| 38 | static char const* whoami = 0; | 41 | static char const* whoami = 0; |
| 39 | 42 | ||
| 40 | void | 43 | void |
| @@ -3298,6 +3301,10 @@ runtest(int n, char const* filename1, char const* arg2) | @@ -3298,6 +3301,10 @@ runtest(int n, char const* filename1, char const* arg2) | ||
| 3298 | QPDFObjectHandle uninitialized; | 3301 | QPDFObjectHandle uninitialized; |
| 3299 | assert(uninitialized.getTypeCode() == ::ot_uninitialized); | 3302 | assert(uninitialized.getTypeCode() == ::ot_uninitialized); |
| 3300 | assert(strcmp(uninitialized.getTypeName(), "uninitialized") == 0); | 3303 | assert(strcmp(uninitialized.getTypeName(), "uninitialized") == 0); |
| 3304 | + | ||
| 3305 | + // ABI: until QPDF 12, spot check deprecated constants | ||
| 3306 | + assert(QPDFObject::ot_unresolved == ::ot_unresolved); | ||
| 3307 | + assert(QPDFObject::ot_uninitialized == ::ot_uninitialized); | ||
| 3301 | } | 3308 | } |
| 3302 | 3309 | ||
| 3303 | QPDF pdf; | 3310 | QPDF pdf; |