/src/serenity/Userland/Libraries/LibPDF/Value.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2021, Matthew Olsson <mattco@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #include <LibPDF/Object.h> |
8 | | #include <LibPDF/Value.h> |
9 | | |
10 | | namespace PDF { |
11 | | |
12 | | ByteString Value::to_byte_string(int indent) const |
13 | 0 | { |
14 | 0 | return visit( |
15 | 0 | [&](Empty const&) -> ByteString { |
16 | | // Return type deduction means that we can't use implicit conversions. |
17 | 0 | return "<empty>"; |
18 | 0 | }, |
19 | 0 | [&](nullptr_t const&) -> ByteString { |
20 | 0 | return "null"; |
21 | 0 | }, |
22 | 0 | [&](bool const& b) -> ByteString { |
23 | 0 | return b ? "true" : "false"; |
24 | 0 | }, |
25 | 0 | [&](int const& i) { |
26 | 0 | return ByteString::number(i); |
27 | 0 | }, |
28 | 0 | [&](float const& f) { |
29 | 0 | return ByteString::number(f); |
30 | 0 | }, |
31 | 0 | [&](Reference const& ref) { |
32 | 0 | return ByteString::formatted("{} {} R", ref.as_ref_index(), ref.as_ref_generation_index()); |
33 | 0 | }, |
34 | 0 | [&](NonnullRefPtr<Object> const& object) { |
35 | 0 | return object->to_byte_string(indent); |
36 | 0 | }); |
37 | 0 | } |
38 | | |
39 | | } |