mirror of
https://github.com/qpdf/qpdf.git
synced 2024-06-09 05:32:43 +00:00
Have dictionary/streams mutators take const& where possible
This commit is contained in:
parent
68e721981a
commit
4925f0d18c
|
@ -1025,13 +1025,13 @@ class QPDFObjectHandle
|
||||||
|
|
||||||
// Replace value of key, adding it if it does not exist
|
// Replace value of key, adding it if it does not exist
|
||||||
QPDF_DLL
|
QPDF_DLL
|
||||||
void replaceKey(std::string const& key, QPDFObjectHandle);
|
void replaceKey(std::string const& key, QPDFObjectHandle const&);
|
||||||
// Remove key, doing nothing if key does not exist
|
// Remove key, doing nothing if key does not exist
|
||||||
QPDF_DLL
|
QPDF_DLL
|
||||||
void removeKey(std::string const& key);
|
void removeKey(std::string const& key);
|
||||||
// If the object is null, remove the key. Otherwise, replace it.
|
// If the object is null, remove the key. Otherwise, replace it.
|
||||||
QPDF_DLL
|
QPDF_DLL
|
||||||
void replaceOrRemoveKey(std::string const& key, QPDFObjectHandle);
|
void replaceOrRemoveKey(std::string const& key, QPDFObjectHandle const&);
|
||||||
|
|
||||||
// Methods for stream objects
|
// Methods for stream objects
|
||||||
QPDF_DLL
|
QPDF_DLL
|
||||||
|
@ -1164,7 +1164,7 @@ class QPDFObjectHandle
|
||||||
// may be more convenient in this case than calling getDict and
|
// may be more convenient in this case than calling getDict and
|
||||||
// modifying it for each key. The pdf-create example does this.
|
// modifying it for each key. The pdf-create example does this.
|
||||||
QPDF_DLL
|
QPDF_DLL
|
||||||
void replaceDict(QPDFObjectHandle);
|
void replaceDict(QPDFObjectHandle const&);
|
||||||
|
|
||||||
// Replace this stream's stream data with the given data buffer,
|
// Replace this stream's stream data with the given data buffer,
|
||||||
// and replace the /Filter and /DecodeParms keys in the stream
|
// and replace the /Filter and /DecodeParms keys in the stream
|
||||||
|
|
|
@ -1268,7 +1268,8 @@ QPDFObjectHandle::getOwningQPDF()
|
||||||
// Dictionary mutators
|
// Dictionary mutators
|
||||||
|
|
||||||
void
|
void
|
||||||
QPDFObjectHandle::replaceKey(std::string const& key, QPDFObjectHandle value)
|
QPDFObjectHandle::replaceKey(
|
||||||
|
std::string const& key, QPDFObjectHandle const& value)
|
||||||
{
|
{
|
||||||
if (isDictionary()) {
|
if (isDictionary()) {
|
||||||
checkOwnership(value);
|
checkOwnership(value);
|
||||||
|
@ -1292,7 +1293,7 @@ QPDFObjectHandle::removeKey(std::string const& key)
|
||||||
|
|
||||||
void
|
void
|
||||||
QPDFObjectHandle::replaceOrRemoveKey(
|
QPDFObjectHandle::replaceOrRemoveKey(
|
||||||
std::string const& key, QPDFObjectHandle value)
|
std::string const& key, QPDFObjectHandle const& value)
|
||||||
{
|
{
|
||||||
if (isDictionary()) {
|
if (isDictionary()) {
|
||||||
checkOwnership(value);
|
checkOwnership(value);
|
||||||
|
@ -1334,7 +1335,7 @@ QPDFObjectHandle::isDataModified()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QPDFObjectHandle::replaceDict(QPDFObjectHandle new_dict)
|
QPDFObjectHandle::replaceDict(QPDFObjectHandle const& new_dict)
|
||||||
{
|
{
|
||||||
assertStream();
|
assertStream();
|
||||||
dynamic_cast<QPDF_Stream*>(obj.get())->replaceDict(new_dict);
|
dynamic_cast<QPDF_Stream*>(obj.get())->replaceDict(new_dict);
|
||||||
|
|
|
@ -115,7 +115,8 @@ QPDF_Dictionary::getAsMap() const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QPDF_Dictionary::replaceKey(std::string const& key, QPDFObjectHandle value)
|
QPDF_Dictionary::replaceKey(
|
||||||
|
std::string const& key, QPDFObjectHandle const& value)
|
||||||
{
|
{
|
||||||
// add or replace value
|
// add or replace value
|
||||||
this->items[key] = value;
|
this->items[key] = value;
|
||||||
|
|
|
@ -617,11 +617,11 @@ QPDF_Stream::replaceFilterData(
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QPDF_Stream::replaceDict(QPDFObjectHandle new_dict)
|
QPDF_Stream::replaceDict(QPDFObjectHandle const& new_dict)
|
||||||
{
|
{
|
||||||
this->stream_dict = new_dict;
|
this->stream_dict = new_dict;
|
||||||
setDictDescription();
|
setDictDescription();
|
||||||
QPDFObjectHandle length_obj = new_dict.getKey("/Length");
|
QPDFObjectHandle length_obj = this->stream_dict.getKey("/Length");
|
||||||
if (length_obj.isInteger()) {
|
if (length_obj.isInteger()) {
|
||||||
this->length = QIntC::to_size(length_obj.getUIntValue());
|
this->length = QIntC::to_size(length_obj.getUIntValue());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -28,7 +28,7 @@ class QPDF_Dictionary: public QPDFObject
|
||||||
std::map<std::string, QPDFObjectHandle> const& getAsMap() const;
|
std::map<std::string, QPDFObjectHandle> const& getAsMap() const;
|
||||||
|
|
||||||
// Replace value of key, adding it if it does not exist
|
// Replace value of key, adding it if it does not exist
|
||||||
void replaceKey(std::string const& key, QPDFObjectHandle);
|
void replaceKey(std::string const& key, QPDFObjectHandle const&);
|
||||||
// Remove key, doing nothing if key does not exist
|
// Remove key, doing nothing if key does not exist
|
||||||
void removeKey(std::string const& key);
|
void removeKey(std::string const& key);
|
||||||
// If object is null, remove key; otherwise, replace key
|
// If object is null, remove key; otherwise, replace key
|
||||||
|
|
|
@ -62,7 +62,7 @@ class QPDF_Stream: public QPDFObject
|
||||||
void
|
void
|
||||||
addTokenFilter(std::shared_ptr<QPDFObjectHandle::TokenFilter> token_filter);
|
addTokenFilter(std::shared_ptr<QPDFObjectHandle::TokenFilter> token_filter);
|
||||||
|
|
||||||
void replaceDict(QPDFObjectHandle new_dict);
|
void replaceDict(QPDFObjectHandle const& new_dict);
|
||||||
|
|
||||||
static void registerStreamFilter(
|
static void registerStreamFilter(
|
||||||
std::string const& filter_name,
|
std::string const& filter_name,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user