mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 10:58:58 +00:00
Add new method QPDFValue::checkOwnership
This commit is contained in:
parent
a1a8f35b63
commit
c6179da961
@ -7,6 +7,26 @@
|
||||
|
||||
static const QPDFObjectHandle null_oh = QPDFObjectHandle::newNull();
|
||||
|
||||
inline void
|
||||
QPDF_Array::checkOwnership(QPDFObjectHandle const& item) const
|
||||
{
|
||||
if (auto obj = item.getObjectPtr()) {
|
||||
if (qpdf) {
|
||||
if (auto item_qpdf = obj->getQPDF()) {
|
||||
if (qpdf != item_qpdf) {
|
||||
throw std::logic_error(
|
||||
"Attempting to add an object from a different QPDF. "
|
||||
"Use QPDF::copyForeignObject to add objects from "
|
||||
"another file.");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw std::logic_error(
|
||||
"Attempting to add an uninitialized object to a QPDF_Array.");
|
||||
}
|
||||
}
|
||||
|
||||
QPDF_Array::QPDF_Array(std::vector<QPDFObjectHandle> const& v) :
|
||||
QPDFValue(::ot_array, "array")
|
||||
{
|
||||
|
@ -42,6 +42,9 @@ class QPDF_Array: public QPDFValue
|
||||
QPDF_Array(std::vector<std::shared_ptr<QPDFObject>>&& items, bool sparse);
|
||||
QPDF_Array(SparseOHArray const& items);
|
||||
QPDF_Array(std::vector<std::shared_ptr<QPDFObject>> const& items);
|
||||
|
||||
void checkOwnership(QPDFObjectHandle const& item) const;
|
||||
|
||||
bool sparse{false};
|
||||
SparseOHArray sp_elements;
|
||||
std::vector<std::shared_ptr<QPDFObject>> elements;
|
||||
|
Loading…
Reference in New Issue
Block a user