diff options
author | Jay Berkenbilt <ejb@ql.org> | 2018-02-16 23:25:27 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2018-02-19 03:06:27 +0100 |
commit | d0e99f195a987c483bbb6c5449cf39bee34e08a1 (patch) | |
tree | cead8acd60cd14fd5d904ed380c750540cb361f3 /libqpdf/QPDF_Dictionary.cc | |
parent | c2e16827b69f3d3ac3721cfcd608b87f28e2a13f (diff) | |
download | qpdf-d0e99f195a987c483bbb6c5449cf39bee34e08a1.tar.zst |
More robust handling of type errors
Give objects descriptions and context so it is possible to issue
warnings instead of fatal errors for attempts to access objects of the
wrong type.
Diffstat (limited to 'libqpdf/QPDF_Dictionary.cc')
-rw-r--r-- | libqpdf/QPDF_Dictionary.cc | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/libqpdf/QPDF_Dictionary.cc b/libqpdf/QPDF_Dictionary.cc index 0af2f4bf..df640354 100644 --- a/libqpdf/QPDF_Dictionary.cc +++ b/libqpdf/QPDF_Dictionary.cc @@ -51,6 +51,12 @@ QPDF_Dictionary::getTypeName() const return "dictionary"; } +void +QPDF_Dictionary::setDescription(QPDF* qpdf, std::string const& description) +{ + this->QPDFObject::setDescription(qpdf, description); +} + bool QPDF_Dictionary::hasKey(std::string const& key) { @@ -70,7 +76,15 @@ QPDF_Dictionary::getKey(std::string const& key) } else { - return QPDFObjectHandle::newNull(); + QPDFObjectHandle null = QPDFObjectHandle::newNull(); + QPDF* qpdf = 0; + std::string description; + if (getDescription(qpdf, description)) + { + null.setObjectDescription( + qpdf, description + " -> dictionary key " + key); + } + return null; } } @@ -93,13 +107,12 @@ QPDF_Dictionary::getKeys() std::map<std::string, QPDFObjectHandle> const& QPDF_Dictionary::getAsMap() const { - return this->items; } void QPDF_Dictionary::replaceKey(std::string const& key, - QPDFObjectHandle const& value) + QPDFObjectHandle value) { // add or replace value this->items[key] = value; |