diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-04-24 15:31:32 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-04-24 15:31:32 +0200 |
commit | 4be2f3604939de8589dd2206fdf3d1a85033f171 (patch) | |
tree | e4a861e9e77bd3b56462f7c996cfec931f8b0b2f /libqpdf/QPDF_Dictionary.cc | |
parent | b8d0b0b6388db732fee0e9fb95af0884704bf423 (diff) | |
download | qpdf-4be2f3604939de8589dd2206fdf3d1a85033f171.tar.zst |
Deprecate replaceOrRemoveKey -- it's the same as replaceKey
Diffstat (limited to 'libqpdf/QPDF_Dictionary.cc')
-rw-r--r-- | libqpdf/QPDF_Dictionary.cc | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/libqpdf/QPDF_Dictionary.cc b/libqpdf/QPDF_Dictionary.cc index 1655f53a..0423f41f 100644 --- a/libqpdf/QPDF_Dictionary.cc +++ b/libqpdf/QPDF_Dictionary.cc @@ -115,11 +115,16 @@ QPDF_Dictionary::getAsMap() const } void -QPDF_Dictionary::replaceKey( - std::string const& key, QPDFObjectHandle const& value) +QPDF_Dictionary::replaceKey(std::string const& key, QPDFObjectHandle value) { - // add or replace value - this->items[key] = value; + if (value.isNull()) { + // The PDF spec doesn't distinguish between keys with null + // values and missing keys. + removeKey(key); + } else { + // add or replace value + this->items[key] = value; + } } void @@ -128,14 +133,3 @@ QPDF_Dictionary::removeKey(std::string const& key) // no-op if key does not exist this->items.erase(key); } - -void -QPDF_Dictionary::replaceOrRemoveKey( - std::string const& key, QPDFObjectHandle value) -{ - if (value.isNull()) { - removeKey(key); - } else { - replaceKey(key, value); - } -} |