diff options
author | Jay Berkenbilt <ejb@ql.org> | 2012-06-21 22:14:34 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2012-06-21 22:15:09 +0200 |
commit | d1ebe30ff63a2f79da041e2d0c4718523db1beda (patch) | |
tree | 01daee6636708e83732e526cbe7c49172cc0d759 /libqpdf/QPDFObjectHandle.cc | |
parent | 9689f4cdcff33babafad71378fb26259f0556a99 (diff) | |
download | qpdf-d1ebe30ff63a2f79da041e2d0c4718523db1beda.tar.zst |
Add QPDFObjectHandle::shallowCopy()
Diffstat (limited to 'libqpdf/QPDFObjectHandle.cc')
-rw-r--r-- | libqpdf/QPDFObjectHandle.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index 53d9414c..4e28c405 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -663,6 +663,38 @@ QPDFObjectHandle::newStream(QPDF* qpdf, PointerHolder<Buffer> data) return result; } +QPDFObjectHandle +QPDFObjectHandle::shallowCopy() +{ + assertInitialized(); + + if (isStream()) + { + QTC::TC("qpdf", "QPDFObjectHandle ERR shallow copy stream"); + throw std::runtime_error( + "attempt to make a shallow copy of a stream"); + } + + QPDFObjectHandle new_obj; + if (isArray()) + { + QTC::TC("qpdf", "QPDFObjectHandle shallow copy array"); + new_obj = newArray(getArrayAsVector()); + } + else if (isDictionary()) + { + QTC::TC("qpdf", "QPDFObjectHandle shallow copy dictionary"); + new_obj = newDictionary(getDictAsMap()); + } + else + { + QTC::TC("qpdf", "QPDFObjectHandle shallow copy scalar"); + new_obj = *this; + } + + return new_obj; +} + void QPDFObjectHandle::makeDirectInternal(std::set<int>& visited) { |