diff options
author | m-holger <m-holger@kubitscheck.org> | 2023-02-15 11:11:38 +0100 |
---|---|---|
committer | m-holger <m-holger@kubitscheck.org> | 2023-02-18 09:33:08 +0100 |
commit | 32907fc14c663e95df0f7c62905b82389c0024a2 (patch) | |
tree | 9e32a7905a436453d5d1920446006d2d4bea2426 /libqpdf/QPDFValue.cc | |
parent | d58ec90310c93653ab42bcb7373a38e3f8d43362 (diff) | |
download | qpdf-32907fc14c663e95df0f7c62905b82389c0024a2.tar.zst |
Change type of QPDFValue::object_description to std::shared_ptr<std::variant>
Also, name the type QPDFValue::Description.
Diffstat (limited to 'libqpdf/QPDFValue.cc')
-rw-r--r-- | libqpdf/QPDFValue.cc | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/libqpdf/QPDFValue.cc b/libqpdf/QPDFValue.cc index 19679df2..7c5b30a6 100644 --- a/libqpdf/QPDFValue.cc +++ b/libqpdf/QPDFValue.cc @@ -13,16 +13,28 @@ QPDFValue::do_create(QPDFValue* object) std::string QPDFValue::getDescription() { - auto description = object_description ? *object_description : ""; - if (auto pos = description.find("$OG"); pos != std::string::npos) { - description.replace(pos, 3, og.unparse(' ')); - } - if (auto pos = description.find("$PO"); pos != std::string::npos) { - qpdf_offset_t shift = (type_code == ::ot_dictionary) ? 2 - : (type_code == ::ot_array) ? 1 - : 0; + if (object_description) { + switch (object_description->index()) { + case 0: + { + auto description = std::get<0>(*object_description); + + if (auto pos = description.find("$OG"); + pos != std::string::npos) { + description.replace(pos, 3, og.unparse(' ')); + } + if (auto pos = description.find("$PO"); + pos != std::string::npos) { + qpdf_offset_t shift = (type_code == ::ot_dictionary) ? 2 + : (type_code == ::ot_array) ? 1 + : 0; - description.replace(pos, 3, std::to_string(parsed_offset + shift)); + description.replace( + pos, 3, std::to_string(parsed_offset + shift)); + } + return description; + } + } } - return description; + return {}; } |