Commit 64649e31c3f8ab4cbedb579dc5cb994d8c219018
1 parent
65ef82be
Add `BaseHandle::get` method for simplified access to object handles by key
Showing
2 changed files
with
16 additions
and
0 deletions
include/qpdf/ObjectHandle.hh
| ... | ... | @@ -137,6 +137,8 @@ namespace qpdf |
| 137 | 137 | |
| 138 | 138 | std::string description() const; |
| 139 | 139 | |
| 140 | + inline QPDFObjectHandle const& get(std::string const& key) const; | |
| 141 | + | |
| 140 | 142 | void no_ci_warn_if(bool condition, std::string const& warning) const; |
| 141 | 143 | void no_ci_stop_if(bool condition, std::string const& warning) const; |
| 142 | 144 | void no_ci_stop_damaged_if(bool condition, std::string const& warning) const; | ... | ... |
libqpdf/qpdf/QPDFObjectHandle_private.hh
| ... | ... | @@ -806,6 +806,20 @@ namespace qpdf |
| 806 | 806 | } |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | + /// @brief Retrieves the QPDFObjectHandle const& associated with the given key. | |
| 810 | + /// | |
| 811 | + /// This method provides a convenience alternative to the direct use of the subscript operator | |
| 812 | + /// "(*this)[key]" or "oh()[key]" in derived classes, enabling a simplified and readable way to | |
| 813 | + /// access object handles by key. | |
| 814 | + /// | |
| 815 | + /// @param key The string key used to look up the corresponding QPDFObjectHandle. | |
| 816 | + /// @return A constant reference to the QPDFObjectHandle associated with the specified key. | |
| 817 | + inline QPDFObjectHandle const& | |
| 818 | + BaseHandle::get(std::string const& key) const | |
| 819 | + { | |
| 820 | + return (*this)[key]; | |
| 821 | + } | |
| 822 | + | |
| 809 | 823 | inline bool |
| 810 | 824 | BaseHandle::null() const |
| 811 | 825 | { | ... | ... |