Commit 4925f0d18c5554bf96d8cb853b5a017e0d18fda2
1 parent
68e72198
Have dictionary/streams mutators take const& where possible
Showing
6 changed files
with
13 additions
and
11 deletions
include/qpdf/QPDFObjectHandle.hh
| ... | ... | @@ -1025,13 +1025,13 @@ class QPDFObjectHandle |
| 1025 | 1025 | |
| 1026 | 1026 | // Replace value of key, adding it if it does not exist |
| 1027 | 1027 | QPDF_DLL |
| 1028 | - void replaceKey(std::string const& key, QPDFObjectHandle); | |
| 1028 | + void replaceKey(std::string const& key, QPDFObjectHandle const&); | |
| 1029 | 1029 | // Remove key, doing nothing if key does not exist |
| 1030 | 1030 | QPDF_DLL |
| 1031 | 1031 | void removeKey(std::string const& key); |
| 1032 | 1032 | // If the object is null, remove the key. Otherwise, replace it. |
| 1033 | 1033 | QPDF_DLL |
| 1034 | - void replaceOrRemoveKey(std::string const& key, QPDFObjectHandle); | |
| 1034 | + void replaceOrRemoveKey(std::string const& key, QPDFObjectHandle const&); | |
| 1035 | 1035 | |
| 1036 | 1036 | // Methods for stream objects |
| 1037 | 1037 | QPDF_DLL |
| ... | ... | @@ -1164,7 +1164,7 @@ class QPDFObjectHandle |
| 1164 | 1164 | // may be more convenient in this case than calling getDict and |
| 1165 | 1165 | // modifying it for each key. The pdf-create example does this. |
| 1166 | 1166 | QPDF_DLL |
| 1167 | - void replaceDict(QPDFObjectHandle); | |
| 1167 | + void replaceDict(QPDFObjectHandle const&); | |
| 1168 | 1168 | |
| 1169 | 1169 | // Replace this stream's stream data with the given data buffer, |
| 1170 | 1170 | // and replace the /Filter and /DecodeParms keys in the stream | ... | ... |
libqpdf/QPDFObjectHandle.cc
| ... | ... | @@ -1268,7 +1268,8 @@ QPDFObjectHandle::getOwningQPDF() |
| 1268 | 1268 | // Dictionary mutators |
| 1269 | 1269 | |
| 1270 | 1270 | void |
| 1271 | -QPDFObjectHandle::replaceKey(std::string const& key, QPDFObjectHandle value) | |
| 1271 | +QPDFObjectHandle::replaceKey( | |
| 1272 | + std::string const& key, QPDFObjectHandle const& value) | |
| 1272 | 1273 | { |
| 1273 | 1274 | if (isDictionary()) { |
| 1274 | 1275 | checkOwnership(value); |
| ... | ... | @@ -1292,7 +1293,7 @@ QPDFObjectHandle::removeKey(std::string const& key) |
| 1292 | 1293 | |
| 1293 | 1294 | void |
| 1294 | 1295 | QPDFObjectHandle::replaceOrRemoveKey( |
| 1295 | - std::string const& key, QPDFObjectHandle value) | |
| 1296 | + std::string const& key, QPDFObjectHandle const& value) | |
| 1296 | 1297 | { |
| 1297 | 1298 | if (isDictionary()) { |
| 1298 | 1299 | checkOwnership(value); |
| ... | ... | @@ -1334,7 +1335,7 @@ QPDFObjectHandle::isDataModified() |
| 1334 | 1335 | } |
| 1335 | 1336 | |
| 1336 | 1337 | void |
| 1337 | -QPDFObjectHandle::replaceDict(QPDFObjectHandle new_dict) | |
| 1338 | +QPDFObjectHandle::replaceDict(QPDFObjectHandle const& new_dict) | |
| 1338 | 1339 | { |
| 1339 | 1340 | assertStream(); |
| 1340 | 1341 | dynamic_cast<QPDF_Stream*>(obj.get())->replaceDict(new_dict); | ... | ... |
libqpdf/QPDF_Dictionary.cc
| ... | ... | @@ -115,7 +115,8 @@ QPDF_Dictionary::getAsMap() const |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | void |
| 118 | -QPDF_Dictionary::replaceKey(std::string const& key, QPDFObjectHandle value) | |
| 118 | +QPDF_Dictionary::replaceKey( | |
| 119 | + std::string const& key, QPDFObjectHandle const& value) | |
| 119 | 120 | { |
| 120 | 121 | // add or replace value |
| 121 | 122 | this->items[key] = value; | ... | ... |
libqpdf/QPDF_Stream.cc
| ... | ... | @@ -617,11 +617,11 @@ QPDF_Stream::replaceFilterData( |
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | void |
| 620 | -QPDF_Stream::replaceDict(QPDFObjectHandle new_dict) | |
| 620 | +QPDF_Stream::replaceDict(QPDFObjectHandle const& new_dict) | |
| 621 | 621 | { |
| 622 | 622 | this->stream_dict = new_dict; |
| 623 | 623 | setDictDescription(); |
| 624 | - QPDFObjectHandle length_obj = new_dict.getKey("/Length"); | |
| 624 | + QPDFObjectHandle length_obj = this->stream_dict.getKey("/Length"); | |
| 625 | 625 | if (length_obj.isInteger()) { |
| 626 | 626 | this->length = QIntC::to_size(length_obj.getUIntValue()); |
| 627 | 627 | } else { | ... | ... |
libqpdf/qpdf/QPDF_Dictionary.hh
| ... | ... | @@ -28,7 +28,7 @@ class QPDF_Dictionary: public QPDFObject |
| 28 | 28 | std::map<std::string, QPDFObjectHandle> const& getAsMap() const; |
| 29 | 29 | |
| 30 | 30 | // Replace value of key, adding it if it does not exist |
| 31 | - void replaceKey(std::string const& key, QPDFObjectHandle); | |
| 31 | + void replaceKey(std::string const& key, QPDFObjectHandle const&); | |
| 32 | 32 | // Remove key, doing nothing if key does not exist |
| 33 | 33 | void removeKey(std::string const& key); |
| 34 | 34 | // If object is null, remove key; otherwise, replace key | ... | ... |
libqpdf/qpdf/QPDF_Stream.hh
| ... | ... | @@ -62,7 +62,7 @@ class QPDF_Stream: public QPDFObject |
| 62 | 62 | void |
| 63 | 63 | addTokenFilter(std::shared_ptr<QPDFObjectHandle::TokenFilter> token_filter); |
| 64 | 64 | |
| 65 | - void replaceDict(QPDFObjectHandle new_dict); | |
| 65 | + void replaceDict(QPDFObjectHandle const& new_dict); | |
| 66 | 66 | |
| 67 | 67 | static void registerStreamFilter( |
| 68 | 68 | std::string const& filter_name, | ... | ... |