Commit 722ca8e0839a21f9210903cfa66c062beddb279c
1 parent
3a2e6764
Add `operator==` to `BaseHandle` for object equality comparison
Showing
2 changed files
with
7 additions
and
1 deletions
include/qpdf/ObjectHandle.hh
| @@ -61,6 +61,13 @@ namespace qpdf | @@ -61,6 +61,13 @@ namespace qpdf | ||
| 61 | 61 | ||
| 62 | // The rest of the header file is for qpdf internal use only. | 62 | // The rest of the header file is for qpdf internal use only. |
| 63 | 63 | ||
| 64 | + // Return true if both object handles refer to the same underlying object. | ||
| 65 | + bool | ||
| 66 | + operator==(BaseHandle const& other) const | ||
| 67 | + { | ||
| 68 | + return obj == other.obj; | ||
| 69 | + } | ||
| 70 | + | ||
| 64 | // For arrays, return the number of items in the array. | 71 | // For arrays, return the number of items in the array. |
| 65 | // For null-like objects, return 0. | 72 | // For null-like objects, return 0. |
| 66 | // For all other objects, return 1. | 73 | // For all other objects, return 1. |
libqpdf/QPDF_Array.cc
| @@ -400,7 +400,6 @@ QPDFObjectHandle::getArrayItem(int n) const | @@ -400,7 +400,6 @@ QPDFObjectHandle::getArrayItem(int n) const | ||
| 400 | return newNull(); | 400 | return newNull(); |
| 401 | } | 401 | } |
| 402 | objectWarning("returning null for out of bounds array access"); | 402 | objectWarning("returning null for out of bounds array access"); |
| 403 | - | ||
| 404 | } else { | 403 | } else { |
| 405 | typeWarning("array", "returning null"); | 404 | typeWarning("array", "returning null"); |
| 406 | } | 405 | } |