Commit edbaeff208d8a34d23b7330b791ac04f78918de7
1 parent
277779a3
Add `nullify` method to `BaseHandle` for setting objects to a mutable null.
Showing
2 changed files
with
10 additions
and
0 deletions
include/qpdf/ObjectHandle.hh
| @@ -130,6 +130,8 @@ namespace qpdf | @@ -130,6 +130,8 @@ namespace qpdf | ||
| 130 | inline void assign(qpdf_object_type_e required, BaseHandle const& other); | 130 | inline void assign(qpdf_object_type_e required, BaseHandle const& other); |
| 131 | inline void assign(qpdf_object_type_e required, BaseHandle&& other); | 131 | inline void assign(qpdf_object_type_e required, BaseHandle&& other); |
| 132 | 132 | ||
| 133 | + inline void nullify(); | ||
| 134 | + | ||
| 133 | std::string description() const; | 135 | std::string description() const; |
| 134 | 136 | ||
| 135 | void no_ci_warn_if(bool condition, std::string const& warning) const; | 137 | void no_ci_warn_if(bool condition, std::string const& warning) const; |
libqpdf/qpdf/QPDFObjectHandle_private.hh
| @@ -812,6 +812,14 @@ namespace qpdf | @@ -812,6 +812,14 @@ namespace qpdf | ||
| 812 | return !obj || type_code() == ::ot_null; | 812 | return !obj || type_code() == ::ot_null; |
| 813 | } | 813 | } |
| 814 | 814 | ||
| 815 | + inline void | ||
| 816 | + BaseHandle::nullify() | ||
| 817 | + { | ||
| 818 | + if (obj) { | ||
| 819 | + obj = QPDFObject::create<QPDF_Null>(); | ||
| 820 | + } | ||
| 821 | + } | ||
| 822 | + | ||
| 815 | inline qpdf_offset_t | 823 | inline qpdf_offset_t |
| 816 | BaseHandle::offset() const | 824 | BaseHandle::offset() const |
| 817 | { | 825 | { |