Coverage Report

Created: 2026-01-09 06:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qpdf/libqpdf/QPDFObject.cc
Line
Count
Source
1
#include <qpdf/QPDFObject_private.hh>
2
3
std::string
4
QPDFObject::getDescription()
5
95.6k
{
6
95.6k
    qpdf_offset_t shift = (getTypeCode() == ::ot_dictionary) ? 2
7
95.6k
        : (getTypeCode() == ::ot_array)                      ? 1
8
48.6k
                                                             : 0;
9
10
95.6k
    if (object_description) {
11
70.2k
        switch (object_description->index()) {
12
67.0k
        case 0:
13
67.0k
            {
14
                // Simple template string
15
67.0k
                auto description = std::get<0>(*object_description);
16
17
67.0k
                if (auto pos = description.find("$OG"); pos != std::string::npos) {
18
0
                    description.replace(pos, 3, og.unparse(' '));
19
0
                }
20
67.0k
                if (auto pos = description.find("$PO"); pos != std::string::npos) {
21
66.4k
                    description.replace(pos, 3, std::to_string(parsed_offset + shift));
22
66.4k
                }
23
67.0k
                return description;
24
0
            }
25
0
        case 1:
26
0
            {
27
                // QPDF::JSONReactor generated description
28
0
                auto j_descr = std::get<1>(*object_description);
29
0
                return (
30
0
                    *j_descr.input + (j_descr.object.empty() ? "" : ", " + j_descr.object) +
31
0
                    " at offset " + std::to_string(parsed_offset));
32
0
            }
33
1.41k
        case 2:
34
1.41k
            {
35
                // Child object description
36
1.41k
                auto j_descr = std::get<2>(*object_description);
37
1.41k
                std::string result;
38
1.41k
                if (auto p = j_descr.parent.lock()) {
39
1.41k
                    result = p->getDescription();
40
1.41k
                }
41
1.41k
                result += j_descr.static_descr;
42
1.41k
                if (auto pos = result.find("$VD"); pos != std::string::npos) {
43
1.37k
                    result.replace(pos, 3, j_descr.var_descr);
44
1.37k
                }
45
1.41k
                return result;
46
0
            }
47
1.86k
        case 3:
48
1.86k
            auto [stream_id, obj_id] = std::get<3>(*object_description);
49
1.86k
            std::string result = qpdf ? qpdf->getFilename() : "";
50
1.86k
            result += " object stream " + std::to_string(stream_id) + ", object " +
51
1.86k
                std::to_string(obj_id) + " 0 at offset " + std::to_string(parsed_offset + shift);
52
1.86k
            return result;
53
70.2k
        }
54
55
70.2k
    } else if (og.isIndirect()) {
56
24.6k
        return "object " + og.unparse(' ');
57
24.6k
    }
58
707
    return {};
59
95.6k
}