2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-16 17:45:09 +00:00
qpdf/libqpdf/qpdf/QPDFValue.hh

113 lines
2.2 KiB
C++
Raw Normal View History

#ifndef QPDFVALUE_HH
#define QPDFVALUE_HH
#include <qpdf/Constants.h>
#include <qpdf/DLL.h>
#include <qpdf/JSON.hh>
#include <qpdf/QPDFObjGen.hh>
#include <qpdf/Types.h>
#include <string>
class QPDF;
class QPDFObjectHandle;
class QPDFObject;
class QPDFValue
{
friend class QPDFObject;
public:
virtual ~QPDFValue() = default;
virtual std::shared_ptr<QPDFObject> copy(bool shallow = false) = 0;
virtual std::string unparse() = 0;
virtual JSON getJSON(int json_version) = 0;
virtual void
setDescription(QPDF* qpdf_p, std::string const& description)
{
qpdf = qpdf_p;
object_description = description;
}
bool
getDescription(QPDF*& qpdf_p, std::string& description)
{
qpdf_p = qpdf;
description = object_description;
return qpdf != nullptr;
}
bool
hasDescription()
{
return qpdf != nullptr && !object_description.empty();
}
void
setParsedOffset(qpdf_offset_t offset)
{
if (parsed_offset < 0) {
parsed_offset = offset;
}
}
qpdf_offset_t
getParsedOffset()
{
return parsed_offset;
}
QPDF*
getQPDF()
{
return qpdf;
}
QPDFObjGen
getObjGen()
{
return og;
}
virtual void
disconnect()
{
}
virtual std::string
getStringValue() const
{
return "";
}
protected:
2022-09-27 11:40:39 +00:00
QPDFValue() = default;
QPDFValue(qpdf_object_type_e type_code, char const* type_name) :
type_code(type_code),
type_name(type_name)
{
}
QPDFValue(
qpdf_object_type_e type_code,
char const* type_name,
QPDF* qpdf,
QPDFObjGen const& og) :
type_code(type_code),
type_name(type_name),
qpdf(qpdf),
og(og)
{
}
static std::shared_ptr<QPDFObject> do_create(QPDFValue*);
private:
QPDFValue(QPDFValue const&) = delete;
QPDFValue& operator=(QPDFValue const&) = delete;
std::string object_description;
2022-09-27 11:40:39 +00:00
const qpdf_object_type_e type_code{::ot_uninitialized};
char const* type_name{"uninitialized"};
protected:
QPDF* qpdf{nullptr};
2022-09-27 11:40:39 +00:00
QPDFObjGen og{};
qpdf_offset_t parsed_offset{-1};
};
#endif // QPDFVALUE_HH