diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/QPDFObject.hh | 33 | ||||
-rw-r--r-- | include/qpdf/QPDFObjectHandle.hh | 8 |
2 files changed, 41 insertions, 0 deletions
diff --git a/include/qpdf/QPDFObject.hh b/include/qpdf/QPDFObject.hh index 8bb61022..4a5f2dec 100644 --- a/include/qpdf/QPDFObject.hh +++ b/include/qpdf/QPDFObject.hh @@ -18,9 +18,42 @@ class QPDFObjectHandle; class QPDFObject { public: + + // 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_boolean, + ot_null, + ot_integer, + ot_real, + ot_name, + ot_string, + ot_array, + ot_dictionary, + ot_stream, + // Additional object types that can occur in content streams + ot_keyword, + ot_inlineimage, + }; + virtual ~QPDFObject() {} virtual std::string unparse() = 0; + // Return a unique type code for the object + virtual object_type_e getTypeCode() const = 0; + + // Return a string literal that describes the type, useful for + // debugging and testing + virtual char const* getTypeName() const = 0; + // Accessor to give specific access to non-public methods class ObjAccessor { diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh index c4a922d1..a23d81df 100644 --- a/include/qpdf/QPDFObjectHandle.hh +++ b/include/qpdf/QPDFObjectHandle.hh @@ -91,6 +91,14 @@ class QPDFObjectHandle QPDF_DLL bool isInitialized() const; + // Return type code and type name of underlying object. These are + // useful for doing rapid type tests (like switch statements) or + // for testing and debugging. + QPDF_DLL + QPDFObject::object_type_e getTypeCode() const; + QPDF_DLL + char const* getTypeName() const; + // Exactly one of these will return true for any object. Keyword // and InlineImage are only allowed in content streams. QPDF_DLL |