aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-11-14 18:54:12 +0100
committerJay Berkenbilt <jberkenbilt@users.noreply.github.com>2022-11-20 18:07:22 +0100
commitdbc5f07b90954c18445ebe725b1a445745726864 (patch)
treeede2939e0ba2faf657e392b5ce413541e94aa832
parent34a6f8938f0e6d55eeb9f37c0ef23e02fec88932 (diff)
downloadqpdf-dbc5f07b90954c18445ebe725b1a445745726864.tar.zst
Rename QPDFObject::shallowCopy to copy
Add optional parameter shallow. Change logic errors to runtime errors.
-rw-r--r--libqpdf/QPDFObjectHandle.cc4
-rw-r--r--libqpdf/QPDF_Array.cc2
-rw-r--r--libqpdf/QPDF_Bool.cc2
-rw-r--r--libqpdf/QPDF_Destroyed.cc2
-rw-r--r--libqpdf/QPDF_Dictionary.cc2
-rw-r--r--libqpdf/QPDF_InlineImage.cc2
-rw-r--r--libqpdf/QPDF_Integer.cc2
-rw-r--r--libqpdf/QPDF_Name.cc2
-rw-r--r--libqpdf/QPDF_Null.cc2
-rw-r--r--libqpdf/QPDF_Operator.cc2
-rw-r--r--libqpdf/QPDF_Real.cc2
-rw-r--r--libqpdf/QPDF_Reserved.cc2
-rw-r--r--libqpdf/QPDF_Stream.cc4
-rw-r--r--libqpdf/QPDF_String.cc2
-rw-r--r--libqpdf/QPDF_Unresolved.cc2
-rw-r--r--libqpdf/qpdf/QPDFObject_private.hh4
-rw-r--r--libqpdf/qpdf/QPDFValue.hh2
-rw-r--r--libqpdf/qpdf/QPDF_Array.hh2
-rw-r--r--libqpdf/qpdf/QPDF_Bool.hh2
-rw-r--r--libqpdf/qpdf/QPDF_Destroyed.hh2
-rw-r--r--libqpdf/qpdf/QPDF_Dictionary.hh2
-rw-r--r--libqpdf/qpdf/QPDF_InlineImage.hh2
-rw-r--r--libqpdf/qpdf/QPDF_Integer.hh2
-rw-r--r--libqpdf/qpdf/QPDF_Name.hh2
-rw-r--r--libqpdf/qpdf/QPDF_Null.hh2
-rw-r--r--libqpdf/qpdf/QPDF_Operator.hh2
-rw-r--r--libqpdf/qpdf/QPDF_Real.hh2
-rw-r--r--libqpdf/qpdf/QPDF_Reserved.hh2
-rw-r--r--libqpdf/qpdf/QPDF_Stream.hh2
-rw-r--r--libqpdf/qpdf/QPDF_String.hh2
-rw-r--r--libqpdf/qpdf/QPDF_Unresolved.hh2
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<QPDFObjGen> 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<QPDFObjectHandle> 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<QPDFObject>
-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<QPDFObject>
-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<QPDFObject>
-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<std::string, QPDFObjectHandle> const& items)
}
std::shared_ptr<QPDFObject>
-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<QPDFObject>
-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<QPDFObject>
-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<QPDFObject>
-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<QPDFObject>
-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<QPDFObject>
-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<QPDFObject>
-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<QPDFObject>
-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<QPDFObject>
-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<QPDFObject>
-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<QPDFObject>
-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<QPDFObject>
- 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<QPDFObject> shallowCopy() = 0;
+ virtual std::shared_ptr<QPDFObject> 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<QPDFObject>
create(std::vector<QPDFObjectHandle> const& items);
static std::shared_ptr<QPDFObject> create(SparseOHArray const& items);
- virtual std::shared_ptr<QPDFObject> shallowCopy();
+ virtual std::shared_ptr<QPDFObject> 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<QPDFObject> create(bool val);
- virtual std::shared_ptr<QPDFObject> shallowCopy();
+ virtual std::shared_ptr<QPDFObject> 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<QPDFObject> shallowCopy();
+ virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
virtual std::string unparse();
virtual JSON getJSON(int json_version);
static std::shared_ptr<QPDFValue> 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<QPDFObject>
create(std::map<std::string, QPDFObjectHandle> const& items);
- virtual std::shared_ptr<QPDFObject> shallowCopy();
+ virtual std::shared_ptr<QPDFObject> 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<QPDFObject> create(std::string const& val);
- virtual std::shared_ptr<QPDFObject> shallowCopy();
+ virtual std::shared_ptr<QPDFObject> 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<QPDFObject> create(long long value);
- virtual std::shared_ptr<QPDFObject> shallowCopy();
+ virtual std::shared_ptr<QPDFObject> 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<QPDFObject> create(std::string const& name);
- virtual std::shared_ptr<QPDFObject> shallowCopy();
+ virtual std::shared_ptr<QPDFObject> 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<QPDFObject> create();
- virtual std::shared_ptr<QPDFObject> shallowCopy();
+ virtual std::shared_ptr<QPDFObject> 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<QPDFObject> create(std::string const& val);
- virtual std::shared_ptr<QPDFObject> shallowCopy();
+ virtual std::shared_ptr<QPDFObject> 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<QPDFObject> create(std::string const& val);
static std::shared_ptr<QPDFObject>
create(double value, int decimal_places, bool trim_trailing_zeroes);
- virtual std::shared_ptr<QPDFObject> shallowCopy();
+ virtual std::shared_ptr<QPDFObject> 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<QPDFObject> create();
- virtual std::shared_ptr<QPDFObject> shallowCopy();
+ virtual std::shared_ptr<QPDFObject> 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<QPDFObject> shallowCopy();
+ virtual std::shared_ptr<QPDFObject> 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<QPDFObject> create(std::string const& val);
static std::shared_ptr<QPDFObject>
create_utf16(std::string const& utf8_val);
- virtual std::shared_ptr<QPDFObject> shallowCopy();
+ virtual std::shared_ptr<QPDFObject> 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<QPDFObject> create(QPDF* qpdf, QPDFObjGen const& og);
- virtual std::shared_ptr<QPDFObject> shallowCopy();
+ virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
virtual std::string unparse();
virtual JSON getJSON(int json_version);