diff options
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/QPDFObjectHandle.cc | 28 | ||||
-rw-r--r-- | libqpdf/qpdf-c.cc | 21 |
2 files changed, 49 insertions, 0 deletions
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index 1a8e3223..f2c77dca 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -497,6 +497,34 @@ QPDFObjectHandle::isScalar() isOperator() || isInlineImage())); } +bool +QPDFObjectHandle::isNameAndEquals(std::string const& name) +{ + return isName() && (getName() == name); +} + +bool +QPDFObjectHandle::isDictionaryOfType(std::string const& type, + std::string const& subtype) +{ + if (isDictionary() && getKey("/Type").isNameAndEquals(type)) + { + return (subtype == "") || + (hasKey("/Subtype") && getKey("/Subtype").isNameAndEquals(subtype)); + } + else + { + return false; + } +} + +bool +QPDFObjectHandle::isStreamOfType(std::string const& type, + std::string const& subtype) +{ + return isStream() && getDict().isDictionaryOfType(type, subtype); +} + // Bool accessors bool diff --git a/libqpdf/qpdf-c.cc b/libqpdf/qpdf-c.cc index fb79407d..44950568 100644 --- a/libqpdf/qpdf-c.cc +++ b/libqpdf/qpdf-c.cc @@ -1148,6 +1148,27 @@ QPDF_BOOL qpdf_oh_is_number(qpdf_data qpdf, qpdf_oh oh) }); } +QPDF_BOOL qpdf_oh_is_name_and_equals( + qpdf_data qpdf, qpdf_oh oh, char const* name) +{ + return do_with_oh<QPDF_BOOL>( + qpdf, oh, return_false, [name](QPDFObjectHandle& o) { + QTC::TC("qpdf", "qpdf-c called qpdf_oh_is_name_and_equals"); + return o.isNameAndEquals(name); + }); +} + +QPDF_BOOL qpdf_oh_is_dictionary_of_type( + qpdf_data qpdf, qpdf_oh oh, char const* type, char const* subtype) +{ + auto stype = (subtype == nullptr) ? "" : subtype; + return do_with_oh<QPDF_BOOL>( + qpdf, oh, return_false, [type, stype](QPDFObjectHandle& o) { + QTC::TC("qpdf", "qpdf-c called qpdf_oh_is_dictionary_of_type"); + return o.isDictionaryOfType(type, stype); + }); +} + qpdf_object_type_e qpdf_oh_get_type_code(qpdf_data qpdf, qpdf_oh oh) { return do_with_oh<qpdf_object_type_e>( |