Commit dbc5f07b90954c18445ebe725b1a445745726864
Committed by
Jay Berkenbilt
1 parent
34a6f893
Rename QPDFObject::shallowCopy to copy
Add optional parameter shallow. Change logic errors to runtime errors.
Showing
31 changed files
with
34 additions
and
34 deletions
libqpdf/QPDFObjectHandle.cc
| ... | ... | @@ -2223,7 +2223,7 @@ QPDFObjectHandle::shallowCopyInternal( |
| 2223 | 2223 | QTC::TC("qpdf", "QPDFObjectHandle ERR shallow copy stream"); |
| 2224 | 2224 | throw std::runtime_error("attempt to make a shallow copy of a stream"); |
| 2225 | 2225 | } |
| 2226 | - new_obj = QPDFObjectHandle(obj->shallowCopy()); | |
| 2226 | + new_obj = QPDFObjectHandle(obj->copy(true)); | |
| 2227 | 2227 | |
| 2228 | 2228 | std::set<QPDFObjGen> visited; |
| 2229 | 2229 | new_obj.copyObject(visited, false, first_level_only, false); |
| ... | ... | @@ -2268,7 +2268,7 @@ QPDFObjectHandle::copyObject( |
| 2268 | 2268 | |
| 2269 | 2269 | if (isBool() || isInteger() || isName() || isNull() || isReal() || |
| 2270 | 2270 | isString()) { |
| 2271 | - new_obj = obj->shallowCopy(); | |
| 2271 | + new_obj = obj->copy(true); | |
| 2272 | 2272 | } else if (isArray()) { |
| 2273 | 2273 | std::vector<QPDFObjectHandle> items; |
| 2274 | 2274 | auto array = asArray(); | ... | ... |
libqpdf/QPDF_Array.cc
libqpdf/QPDF_Bool.cc
libqpdf/QPDF_Destroyed.cc
libqpdf/QPDF_Dictionary.cc
libqpdf/QPDF_InlineImage.cc
libqpdf/QPDF_Integer.cc
libqpdf/QPDF_Name.cc
libqpdf/QPDF_Null.cc
libqpdf/QPDF_Operator.cc
libqpdf/QPDF_Real.cc
libqpdf/QPDF_Reserved.cc
libqpdf/QPDF_Stream.cc
| ... | ... | @@ -140,9 +140,9 @@ QPDF_Stream::create( |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | std::shared_ptr<QPDFObject> |
| 143 | -QPDF_Stream::shallowCopy() | |
| 143 | +QPDF_Stream::copy(bool shallow) | |
| 144 | 144 | { |
| 145 | - throw std::logic_error("stream objects cannot be cloned"); | |
| 145 | + throw std::runtime_error("stream objects cannot be cloned"); | |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | void | ... | ... |
libqpdf/QPDF_String.cc
libqpdf/QPDF_Unresolved.cc
| ... | ... | @@ -14,7 +14,7 @@ QPDF_Unresolved::create(QPDF* qpdf, QPDFObjGen const& og) |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | std::shared_ptr<QPDFObject> |
| 17 | -QPDF_Unresolved::shallowCopy() | |
| 17 | +QPDF_Unresolved::copy(bool shallow) | |
| 18 | 18 | { |
| 19 | 19 | throw std::logic_error( |
| 20 | 20 | "attempted to shallow copy an unresolved QPDFObjectHandle"); | ... | ... |
libqpdf/qpdf/QPDFObject_private.hh
libqpdf/qpdf/QPDFValue.hh
| ... | ... | @@ -20,7 +20,7 @@ class QPDFValue |
| 20 | 20 | public: |
| 21 | 21 | virtual ~QPDFValue() = default; |
| 22 | 22 | |
| 23 | - virtual std::shared_ptr<QPDFObject> shallowCopy() = 0; | |
| 23 | + virtual std::shared_ptr<QPDFObject> copy(bool shallow = false) = 0; | |
| 24 | 24 | virtual std::string unparse() = 0; |
| 25 | 25 | virtual JSON getJSON(int json_version) = 0; |
| 26 | 26 | virtual void | ... | ... |
libqpdf/qpdf/QPDF_Array.hh
| ... | ... | @@ -14,7 +14,7 @@ class QPDF_Array: public QPDFValue |
| 14 | 14 | static std::shared_ptr<QPDFObject> |
| 15 | 15 | create(std::vector<QPDFObjectHandle> const& items); |
| 16 | 16 | static std::shared_ptr<QPDFObject> create(SparseOHArray const& items); |
| 17 | - virtual std::shared_ptr<QPDFObject> shallowCopy(); | |
| 17 | + virtual std::shared_ptr<QPDFObject> copy(bool shallow = false); | |
| 18 | 18 | virtual std::string unparse(); |
| 19 | 19 | virtual JSON getJSON(int json_version); |
| 20 | 20 | virtual void disconnect(); | ... | ... |
libqpdf/qpdf/QPDF_Bool.hh
| ... | ... | @@ -8,7 +8,7 @@ class QPDF_Bool: public QPDFValue |
| 8 | 8 | public: |
| 9 | 9 | virtual ~QPDF_Bool() = default; |
| 10 | 10 | static std::shared_ptr<QPDFObject> create(bool val); |
| 11 | - virtual std::shared_ptr<QPDFObject> shallowCopy(); | |
| 11 | + virtual std::shared_ptr<QPDFObject> copy(bool shallow = false); | |
| 12 | 12 | virtual std::string unparse(); |
| 13 | 13 | virtual JSON getJSON(int json_version); |
| 14 | 14 | bool getVal() const; | ... | ... |
libqpdf/qpdf/QPDF_Destroyed.hh
| ... | ... | @@ -7,7 +7,7 @@ class QPDF_Destroyed: public QPDFValue |
| 7 | 7 | { |
| 8 | 8 | public: |
| 9 | 9 | virtual ~QPDF_Destroyed() = default; |
| 10 | - virtual std::shared_ptr<QPDFObject> shallowCopy(); | |
| 10 | + virtual std::shared_ptr<QPDFObject> copy(bool shallow = false); | |
| 11 | 11 | virtual std::string unparse(); |
| 12 | 12 | virtual JSON getJSON(int json_version); |
| 13 | 13 | static std::shared_ptr<QPDFValue> getInstance(); | ... | ... |
libqpdf/qpdf/QPDF_Dictionary.hh
| ... | ... | @@ -14,7 +14,7 @@ class QPDF_Dictionary: public QPDFValue |
| 14 | 14 | virtual ~QPDF_Dictionary() = default; |
| 15 | 15 | static std::shared_ptr<QPDFObject> |
| 16 | 16 | create(std::map<std::string, QPDFObjectHandle> const& items); |
| 17 | - virtual std::shared_ptr<QPDFObject> shallowCopy(); | |
| 17 | + virtual std::shared_ptr<QPDFObject> copy(bool shallow = false); | |
| 18 | 18 | virtual std::string unparse(); |
| 19 | 19 | virtual JSON getJSON(int json_version); |
| 20 | 20 | virtual void disconnect(); | ... | ... |
libqpdf/qpdf/QPDF_InlineImage.hh
| ... | ... | @@ -8,7 +8,7 @@ class QPDF_InlineImage: public QPDFValue |
| 8 | 8 | public: |
| 9 | 9 | virtual ~QPDF_InlineImage() = default; |
| 10 | 10 | static std::shared_ptr<QPDFObject> create(std::string const& val); |
| 11 | - virtual std::shared_ptr<QPDFObject> shallowCopy(); | |
| 11 | + virtual std::shared_ptr<QPDFObject> copy(bool shallow = false); | |
| 12 | 12 | virtual std::string unparse(); |
| 13 | 13 | virtual JSON getJSON(int json_version); |
| 14 | 14 | std::string getVal() const; | ... | ... |
libqpdf/qpdf/QPDF_Integer.hh
| ... | ... | @@ -8,7 +8,7 @@ class QPDF_Integer: public QPDFValue |
| 8 | 8 | public: |
| 9 | 9 | virtual ~QPDF_Integer() = default; |
| 10 | 10 | static std::shared_ptr<QPDFObject> create(long long value); |
| 11 | - virtual std::shared_ptr<QPDFObject> shallowCopy(); | |
| 11 | + virtual std::shared_ptr<QPDFObject> copy(bool shallow = false); | |
| 12 | 12 | virtual std::string unparse(); |
| 13 | 13 | virtual JSON getJSON(int json_version); |
| 14 | 14 | long long getVal() const; | ... | ... |
libqpdf/qpdf/QPDF_Name.hh
| ... | ... | @@ -8,7 +8,7 @@ class QPDF_Name: public QPDFValue |
| 8 | 8 | public: |
| 9 | 9 | virtual ~QPDF_Name() = default; |
| 10 | 10 | static std::shared_ptr<QPDFObject> create(std::string const& name); |
| 11 | - virtual std::shared_ptr<QPDFObject> shallowCopy(); | |
| 11 | + virtual std::shared_ptr<QPDFObject> copy(bool shallow = false); | |
| 12 | 12 | virtual std::string unparse(); |
| 13 | 13 | virtual JSON getJSON(int json_version); |
| 14 | 14 | std::string getName() const; | ... | ... |
libqpdf/qpdf/QPDF_Null.hh
| ... | ... | @@ -8,7 +8,7 @@ class QPDF_Null: public QPDFValue |
| 8 | 8 | public: |
| 9 | 9 | virtual ~QPDF_Null() = default; |
| 10 | 10 | static std::shared_ptr<QPDFObject> create(); |
| 11 | - virtual std::shared_ptr<QPDFObject> shallowCopy(); | |
| 11 | + virtual std::shared_ptr<QPDFObject> copy(bool shallow = false); | |
| 12 | 12 | virtual std::string unparse(); |
| 13 | 13 | virtual JSON getJSON(int json_version); |
| 14 | 14 | ... | ... |
libqpdf/qpdf/QPDF_Operator.hh
| ... | ... | @@ -8,7 +8,7 @@ class QPDF_Operator: public QPDFValue |
| 8 | 8 | public: |
| 9 | 9 | virtual ~QPDF_Operator() = default; |
| 10 | 10 | static std::shared_ptr<QPDFObject> create(std::string const& val); |
| 11 | - virtual std::shared_ptr<QPDFObject> shallowCopy(); | |
| 11 | + virtual std::shared_ptr<QPDFObject> copy(bool shallow = false); | |
| 12 | 12 | virtual std::string unparse(); |
| 13 | 13 | virtual JSON getJSON(int json_version); |
| 14 | 14 | std::string getVal() const; | ... | ... |
libqpdf/qpdf/QPDF_Real.hh
| ... | ... | @@ -10,7 +10,7 @@ class QPDF_Real: public QPDFValue |
| 10 | 10 | static std::shared_ptr<QPDFObject> create(std::string const& val); |
| 11 | 11 | static std::shared_ptr<QPDFObject> |
| 12 | 12 | create(double value, int decimal_places, bool trim_trailing_zeroes); |
| 13 | - virtual std::shared_ptr<QPDFObject> shallowCopy(); | |
| 13 | + virtual std::shared_ptr<QPDFObject> copy(bool shallow = false); | |
| 14 | 14 | virtual std::string unparse(); |
| 15 | 15 | virtual JSON getJSON(int json_version); |
| 16 | 16 | std::string getVal(); | ... | ... |
libqpdf/qpdf/QPDF_Reserved.hh
| ... | ... | @@ -8,7 +8,7 @@ class QPDF_Reserved: public QPDFValue |
| 8 | 8 | public: |
| 9 | 9 | virtual ~QPDF_Reserved() = default; |
| 10 | 10 | static std::shared_ptr<QPDFObject> create(); |
| 11 | - virtual std::shared_ptr<QPDFObject> shallowCopy(); | |
| 11 | + virtual std::shared_ptr<QPDFObject> copy(bool shallow = false); | |
| 12 | 12 | virtual std::string unparse(); |
| 13 | 13 | virtual JSON getJSON(int json_version); |
| 14 | 14 | ... | ... |
libqpdf/qpdf/QPDF_Stream.hh
| ... | ... | @@ -23,7 +23,7 @@ class QPDF_Stream: public QPDFValue |
| 23 | 23 | QPDFObjectHandle stream_dict, |
| 24 | 24 | qpdf_offset_t offset, |
| 25 | 25 | size_t length); |
| 26 | - virtual std::shared_ptr<QPDFObject> shallowCopy(); | |
| 26 | + virtual std::shared_ptr<QPDFObject> copy(bool shallow = false); | |
| 27 | 27 | virtual std::string unparse(); |
| 28 | 28 | virtual JSON getJSON(int json_version); |
| 29 | 29 | virtual void setDescription(QPDF*, std::string const&); | ... | ... |
libqpdf/qpdf/QPDF_String.hh
| ... | ... | @@ -14,7 +14,7 @@ class QPDF_String: public QPDFValue |
| 14 | 14 | static std::shared_ptr<QPDFObject> create(std::string const& val); |
| 15 | 15 | static std::shared_ptr<QPDFObject> |
| 16 | 16 | create_utf16(std::string const& utf8_val); |
| 17 | - virtual std::shared_ptr<QPDFObject> shallowCopy(); | |
| 17 | + virtual std::shared_ptr<QPDFObject> copy(bool shallow = false); | |
| 18 | 18 | virtual std::string unparse(); |
| 19 | 19 | std::string unparse(bool force_binary); |
| 20 | 20 | virtual JSON getJSON(int json_version); | ... | ... |
libqpdf/qpdf/QPDF_Unresolved.hh
| ... | ... | @@ -8,7 +8,7 @@ class QPDF_Unresolved: public QPDFValue |
| 8 | 8 | public: |
| 9 | 9 | virtual ~QPDF_Unresolved() = default; |
| 10 | 10 | static std::shared_ptr<QPDFObject> create(QPDF* qpdf, QPDFObjGen const& og); |
| 11 | - virtual std::shared_ptr<QPDFObject> shallowCopy(); | |
| 11 | + virtual std::shared_ptr<QPDFObject> copy(bool shallow = false); | |
| 12 | 12 | virtual std::string unparse(); |
| 13 | 13 | virtual JSON getJSON(int json_version); |
| 14 | 14 | ... | ... |