aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-09-01 23:39:52 +0200
committerJay Berkenbilt <ejb@ql.org>2022-09-02 00:11:22 +0200
commitb66392653871f834d7b78aa423ca279e4828951a (patch)
treeeb3929bfa0936c67a7153b5585d69762c5be8b8e
parenta47b99953f503ea028abc3bb48c72b006bb2289a (diff)
downloadqpdf-b66392653871f834d7b78aa423ca279e4828951a.tar.zst
Remove QPDFObject::object_type_e as alias for qpdf_object_type_e
-rw-r--r--ChangeLog4
-rw-r--r--include/qpdf/Constants.h6
-rw-r--r--include/qpdf/QPDFObject.hh28
-rw-r--r--include/qpdf/QPDFObjectHandle.hh2
-rw-r--r--libqpdf/QPDFObjectHandle.cc31
-rw-r--r--manual/release-notes.rst12
-rw-r--r--qpdf/test_driver.cc4
-rw-r--r--qpdf/test_renumber.cc18
8 files changed, 46 insertions, 59 deletions
diff --git a/ChangeLog b/ChangeLog
index 551d6d03..66f4e262 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2022-09-01 Jay Berkenbilt <ejb@ql.org>
+ * Remove QPDFObject.hh from include/qpdf. The only reason to
+ include was to get QPDFObject::object_type_e. Instead, include
+ qpdf/Constants.h, and change `QPDFObject::ot_` to `::ot_`.
+
* More optimizations and cleanup from m-holger (#726, #730)
including major refactor of QPDF's internal representations of
objects. In addition to a large performance improvement, this also
diff --git a/include/qpdf/Constants.h b/include/qpdf/Constants.h
index cf6bdaef..006ff20e 100644
--- a/include/qpdf/Constants.h
+++ b/include/qpdf/Constants.h
@@ -61,9 +61,8 @@ enum qpdf_error_code_e {
* may be added to the list, so code that switches on these values
* should take that into consideration. (Maintainer note: it would be
* better to call this qpdf_ot_* rather than ot_* to reduce likelihood
- * of name collision, but since QPDFObject::object_type_e is an alias
- * to this type, changing the names of the values breaks backward
- * compatibility.)
+ * of name collision, but changing the names of the values breaks
+ * backward compatibility.)
*/
enum qpdf_object_type_e {
/* Object types internal to qpdf */
@@ -84,7 +83,6 @@ enum qpdf_object_type_e {
ot_inlineimage,
/* Object types internal to qpdf */
ot_unresolved,
- /* NOTE: if adding to this list, update QPDFObject.hh */
};
/* Write Parameters. See QPDFWriter.hh for details. */
diff --git a/include/qpdf/QPDFObject.hh b/include/qpdf/QPDFObject.hh
index e6d1d18b..310b2c2c 100644
--- a/include/qpdf/QPDFObject.hh
+++ b/include/qpdf/QPDFObject.hh
@@ -38,32 +38,6 @@ class QPDFObject
friend class QPDFValue;
public:
- // Objects derived from QPDFObject are accessible through
- // QPDFObjectHandle. Each object returns a unique type code that
- // has one of the valid qpdf_object_type_e values. As new object
- // types are added to qpdf, additional items may be added to the
- // list, so code that switches on these values should take that
- // into consideration.
-
- // Prior to qpdf 10.5, qpdf_object_type_e was
- // QPDFObject::object_type_e but was moved to make it accessible
- // to the C API. The code below is for backward compatibility.
- typedef enum qpdf_object_type_e object_type_e;
- static constexpr object_type_e ot_uninitialized = ::ot_uninitialized;
- static constexpr object_type_e ot_reserved = ::ot_reserved;
- static constexpr object_type_e ot_null = ::ot_null;
- static constexpr object_type_e ot_boolean = ::ot_boolean;
- static constexpr object_type_e ot_integer = ::ot_integer;
- static constexpr object_type_e ot_real = ::ot_real;
- static constexpr object_type_e ot_string = ::ot_string;
- static constexpr object_type_e ot_name = ::ot_name;
- static constexpr object_type_e ot_array = ::ot_array;
- static constexpr object_type_e ot_dictionary = ::ot_dictionary;
- static constexpr object_type_e ot_stream = ::ot_stream;
- static constexpr object_type_e ot_operator = ::ot_operator;
- static constexpr object_type_e ot_inlineimage = ::ot_inlineimage;
- static constexpr object_type_e ot_unresolved = ::ot_unresolved;
-
QPDFObject() = default;
virtual ~QPDFObject() = default;
@@ -84,7 +58,7 @@ class QPDFObject
}
// Return a unique type code for the object
- object_type_e
+ qpdf_object_type_e
getTypeCode() const
{
return value->type_code;
diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh
index 16e8dc8b..02f83363 100644
--- a/include/qpdf/QPDFObjectHandle.hh
+++ b/include/qpdf/QPDFObjectHandle.hh
@@ -338,7 +338,7 @@ class QPDFObjectHandle
// useful for doing rapid type tests (like switch statements) or
// for testing and debugging.
QPDF_DLL
- QPDFObject::object_type_e getTypeCode();
+ qpdf_object_type_e getTypeCode();
QPDF_DLL
char const* getTypeName();
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc
index 19a85034..cb1e9e45 100644
--- a/libqpdf/QPDFObjectHandle.cc
+++ b/libqpdf/QPDFObjectHandle.cc
@@ -251,11 +251,10 @@ QPDFObjectHandle::releaseResolved()
}
}
-QPDFObject::object_type_e
+qpdf_object_type_e
QPDFObjectHandle::getTypeCode()
{
- return dereference() ? this->obj->getTypeCode()
- : QPDFObject::ot_uninitialized;
+ return dereference() ? this->obj->getTypeCode() : ::ot_uninitialized;
}
char const*
@@ -347,7 +346,7 @@ QPDFObjectHandle::asString()
bool
QPDFObjectHandle::isBool()
{
- return dereference() && (obj->getTypeCode() == QPDFObject::ot_boolean);
+ return dereference() && (obj->getTypeCode() == ::ot_boolean);
}
bool
@@ -357,25 +356,25 @@ QPDFObjectHandle::isDirectNull() const
// objid == 0, so there's nothing to resolve.
return (
isInitialized() && (getObjectID() == 0) &&
- (obj->getTypeCode() == QPDFObject::ot_null));
+ (obj->getTypeCode() == ::ot_null));
}
bool
QPDFObjectHandle::isNull()
{
- return dereference() && (obj->getTypeCode() == QPDFObject::ot_null);
+ return dereference() && (obj->getTypeCode() == ::ot_null);
}
bool
QPDFObjectHandle::isInteger()
{
- return dereference() && (obj->getTypeCode() == QPDFObject::ot_integer);
+ return dereference() && (obj->getTypeCode() == ::ot_integer);
}
bool
QPDFObjectHandle::isReal()
{
- return dereference() && (obj->getTypeCode() == QPDFObject::ot_real);
+ return dereference() && (obj->getTypeCode() == ::ot_real);
}
bool
@@ -412,49 +411,49 @@ QPDFObjectHandle::getValueAsNumber(double& value)
bool
QPDFObjectHandle::isName()
{
- return dereference() && (obj->getTypeCode() == QPDFObject::ot_name);
+ return dereference() && (obj->getTypeCode() == ::ot_name);
}
bool
QPDFObjectHandle::isString()
{
- return dereference() && (obj->getTypeCode() == QPDFObject::ot_string);
+ return dereference() && (obj->getTypeCode() == ::ot_string);
}
bool
QPDFObjectHandle::isOperator()
{
- return dereference() && (obj->getTypeCode() == QPDFObject::ot_operator);
+ return dereference() && (obj->getTypeCode() == ::ot_operator);
}
bool
QPDFObjectHandle::isInlineImage()
{
- return dereference() && (obj->getTypeCode() == QPDFObject::ot_inlineimage);
+ return dereference() && (obj->getTypeCode() == ::ot_inlineimage);
}
bool
QPDFObjectHandle::isArray()
{
- return dereference() && (obj->getTypeCode() == QPDFObject::ot_array);
+ return dereference() && (obj->getTypeCode() == ::ot_array);
}
bool
QPDFObjectHandle::isDictionary()
{
- return dereference() && (obj->getTypeCode() == QPDFObject::ot_dictionary);
+ return dereference() && (obj->getTypeCode() == ::ot_dictionary);
}
bool
QPDFObjectHandle::isStream()
{
- return dereference() && (obj->getTypeCode() == QPDFObject::ot_stream);
+ return dereference() && (obj->getTypeCode() == ::ot_stream);
}
bool
QPDFObjectHandle::isReserved()
{
- return dereference() && (obj->getTypeCode() == QPDFObject::ot_reserved);
+ return dereference() && (obj->getTypeCode() == ::ot_reserved);
}
bool
diff --git a/manual/release-notes.rst b/manual/release-notes.rst
index 49298836..e3e65d88 100644
--- a/manual/release-notes.rst
+++ b/manual/release-notes.rst
@@ -95,6 +95,18 @@ For a detailed list of changes, please see the file
- API: breaking changes
+ - Remove ``QPDFObject.hh`` from the public ``include/qpdf``
+ directory. The only use case for including
+ ``qpdf/QPDFObject.hh`` was to get ``QPDFObject::object_type_e``.
+ Since 10.5.0, this has been an alias to ``qpdf_object_type_e``,
+ defined in ``qpdf/Constants.h``. To fix your code, replace any
+ includes of ``qpdf/QPDFObject.hh`` with ``qpdf/Constants.h``,
+ and replace all occurrences of ``QPDFObject::ot_`` with
+ ``::ot_``. If you need your code to be backward compatible to
+ qpdf versions prior to 10.5.0, you can check that the
+ preprocessor symbol ``QPDF_MAJOR_VERSION`` is defined and ``>=
+ 11``.
+
- Pipeline::write now takes ``unsigned char const*`` instead of
``unsigned char*``. Callers don't need to change anything, but
you no longer have to pass writable pointers to pipelines. If
diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc
index 5572e824..095543c1 100644
--- a/qpdf/test_driver.cc
+++ b/qpdf/test_driver.cc
@@ -103,7 +103,7 @@ ParserCallbacks::handleObject(
<< ", length=" << length << ": ";
if (obj.isInlineImage()) {
// Exercise getTypeCode
- assert(obj.getTypeCode() == QPDFObject::ot_inlineimage);
+ assert(obj.getTypeCode() == ::ot_inlineimage);
std::cout << QUtil::hex_encode(obj.getInlineImageValue()) << std::endl;
} else {
std::cout << obj.unparse() << std::endl;
@@ -3296,7 +3296,7 @@ runtest(int n, char const* filename1, char const* arg2)
assert(password == "1234567890123456789012(45678");
QPDFObjectHandle uninitialized;
- assert(uninitialized.getTypeCode() == QPDFObject::ot_uninitialized);
+ assert(uninitialized.getTypeCode() == ::ot_uninitialized);
assert(strcmp(uninitialized.getTypeName(), "uninitialized") == 0);
}
diff --git a/qpdf/test_renumber.cc b/qpdf/test_renumber.cc
index 206ef49a..1ef519d6 100644
--- a/qpdf/test_renumber.cc
+++ b/qpdf/test_renumber.cc
@@ -40,37 +40,37 @@ compare(QPDFObjectHandle a, QPDFObjectHandle b)
}
switch (a.getTypeCode()) {
- case QPDFObject::ot_boolean:
+ case ::ot_boolean:
if (a.getBoolValue() != b.getBoolValue()) {
std::cerr << "different boolean" << std::endl;
return false;
}
break;
- case QPDFObject::ot_integer:
+ case ::ot_integer:
if (a.getIntValue() != b.getIntValue()) {
std::cerr << "different integer" << std::endl;
return false;
}
break;
- case QPDFObject::ot_real:
+ case ::ot_real:
if (a.getRealValue() != b.getRealValue()) {
std::cerr << "different real" << std::endl;
return false;
}
break;
- case QPDFObject::ot_string:
+ case ::ot_string:
if (a.getStringValue() != b.getStringValue()) {
std::cerr << "different string" << std::endl;
return false;
}
break;
- case QPDFObject::ot_name:
+ case ::ot_name:
if (a.getName() != b.getName()) {
std::cerr << "different name" << std::endl;
return false;
}
break;
- case QPDFObject::ot_array:
+ case ::ot_array:
{
std::vector<QPDFObjectHandle> objs_a = a.getArrayAsVector();
std::vector<QPDFObjectHandle> objs_b = b.getArrayAsVector();
@@ -88,7 +88,7 @@ compare(QPDFObjectHandle a, QPDFObjectHandle b)
}
}
break;
- case QPDFObject::ot_dictionary:
+ case ::ot_dictionary:
{
std::set<std::string> keys_a = a.getKeys();
std::set<std::string> keys_b = b.getKeys();
@@ -105,9 +105,9 @@ compare(QPDFObjectHandle a, QPDFObjectHandle b)
}
}
break;
- case QPDFObject::ot_null:
+ case ::ot_null:
break;
- case QPDFObject::ot_stream:
+ case ::ot_stream:
std::cout << "stream objects are not compared" << std::endl;
break;
default: