2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-06-10 06:02:27 +00:00
qpdf/libqpdf/QPDF_Null.cc
m-holger 542cb91b7d Refactor the creation of unresolved objects
Create unresolved objects only for objects in the xref table (except during
parsing of the xref table). Do not add indirect nulls into the the object
cache as the result of a cache miss during a call to getObject except
during parsing or creation/updating from JSON. To support this behaviour,
add new private methods getObjectForParser and getObjectForJSON.

As a result of this change, dangling references are treated as direct nulls
rather than indirect nulls.
2024-05-04 12:29:03 +01:00

52 lines
1.1 KiB
C++

#include <qpdf/QPDF_Null.hh>
#include <qpdf/JSON_writer.hh>
#include <qpdf/QPDFObject_private.hh>
QPDF_Null::QPDF_Null(QPDF* qpdf, QPDFObjGen og) :
QPDFValue(::ot_null, "null", qpdf, og)
{
}
std::shared_ptr<QPDFObject>
QPDF_Null::create(QPDF* qpdf, QPDFObjGen og)
{
return do_create(new QPDF_Null(qpdf, og));
}
std::shared_ptr<QPDFObject>
QPDF_Null::create(
std::shared_ptr<QPDFObject> parent, std::string_view const& static_descr, std::string var_descr)
{
auto n = do_create(new QPDF_Null());
n->setChildDescription(parent, static_descr, var_descr);
return n;
}
std::shared_ptr<QPDFObject>
QPDF_Null::create(
std::shared_ptr<QPDFValue> parent, std::string_view const& static_descr, std::string var_descr)
{
auto n = do_create(new QPDF_Null());
n->setChildDescription(parent, static_descr, var_descr);
return n;
}
std::shared_ptr<QPDFObject>
QPDF_Null::copy(bool shallow)
{
return create();
}
std::string
QPDF_Null::unparse()
{
return "null";
}
void
QPDF_Null::writeJSON(int json_version, JSON::Writer& p)
{
p << "null";
}