diff options
author | Jay Berkenbilt <ejb@ql.org> | 2020-04-02 23:52:21 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2020-04-03 18:16:24 +0200 |
commit | 38afdcea7b08226aa6cc12a8fcda93a6f35a0a18 (patch) | |
tree | 963a1949e6e28a5f104c6d650f24af56e301ea1e /include | |
parent | 07afb668b14e4b71062b76b1c8fbfb1d88e1d425 (diff) | |
download | qpdf-38afdcea7b08226aa6cc12a8fcda93a6f35a0a18.tar.zst |
Add QPDFObjectHandle::unsafeShallowCopy
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/QPDFObjectHandle.hh | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh index 38f29106..dcb7de35 100644 --- a/include/qpdf/QPDFObjectHandle.hh +++ b/include/qpdf/QPDFObjectHandle.hh @@ -670,10 +670,24 @@ class QPDFObjectHandle // traverse across indirect object boundaries. That means that, // for dictionaries and arrays, any keys or items that were // indirect objects will still be indirect objects that point to - // the same place. + // the same place. In the strictest sense, this is not a shallow + // copy because it recursively descends arrays and dictionaries; + // it just doesn't cross over indirect objects. See also + // unsafeShallowCopy(). QPDF_DLL QPDFObjectHandle shallowCopy(); + // Create a true shallow copy of an array or dictionary, just + // copying the immediate items (array) or keys (dictionary). This + // is "unsafe" because, if you *modify* any of the items in the + // copy, you are modifying the original, which is almost never + // what you want. However, if your intention is merely to + // *replace* top-level items or keys and not to modify lower-level + // items in the copy, this method is much faster than + // shallowCopy(). + QPDF_DLL + QPDFObjectHandle unsafeShallowCopy(); + // Mutator methods. Use with caution. // Recursively copy this object, making it direct. Throws an @@ -1053,7 +1067,9 @@ class QPDFObjectHandle void objectWarning(std::string const& warning); void assertType(char const* type_name, bool istype); void dereference(); - void copyObject(std::set<QPDFObjGen>& visited, bool cross_indirect); + void copyObject(std::set<QPDFObjGen>& visited, bool cross_indirect, + bool first_level_only); + void shallowCopyInternal(QPDFObjectHandle& oh, bool first_level_only); void releaseResolved(); static void setObjectDescriptionFromInput( QPDFObjectHandle, QPDF*, std::string const&, |