Commit 56c923d1096b0317d978bdadeb44e8198053286c

Authored by m-holger
Committed by Jay Berkenbilt
1 parent d7b47076

Add QPDFObjectHandle operator bool

include/qpdf/QPDFObjectHandle.hh
@@ -334,6 +334,11 @@ class QPDFObjectHandle @@ -334,6 +334,11 @@ class QPDFObjectHandle
334 QPDF_DLL 334 QPDF_DLL
335 inline bool isInitialized() const; 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 // This method returns true if the QPDFObjectHandle objects point 342 // This method returns true if the QPDFObjectHandle objects point
338 // to exactly the same underlying object, meaning that changes to 343 // to exactly the same underlying object, meaning that changes to
339 // one are reflected in the other, or "if you paint one, the other 344 // one are reflected in the other, or "if you paint one, the other
@@ -1863,6 +1868,11 @@ QPDFObjectHandle::isIndirect() const @@ -1863,6 +1868,11 @@ QPDFObjectHandle::isIndirect() const
1863 return (obj != nullptr) && (getObjectID() != 0); 1868 return (obj != nullptr) && (getObjectID() != 0);
1864 } 1869 }
1865 1870
  1871 +inline QPDFObjectHandle::operator bool() const
  1872 +{
  1873 + return obj != nullptr;
  1874 +}
  1875 +
1866 inline bool 1876 inline bool
1867 QPDFObjectHandle::isInitialized() const 1877 QPDFObjectHandle::isInitialized() const
1868 { 1878 {