From 64649e31c3f8ab4cbedb579dc5cb994d8c219018 Mon Sep 17 00:00:00 2001 From: m-holger Date: Mon, 10 Nov 2025 10:17:47 +0000 Subject: [PATCH] Add `BaseHandle::get` method for simplified access to object handles by key --- include/qpdf/ObjectHandle.hh | 2 ++ libqpdf/qpdf/QPDFObjectHandle_private.hh | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/include/qpdf/ObjectHandle.hh b/include/qpdf/ObjectHandle.hh index 478efcb..02b6674 100644 --- a/include/qpdf/ObjectHandle.hh +++ b/include/qpdf/ObjectHandle.hh @@ -137,6 +137,8 @@ namespace qpdf std::string description() const; + inline QPDFObjectHandle const& get(std::string const& key) const; + void no_ci_warn_if(bool condition, std::string const& warning) const; void no_ci_stop_if(bool condition, std::string const& warning) const; void no_ci_stop_damaged_if(bool condition, std::string const& warning) const; diff --git a/libqpdf/qpdf/QPDFObjectHandle_private.hh b/libqpdf/qpdf/QPDFObjectHandle_private.hh index 51b7897..cc30057 100644 --- a/libqpdf/qpdf/QPDFObjectHandle_private.hh +++ b/libqpdf/qpdf/QPDFObjectHandle_private.hh @@ -806,6 +806,20 @@ namespace qpdf } } + /// @brief Retrieves the QPDFObjectHandle const& associated with the given key. + /// + /// This method provides a convenience alternative to the direct use of the subscript operator + /// "(*this)[key]" or "oh()[key]" in derived classes, enabling a simplified and readable way to + /// access object handles by key. + /// + /// @param key The string key used to look up the corresponding QPDFObjectHandle. + /// @return A constant reference to the QPDFObjectHandle associated with the specified key. + inline QPDFObjectHandle const& + BaseHandle::get(std::string const& key) const + { + return (*this)[key]; + } + inline bool BaseHandle::null() const { -- libgit2 0.21.4