diff options
author | Jay Berkenbilt <ejb@ql.org> | 2013-01-22 15:57:07 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2013-01-22 16:01:45 +0100 |
commit | 913eb5ac35011b3d28c653b6f89d936c8f99c844 (patch) | |
tree | ded1a2e1b5f9fcdf6a5e77e44e30aa528be306be /include | |
parent | f81152311e5737e5e0de9dd9462311f306c6921b (diff) | |
download | qpdf-913eb5ac35011b3d28c653b6f89d936c8f99c844.tar.zst |
Add getTypeCode() and getTypeName()
Add virtual methods to QPDFObject, wrappers to QPDFObjectHandle, and
implementations to all the QPDF_Object types.
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 |