2021-04-30 18:23:17 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, Matthew Olsson <mattco@serenityos.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <LibPDF/Object.h>
|
|
|
|
|
#include <LibPDF/Value.h>
|
|
|
|
|
|
|
|
|
|
namespace PDF {
|
|
|
|
|
|
2022-12-06 01:12:49 +00:00
|
|
|
DeprecatedString Value::to_deprecated_string(int indent) const
|
2021-04-30 18:23:17 -07:00
|
|
|
{
|
2021-09-19 20:56:05 +02:00
|
|
|
return visit(
|
2022-12-04 18:02:33 +00:00
|
|
|
[&](Empty const&) -> DeprecatedString {
|
2021-09-19 20:56:05 +02:00
|
|
|
// Return type deduction means that we can't use implicit conversions.
|
|
|
|
|
return "<empty>";
|
|
|
|
|
},
|
2022-12-04 18:02:33 +00:00
|
|
|
[&](std::nullptr_t const&) -> DeprecatedString {
|
2021-09-19 20:56:05 +02:00
|
|
|
return "null";
|
|
|
|
|
},
|
2022-12-04 18:02:33 +00:00
|
|
|
[&](bool const& b) -> DeprecatedString {
|
2021-09-19 20:56:05 +02:00
|
|
|
return b ? "true" : "false";
|
|
|
|
|
},
|
|
|
|
|
[&](int const& i) {
|
2022-12-04 18:02:33 +00:00
|
|
|
return DeprecatedString::number(i);
|
2021-09-19 20:56:05 +02:00
|
|
|
},
|
|
|
|
|
[&](float const& f) {
|
2022-12-04 18:02:33 +00:00
|
|
|
return DeprecatedString::number(f);
|
2021-09-19 20:56:05 +02:00
|
|
|
},
|
|
|
|
|
[&](Reference const& ref) {
|
2022-12-04 18:02:33 +00:00
|
|
|
return DeprecatedString::formatted("{} {} R", ref.as_ref_index(), ref.as_ref_generation_index());
|
2021-09-19 20:56:05 +02:00
|
|
|
},
|
|
|
|
|
[&](NonnullRefPtr<Object> const& object) {
|
2022-12-06 01:12:49 +00:00
|
|
|
return object->to_deprecated_string(indent);
|
2021-09-19 20:56:05 +02:00
|
|
|
});
|
2021-04-30 18:23:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|