aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2021-12-17 18:34:48 +0100
committerJay Berkenbilt <ejb@ql.org>2021-12-17 18:38:52 +0100
commitc40f8b5329a645bd7ec2202af3433d11e6eae1d8 (patch)
treede60dba858752eb399e9a23c4fab55454ba7e415
parentcce715cd0e7f4ea434a9294e43045feb40c63488 (diff)
downloadqpdf-c40f8b5329a645bd7ec2202af3433d11e6eae1d8.tar.zst
Make object types available to C API
-rw-r--r--ChangeLog4
-rw-r--r--include/qpdf/Constants.h28
-rw-r--r--include/qpdf/QPDFObject.hh47
3 files changed, 56 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 60e3c0c2..cad0edd3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2021-12-17 Jay Berkenbilt <ejb@ql.org>
+ * QPDFObjectHandle object types have been moved from
+ QPDFObject::object_type_e to qpdf_object_type_e (defined in
+ Constants.h). Old values are available for backward compatibility.
+
* Add Pl_Buffer::getMallocBuffer() to initialize a buffer with
malloc in support of the C API
diff --git a/include/qpdf/Constants.h b/include/qpdf/Constants.h
index 4e4c9e01..3e36a8f9 100644
--- a/include/qpdf/Constants.h
+++ b/include/qpdf/Constants.h
@@ -41,6 +41,34 @@ enum qpdf_error_code_e
qpdf_e_object, /* type/bounds errors accessing objects */
};
+/* Object Types */
+
+/* PDF objects represented by QPDFObjectHandle or, in the C API, by
+ * qpdf_oh, have a unique type code that has one of the values in the
+ * list below. 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.
+ */
+enum qpdf_object_type_e {
+ /* Object types internal to qpdf */
+ qpdf_ot_uninitialized,
+ qpdf_ot_reserved,
+ /* Object types that can occur in the main document */
+ qpdf_ot_null,
+ qpdf_ot_boolean,
+ qpdf_ot_integer,
+ qpdf_ot_real,
+ qpdf_ot_string,
+ qpdf_ot_name,
+ qpdf_ot_array,
+ qpdf_ot_dictionary,
+ qpdf_ot_stream,
+ /* Additional object types that can occur in content streams */
+ qpdf_ot_operator,
+ qpdf_ot_inlineimage,
+ /* NOTE: if adding to this list, update QPDFObject.hh */
+};
+
/* Write Parameters. See QPDFWriter.hh for details. */
enum qpdf_object_stream_e
diff --git a/include/qpdf/QPDFObject.hh b/include/qpdf/QPDFObject.hh
index 3b1cd72b..02f51ab2 100644
--- a/include/qpdf/QPDFObject.hh
+++ b/include/qpdf/QPDFObject.hh
@@ -25,6 +25,7 @@
#include <qpdf/DLL.h>
#include <qpdf/Types.h>
#include <qpdf/JSON.hh>
+#include <qpdf/Constants.h>
#include <string>
@@ -37,29 +38,29 @@ class QPDF_DLL_CLASS QPDFObject
QPDFObject();
// Objects derived from QPDFObject are accessible through
- // QPDFObjectHandle. Each object returns a unique type code that
- // has one of the values in the list below. 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.
- enum object_type_e {
- // Object types internal to qpdf
- ot_uninitialized,
- ot_reserved,
- // Object types that can occur in the main document
- ot_null,
- ot_boolean,
- ot_integer,
- ot_real,
- ot_string,
- ot_name,
- ot_array,
- ot_dictionary,
- ot_stream,
- // Additional object types that can occur in content streams
- ot_operator,
- ot_inlineimage,
- };
+ // 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 = ::qpdf_ot_uninitialized;
+ static constexpr object_type_e ot_reserved = ::qpdf_ot_reserved;
+ static constexpr object_type_e ot_null = ::qpdf_ot_null;
+ static constexpr object_type_e ot_boolean = ::qpdf_ot_boolean;
+ static constexpr object_type_e ot_integer = ::qpdf_ot_integer;
+ static constexpr object_type_e ot_real = ::qpdf_ot_real;
+ static constexpr object_type_e ot_string = ::qpdf_ot_string;
+ static constexpr object_type_e ot_name = ::qpdf_ot_name;
+ static constexpr object_type_e ot_array = ::qpdf_ot_array;
+ static constexpr object_type_e ot_dictionary = ::qpdf_ot_dictionary;
+ static constexpr object_type_e ot_stream = ::qpdf_ot_stream;
+ static constexpr object_type_e ot_operator = ::qpdf_ot_operator;
+ static constexpr object_type_e ot_inlineimage = ::qpdf_ot_inlineimage;
virtual ~QPDFObject() {}
virtual std::string unparse() = 0;