Commit 56c923d1096b0317d978bdadeb44e8198053286c
Committed by
Jay Berkenbilt
1 parent
d7b47076
Add QPDFObjectHandle operator bool
Showing
1 changed file
with
10 additions
and
0 deletions
include/qpdf/QPDFObjectHandle.hh
| ... | ... | @@ -334,6 +334,11 @@ class QPDFObjectHandle |
| 334 | 334 | QPDF_DLL |
| 335 | 335 | inline bool isInitialized() const; |
| 336 | 336 | |
| 337 | + // Return true if the QPDFObjectHandle is initialized. This allows object | |
| 338 | + // handles to be used in if statements with initializer. | |
| 339 | + QPDF_DLL | |
| 340 | + inline operator bool() const; | |
| 341 | + | |
| 337 | 342 | // This method returns true if the QPDFObjectHandle objects point |
| 338 | 343 | // to exactly the same underlying object, meaning that changes to |
| 339 | 344 | // one are reflected in the other, or "if you paint one, the other |
| ... | ... | @@ -1863,6 +1868,11 @@ QPDFObjectHandle::isIndirect() const |
| 1863 | 1868 | return (obj != nullptr) && (getObjectID() != 0); |
| 1864 | 1869 | } |
| 1865 | 1870 | |
| 1871 | +inline QPDFObjectHandle::operator bool() const | |
| 1872 | +{ | |
| 1873 | + return obj != nullptr; | |
| 1874 | +} | |
| 1875 | + | |
| 1866 | 1876 | inline bool |
| 1867 | 1877 | QPDFObjectHandle::isInitialized() const |
| 1868 | 1878 | { | ... | ... |