mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 02:49:00 +00:00
Remove QPDFObject::object_type_e as alias for qpdf_object_type_e
This commit is contained in:
parent
a47b99953f
commit
b663926538
@ -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
|
||||
|
@ -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. */
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user