diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-02-05 15:18:58 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-02-05 17:29:25 +0100 |
commit | 7fb22740e131d997fb68bc113b8d9b4472e2c908 (patch) | |
tree | 93da9a3babdf591fa1cc286f71fb3d6f2277fa30 /include | |
parent | b48a0ff0e8e1861884b2dac62d98d39f8e194086 (diff) | |
download | qpdf-7fb22740e131d997fb68bc113b8d9b4472e2c908.tar.zst |
Add operator ""_qpdf for creating QPDFObjectHandle literals
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/QPDFObjectHandle.hh | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh index 855c14c2..03d7cb0d 100644 --- a/include/qpdf/QPDFObjectHandle.hh +++ b/include/qpdf/QPDFObjectHandle.hh @@ -395,7 +395,7 @@ class QPDFObjectHandle // object syntax (obj gen R) will cause a logic_error exception to // be thrown. If object_description is provided, it will appear // in the message of any QPDFExc exception thrown for invalid - // syntax. + // syntax. See also the global `operator ""_qpdf` defined below. QPDF_DLL static QPDFObjectHandle parse(std::string const& object_str, std::string const& object_description = ""); @@ -1450,6 +1450,17 @@ class QPDFObjectHandle bool reserved; }; +#ifndef QPDF_NO_QPDF_STRING +// This is short for QPDFObjectHandle::parse, so you can do + +// auto oh = "<< /Key (value) >>"_qpdf; + +// If this is causing problems in your code, define +// QPDF_NO_QPDF_STRING to prevent the declaration from being here. +QPDF_DLL +QPDFObjectHandle operator ""_qpdf(char const* v, size_t len); +#endif // QPDF_NO_QPDF_STRING + class QPDFObjectHandle::QPDFDictItems { // This class allows C++-style iteration, including range-for |