From dbc5f07b90954c18445ebe725b1a445745726864 Mon Sep 17 00:00:00 2001 From: m-holger Date: Mon, 14 Nov 2022 17:54:12 +0000 Subject: Rename QPDFObject::shallowCopy to copy Add optional parameter shallow. Change logic errors to runtime errors. --- libqpdf/QPDFObjectHandle.cc | 4 ++-- libqpdf/QPDF_Array.cc | 2 +- libqpdf/QPDF_Bool.cc | 2 +- libqpdf/QPDF_Destroyed.cc | 2 +- libqpdf/QPDF_Dictionary.cc | 2 +- libqpdf/QPDF_InlineImage.cc | 2 +- libqpdf/QPDF_Integer.cc | 2 +- libqpdf/QPDF_Name.cc | 2 +- libqpdf/QPDF_Null.cc | 2 +- libqpdf/QPDF_Operator.cc | 2 +- libqpdf/QPDF_Real.cc | 2 +- libqpdf/QPDF_Reserved.cc | 2 +- libqpdf/QPDF_Stream.cc | 4 ++-- libqpdf/QPDF_String.cc | 2 +- libqpdf/QPDF_Unresolved.cc | 2 +- libqpdf/qpdf/QPDFObject_private.hh | 4 ++-- libqpdf/qpdf/QPDFValue.hh | 2 +- libqpdf/qpdf/QPDF_Array.hh | 2 +- libqpdf/qpdf/QPDF_Bool.hh | 2 +- libqpdf/qpdf/QPDF_Destroyed.hh | 2 +- libqpdf/qpdf/QPDF_Dictionary.hh | 2 +- libqpdf/qpdf/QPDF_InlineImage.hh | 2 +- libqpdf/qpdf/QPDF_Integer.hh | 2 +- libqpdf/qpdf/QPDF_Name.hh | 2 +- libqpdf/qpdf/QPDF_Null.hh | 2 +- libqpdf/qpdf/QPDF_Operator.hh | 2 +- libqpdf/qpdf/QPDF_Real.hh | 2 +- libqpdf/qpdf/QPDF_Reserved.hh | 2 +- libqpdf/qpdf/QPDF_Stream.hh | 2 +- libqpdf/qpdf/QPDF_String.hh | 2 +- libqpdf/qpdf/QPDF_Unresolved.hh | 2 +- 31 files changed, 34 insertions(+), 34 deletions(-) diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index d70267cd..02b40c4f 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -2223,7 +2223,7 @@ QPDFObjectHandle::shallowCopyInternal( QTC::TC("qpdf", "QPDFObjectHandle ERR shallow copy stream"); throw std::runtime_error("attempt to make a shallow copy of a stream"); } - new_obj = QPDFObjectHandle(obj->shallowCopy()); + new_obj = QPDFObjectHandle(obj->copy(true)); std::set visited; new_obj.copyObject(visited, false, first_level_only, false); @@ -2268,7 +2268,7 @@ QPDFObjectHandle::copyObject( if (isBool() || isInteger() || isName() || isNull() || isReal() || isString()) { - new_obj = obj->shallowCopy(); + new_obj = obj->copy(true); } else if (isArray()) { std::vector items; auto array = asArray(); diff --git a/libqpdf/QPDF_Array.cc b/libqpdf/QPDF_Array.cc index 2cbdfcec..f33ad99d 100644 --- a/libqpdf/QPDF_Array.cc +++ b/libqpdf/QPDF_Array.cc @@ -29,7 +29,7 @@ QPDF_Array::create(SparseOHArray const& items) } std::shared_ptr -QPDF_Array::shallowCopy() +QPDF_Array::copy(bool shallow) { return create(elements); } diff --git a/libqpdf/QPDF_Bool.cc b/libqpdf/QPDF_Bool.cc index efbfd6c9..05c52f22 100644 --- a/libqpdf/QPDF_Bool.cc +++ b/libqpdf/QPDF_Bool.cc @@ -13,7 +13,7 @@ QPDF_Bool::create(bool value) } std::shared_ptr -QPDF_Bool::shallowCopy() +QPDF_Bool::copy(bool shallow) { return create(val); } diff --git a/libqpdf/QPDF_Destroyed.cc b/libqpdf/QPDF_Destroyed.cc index e12a9975..eb84f3aa 100644 --- a/libqpdf/QPDF_Destroyed.cc +++ b/libqpdf/QPDF_Destroyed.cc @@ -15,7 +15,7 @@ QPDF_Destroyed::getInstance() } std::shared_ptr -QPDF_Destroyed::shallowCopy() +QPDF_Destroyed::copy(bool shallow) { throw std::logic_error( "attempted to shallow copy QPDFObjectHandle from destroyed QPDF"); diff --git a/libqpdf/QPDF_Dictionary.cc b/libqpdf/QPDF_Dictionary.cc index afbaba4b..5b1e03d8 100644 --- a/libqpdf/QPDF_Dictionary.cc +++ b/libqpdf/QPDF_Dictionary.cc @@ -16,7 +16,7 @@ QPDF_Dictionary::create(std::map const& items) } std::shared_ptr -QPDF_Dictionary::shallowCopy() +QPDF_Dictionary::copy(bool shallow) { return create(items); } diff --git a/libqpdf/QPDF_InlineImage.cc b/libqpdf/QPDF_InlineImage.cc index 76318196..3ba9719f 100644 --- a/libqpdf/QPDF_InlineImage.cc +++ b/libqpdf/QPDF_InlineImage.cc @@ -13,7 +13,7 @@ QPDF_InlineImage::create(std::string const& val) } std::shared_ptr -QPDF_InlineImage::shallowCopy() +QPDF_InlineImage::copy(bool shallow) { return create(val); } diff --git a/libqpdf/QPDF_Integer.cc b/libqpdf/QPDF_Integer.cc index 2bcdfef1..716a11e0 100644 --- a/libqpdf/QPDF_Integer.cc +++ b/libqpdf/QPDF_Integer.cc @@ -15,7 +15,7 @@ QPDF_Integer::create(long long value) } std::shared_ptr -QPDF_Integer::shallowCopy() +QPDF_Integer::copy(bool shallow) { return create(val); } diff --git a/libqpdf/QPDF_Name.cc b/libqpdf/QPDF_Name.cc index c86d34b4..47e917a1 100644 --- a/libqpdf/QPDF_Name.cc +++ b/libqpdf/QPDF_Name.cc @@ -17,7 +17,7 @@ QPDF_Name::create(std::string const& name) } std::shared_ptr -QPDF_Name::shallowCopy() +QPDF_Name::copy(bool shallow) { return create(name); } diff --git a/libqpdf/QPDF_Null.cc b/libqpdf/QPDF_Null.cc index f60dda1f..6ec4556c 100644 --- a/libqpdf/QPDF_Null.cc +++ b/libqpdf/QPDF_Null.cc @@ -12,7 +12,7 @@ QPDF_Null::create() } std::shared_ptr -QPDF_Null::shallowCopy() +QPDF_Null::copy(bool shallow) { return create(); } diff --git a/libqpdf/QPDF_Operator.cc b/libqpdf/QPDF_Operator.cc index 547ff40a..e0d64474 100644 --- a/libqpdf/QPDF_Operator.cc +++ b/libqpdf/QPDF_Operator.cc @@ -13,7 +13,7 @@ QPDF_Operator::create(std::string const& val) } std::shared_ptr -QPDF_Operator::shallowCopy() +QPDF_Operator::copy(bool shallow) { return create(val); } diff --git a/libqpdf/QPDF_Real.cc b/libqpdf/QPDF_Real.cc index 85c9ceeb..c092cfe3 100644 --- a/libqpdf/QPDF_Real.cc +++ b/libqpdf/QPDF_Real.cc @@ -29,7 +29,7 @@ QPDF_Real::create(double value, int decimal_places, bool trim_trailing_zeroes) } std::shared_ptr -QPDF_Real::shallowCopy() +QPDF_Real::copy(bool shallow) { return create(val); } diff --git a/libqpdf/QPDF_Reserved.cc b/libqpdf/QPDF_Reserved.cc index b3669320..c675ec7d 100644 --- a/libqpdf/QPDF_Reserved.cc +++ b/libqpdf/QPDF_Reserved.cc @@ -14,7 +14,7 @@ QPDF_Reserved::create() } std::shared_ptr -QPDF_Reserved::shallowCopy() +QPDF_Reserved::copy(bool shallow) { return create(); } diff --git a/libqpdf/QPDF_Stream.cc b/libqpdf/QPDF_Stream.cc index ff2634ed..332eaa37 100644 --- a/libqpdf/QPDF_Stream.cc +++ b/libqpdf/QPDF_Stream.cc @@ -140,9 +140,9 @@ QPDF_Stream::create( } std::shared_ptr -QPDF_Stream::shallowCopy() +QPDF_Stream::copy(bool shallow) { - throw std::logic_error("stream objects cannot be cloned"); + throw std::runtime_error("stream objects cannot be cloned"); } void diff --git a/libqpdf/QPDF_String.cc b/libqpdf/QPDF_String.cc index b37682c9..6e72a96f 100644 --- a/libqpdf/QPDF_String.cc +++ b/libqpdf/QPDF_String.cc @@ -37,7 +37,7 @@ QPDF_String::create_utf16(std::string const& utf8_val) } std::shared_ptr -QPDF_String::shallowCopy() +QPDF_String::copy(bool shallow) { return create(val); } diff --git a/libqpdf/QPDF_Unresolved.cc b/libqpdf/QPDF_Unresolved.cc index c069842b..bef292ce 100644 --- a/libqpdf/QPDF_Unresolved.cc +++ b/libqpdf/QPDF_Unresolved.cc @@ -14,7 +14,7 @@ QPDF_Unresolved::create(QPDF* qpdf, QPDFObjGen const& og) } std::shared_ptr -QPDF_Unresolved::shallowCopy() +QPDF_Unresolved::copy(bool shallow) { throw std::logic_error( "attempted to shallow copy an unresolved QPDFObjectHandle"); diff --git a/libqpdf/qpdf/QPDFObject_private.hh b/libqpdf/qpdf/QPDFObject_private.hh index 42bd02b5..6ca81286 100644 --- a/libqpdf/qpdf/QPDFObject_private.hh +++ b/libqpdf/qpdf/QPDFObject_private.hh @@ -24,9 +24,9 @@ class QPDFObject QPDFObject() = default; std::shared_ptr - shallowCopy() + copy(bool shallow = false) { - return value->shallowCopy(); + return value->copy(shallow); } std::string unparse() diff --git a/libqpdf/qpdf/QPDFValue.hh b/libqpdf/qpdf/QPDFValue.hh index 17dce933..690b3b39 100644 --- a/libqpdf/qpdf/QPDFValue.hh +++ b/libqpdf/qpdf/QPDFValue.hh @@ -20,7 +20,7 @@ class QPDFValue public: virtual ~QPDFValue() = default; - virtual std::shared_ptr shallowCopy() = 0; + virtual std::shared_ptr copy(bool shallow = false) = 0; virtual std::string unparse() = 0; virtual JSON getJSON(int json_version) = 0; virtual void diff --git a/libqpdf/qpdf/QPDF_Array.hh b/libqpdf/qpdf/QPDF_Array.hh index 61482848..0bf3d436 100644 --- a/libqpdf/qpdf/QPDF_Array.hh +++ b/libqpdf/qpdf/QPDF_Array.hh @@ -14,7 +14,7 @@ class QPDF_Array: public QPDFValue static std::shared_ptr create(std::vector const& items); static std::shared_ptr create(SparseOHArray const& items); - virtual std::shared_ptr shallowCopy(); + virtual std::shared_ptr copy(bool shallow = false); virtual std::string unparse(); virtual JSON getJSON(int json_version); virtual void disconnect(); diff --git a/libqpdf/qpdf/QPDF_Bool.hh b/libqpdf/qpdf/QPDF_Bool.hh index 3e45cd8e..215d359a 100644 --- a/libqpdf/qpdf/QPDF_Bool.hh +++ b/libqpdf/qpdf/QPDF_Bool.hh @@ -8,7 +8,7 @@ class QPDF_Bool: public QPDFValue public: virtual ~QPDF_Bool() = default; static std::shared_ptr create(bool val); - virtual std::shared_ptr shallowCopy(); + virtual std::shared_ptr copy(bool shallow = false); virtual std::string unparse(); virtual JSON getJSON(int json_version); bool getVal() const; diff --git a/libqpdf/qpdf/QPDF_Destroyed.hh b/libqpdf/qpdf/QPDF_Destroyed.hh index def4346a..c8e35557 100644 --- a/libqpdf/qpdf/QPDF_Destroyed.hh +++ b/libqpdf/qpdf/QPDF_Destroyed.hh @@ -7,7 +7,7 @@ class QPDF_Destroyed: public QPDFValue { public: virtual ~QPDF_Destroyed() = default; - virtual std::shared_ptr shallowCopy(); + virtual std::shared_ptr copy(bool shallow = false); virtual std::string unparse(); virtual JSON getJSON(int json_version); static std::shared_ptr getInstance(); diff --git a/libqpdf/qpdf/QPDF_Dictionary.hh b/libqpdf/qpdf/QPDF_Dictionary.hh index e6ec76fd..3354a256 100644 --- a/libqpdf/qpdf/QPDF_Dictionary.hh +++ b/libqpdf/qpdf/QPDF_Dictionary.hh @@ -14,7 +14,7 @@ class QPDF_Dictionary: public QPDFValue virtual ~QPDF_Dictionary() = default; static std::shared_ptr create(std::map const& items); - virtual std::shared_ptr shallowCopy(); + virtual std::shared_ptr copy(bool shallow = false); virtual std::string unparse(); virtual JSON getJSON(int json_version); virtual void disconnect(); diff --git a/libqpdf/qpdf/QPDF_InlineImage.hh b/libqpdf/qpdf/QPDF_InlineImage.hh index b7bea9c7..d6d62efd 100644 --- a/libqpdf/qpdf/QPDF_InlineImage.hh +++ b/libqpdf/qpdf/QPDF_InlineImage.hh @@ -8,7 +8,7 @@ class QPDF_InlineImage: public QPDFValue public: virtual ~QPDF_InlineImage() = default; static std::shared_ptr create(std::string const& val); - virtual std::shared_ptr shallowCopy(); + virtual std::shared_ptr copy(bool shallow = false); virtual std::string unparse(); virtual JSON getJSON(int json_version); std::string getVal() const; diff --git a/libqpdf/qpdf/QPDF_Integer.hh b/libqpdf/qpdf/QPDF_Integer.hh index 7e09673c..180bb48a 100644 --- a/libqpdf/qpdf/QPDF_Integer.hh +++ b/libqpdf/qpdf/QPDF_Integer.hh @@ -8,7 +8,7 @@ class QPDF_Integer: public QPDFValue public: virtual ~QPDF_Integer() = default; static std::shared_ptr create(long long value); - virtual std::shared_ptr shallowCopy(); + virtual std::shared_ptr copy(bool shallow = false); virtual std::string unparse(); virtual JSON getJSON(int json_version); long long getVal() const; diff --git a/libqpdf/qpdf/QPDF_Name.hh b/libqpdf/qpdf/QPDF_Name.hh index 74fc7e44..833ac822 100644 --- a/libqpdf/qpdf/QPDF_Name.hh +++ b/libqpdf/qpdf/QPDF_Name.hh @@ -8,7 +8,7 @@ class QPDF_Name: public QPDFValue public: virtual ~QPDF_Name() = default; static std::shared_ptr create(std::string const& name); - virtual std::shared_ptr shallowCopy(); + virtual std::shared_ptr copy(bool shallow = false); virtual std::string unparse(); virtual JSON getJSON(int json_version); std::string getName() const; diff --git a/libqpdf/qpdf/QPDF_Null.hh b/libqpdf/qpdf/QPDF_Null.hh index 68973de9..1a92b214 100644 --- a/libqpdf/qpdf/QPDF_Null.hh +++ b/libqpdf/qpdf/QPDF_Null.hh @@ -8,7 +8,7 @@ class QPDF_Null: public QPDFValue public: virtual ~QPDF_Null() = default; static std::shared_ptr create(); - virtual std::shared_ptr shallowCopy(); + virtual std::shared_ptr copy(bool shallow = false); virtual std::string unparse(); virtual JSON getJSON(int json_version); diff --git a/libqpdf/qpdf/QPDF_Operator.hh b/libqpdf/qpdf/QPDF_Operator.hh index 767c0ba0..f420b793 100644 --- a/libqpdf/qpdf/QPDF_Operator.hh +++ b/libqpdf/qpdf/QPDF_Operator.hh @@ -8,7 +8,7 @@ class QPDF_Operator: public QPDFValue public: virtual ~QPDF_Operator() = default; static std::shared_ptr create(std::string const& val); - virtual std::shared_ptr shallowCopy(); + virtual std::shared_ptr copy(bool shallow = false); virtual std::string unparse(); virtual JSON getJSON(int json_version); std::string getVal() const; diff --git a/libqpdf/qpdf/QPDF_Real.hh b/libqpdf/qpdf/QPDF_Real.hh index dc0f3ff8..cb3c1846 100644 --- a/libqpdf/qpdf/QPDF_Real.hh +++ b/libqpdf/qpdf/QPDF_Real.hh @@ -10,7 +10,7 @@ class QPDF_Real: public QPDFValue static std::shared_ptr create(std::string const& val); static std::shared_ptr create(double value, int decimal_places, bool trim_trailing_zeroes); - virtual std::shared_ptr shallowCopy(); + virtual std::shared_ptr copy(bool shallow = false); virtual std::string unparse(); virtual JSON getJSON(int json_version); std::string getVal(); diff --git a/libqpdf/qpdf/QPDF_Reserved.hh b/libqpdf/qpdf/QPDF_Reserved.hh index f90242a9..8d6c74f8 100644 --- a/libqpdf/qpdf/QPDF_Reserved.hh +++ b/libqpdf/qpdf/QPDF_Reserved.hh @@ -8,7 +8,7 @@ class QPDF_Reserved: public QPDFValue public: virtual ~QPDF_Reserved() = default; static std::shared_ptr create(); - virtual std::shared_ptr shallowCopy(); + virtual std::shared_ptr copy(bool shallow = false); virtual std::string unparse(); virtual JSON getJSON(int json_version); diff --git a/libqpdf/qpdf/QPDF_Stream.hh b/libqpdf/qpdf/QPDF_Stream.hh index 7479b127..3bb9e19a 100644 --- a/libqpdf/qpdf/QPDF_Stream.hh +++ b/libqpdf/qpdf/QPDF_Stream.hh @@ -23,7 +23,7 @@ class QPDF_Stream: public QPDFValue QPDFObjectHandle stream_dict, qpdf_offset_t offset, size_t length); - virtual std::shared_ptr shallowCopy(); + virtual std::shared_ptr copy(bool shallow = false); virtual std::string unparse(); virtual JSON getJSON(int json_version); virtual void setDescription(QPDF*, std::string const&); diff --git a/libqpdf/qpdf/QPDF_String.hh b/libqpdf/qpdf/QPDF_String.hh index a92427e3..d349439a 100644 --- a/libqpdf/qpdf/QPDF_String.hh +++ b/libqpdf/qpdf/QPDF_String.hh @@ -14,7 +14,7 @@ class QPDF_String: public QPDFValue static std::shared_ptr create(std::string const& val); static std::shared_ptr create_utf16(std::string const& utf8_val); - virtual std::shared_ptr shallowCopy(); + virtual std::shared_ptr copy(bool shallow = false); virtual std::string unparse(); std::string unparse(bool force_binary); virtual JSON getJSON(int json_version); diff --git a/libqpdf/qpdf/QPDF_Unresolved.hh b/libqpdf/qpdf/QPDF_Unresolved.hh index efcf4e3d..43d2af31 100644 --- a/libqpdf/qpdf/QPDF_Unresolved.hh +++ b/libqpdf/qpdf/QPDF_Unresolved.hh @@ -8,7 +8,7 @@ class QPDF_Unresolved: public QPDFValue public: virtual ~QPDF_Unresolved() = default; static std::shared_ptr create(QPDF* qpdf, QPDFObjGen const& og); - virtual std::shared_ptr shallowCopy(); + virtual std::shared_ptr copy(bool shallow = false); virtual std::string unparse(); virtual JSON getJSON(int json_version); -- cgit v1.2.3-70-g09d2