Coverage Report

Created: 2026-07-16 06:57

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
1.09M
{
6
1.09M
    qpdf_offset_t shift = (getTypeCode() == ::ot_dictionary) ? 2
7
1.09M
        : (getTypeCode() == ::ot_array)                      ? 1
8
532k
                                                             : 0;
9
10
1.09M
    if (object_description) {
11
833k
        switch (object_description->index()) {
12
800k
        case 0:
13
800k
            {
14
                // Simple template string
15
800k
                auto description = std::get<0>(*object_description);
16
17
800k
                if (auto pos = description.find("$OG"); pos != std::string::npos) {
18
0
                    description.replace(pos, 3, og.unparse(' '));
19
0
                }
20
800k
                if (auto pos = description.find("$PO"); pos != std::string::npos) {
21
742k
                    description.replace(pos, 3, std::to_string(parsed_offset + shift));
22
742k
                }
23
800k
                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
20.5k
        case 2:
34
20.5k
            {
35
                // Child object description
36
20.5k
                auto j_descr = std::get<2>(*object_description);
37
20.5k
                std::string result;
38
20.5k
                if (auto p = j_descr.parent.lock()) {
39
20.5k
                    result = p->getDescription();
40
20.5k
                }
41
20.5k
                result += j_descr.static_descr;
42
20.5k
                if (auto pos = result.find("$VD"); pos != std::string::npos) {
43
20.5k
                    result.replace(pos, 3, j_descr.var_descr);
44
20.5k
                }
45
20.5k
                return result;
46
0
            }
47
12.7k
        case 3:
48
12.7k
            auto [stream_id, obj_id] = std::get<3>(*object_description);
49
12.7k
            std::string result = qpdf ? qpdf->getFilename() : "";
50
12.7k
            result += " object stream " + std::to_string(stream_id) + ", object " +
51
12.7k
                std::to_string(obj_id) + " 0 at offset " + std::to_string(parsed_offset + shift);
52
12.7k
            return result;
53
833k
        }
54
55
833k
    } else if (og.isIndirect()) {
56
261k
        return "object " + og.unparse(' ');
57
261k
    }
58
3.73k
    return {};
59
1.09M
}