aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFValue.cc
blob: 19679df2ae32114a2d5a2c2c6caedc061191d0c9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <qpdf/QPDFValue.hh>

#include <qpdf/QPDFObject_private.hh>

std::shared_ptr<QPDFObject>
QPDFValue::do_create(QPDFValue* object)
{
    std::shared_ptr<QPDFObject> obj(new QPDFObject());
    obj->value = std::shared_ptr<QPDFValue>(object);
    return obj;
}

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;

        description.replace(pos, 3, std::to_string(parsed_offset + shift));
    }
    return description;
}