diff options
author | Jay Berkenbilt <ejb@ql.org> | 2021-02-21 12:35:53 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2021-02-21 12:36:30 +0100 |
commit | 92fbc6fdf56bad6aff8c9f3f1a3032d5ad36ec51 (patch) | |
tree | 583522ecd2468ef78421fb91a99d866098c12625 /include | |
parent | 60afe4142e4399b12f21aced476df7ef719008b9 (diff) | |
download | qpdf-92fbc6fdf56bad6aff8c9f3f1a3032d5ad36ec51.tar.zst |
QPDFObjectHandle::copyStream
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/QPDF.hh | 15 | ||||
-rw-r--r-- | include/qpdf/QPDFObjectHandle.hh | 16 |
2 files changed, 30 insertions, 1 deletions
diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index ee00b23f..d4b7e775 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -700,6 +700,21 @@ class QPDF }; friend class Resolver; + // StreamCopier class is restricted to QPDFObjectHandle so it can + // copy stream data. + class StreamCopier + { + friend class QPDFObjectHandle; + private: + static void copyStreamData(QPDF* qpdf, + QPDFObjectHandle const& dest, + QPDFObjectHandle const& src) + { + qpdf->copyStreamData(dest, src); + } + }; + friend class Resolver; + // ParseGuard class allows QPDFObjectHandle to detect re-entrant // resolution class ParseGuard diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh index bb877622..07c5b427 100644 --- a/include/qpdf/QPDFObjectHandle.hh +++ b/include/qpdf/QPDFObjectHandle.hh @@ -761,7 +761,8 @@ class QPDFObjectHandle // 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(). + // unsafeShallowCopy(). You can't copy a stream this way. See + // copyStream() instead. QPDF_DLL QPDFObjectHandle shallowCopy(); @@ -776,6 +777,19 @@ class QPDFObjectHandle QPDF_DLL QPDFObjectHandle unsafeShallowCopy(); + // Create a copy of this stream. The new stream and the old stream + // are independent: after the copy, either the original or the + // copy's dictionary or data can be modified without affecting the + // other. This uses StreamDataProvider internally, so no + // unnecessary copies of the stream's data are made. If the source + // stream's data is already being provided by a + // StreamDataProvider, the new stream will use the same one, so + // you have to make sure your StreamDataProvider can handle that + // case. But if you're already using a StreamDataProvider, you + // probably don't need to call this method. + QPDF_DLL + QPDFObjectHandle copyStream(); + // Mutator methods. Use with caution. // Recursively copy this object, making it direct. An exception is |