2022-08-02 20:35:04 +00:00
|
|
|
#ifndef QPDFVALUE_HH
|
|
|
|
#define QPDFVALUE_HH
|
|
|
|
|
|
|
|
#include <qpdf/Constants.h>
|
|
|
|
#include <qpdf/DLL.h>
|
|
|
|
#include <qpdf/JSON.hh>
|
2022-08-12 14:14:11 +00:00
|
|
|
#include <qpdf/QPDFObjGen.hh>
|
2022-08-02 20:35:04 +00:00
|
|
|
#include <qpdf/Types.h>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
class QPDF;
|
|
|
|
class QPDFObjectHandle;
|
2022-09-08 15:29:23 +00:00
|
|
|
class QPDFObject;
|
2022-08-02 20:35:04 +00:00
|
|
|
|
|
|
|
class QPDFValue
|
|
|
|
{
|
2022-09-08 15:29:23 +00:00
|
|
|
friend class QPDFObject;
|
2022-08-02 20:35:04 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~QPDFValue() = default;
|
|
|
|
|
2022-11-14 17:54:12 +00:00
|
|
|
virtual std::shared_ptr<QPDFObject> copy(bool shallow = false) = 0;
|
2022-08-02 20:35:04 +00:00
|
|
|
virtual std::string unparse() = 0;
|
|
|
|
virtual JSON getJSON(int json_version) = 0;
|
|
|
|
virtual void
|
2022-09-07 18:11:24 +00:00
|
|
|
setDescription(QPDF* qpdf_p, std::string const& description)
|
2022-08-02 20:35:04 +00:00
|
|
|
{
|
2022-09-07 18:11:24 +00:00
|
|
|
qpdf = qpdf_p;
|
2022-08-02 20:35:04 +00:00
|
|
|
object_description = description;
|
|
|
|
}
|
|
|
|
bool
|
2022-09-07 18:11:24 +00:00
|
|
|
getDescription(QPDF*& qpdf_p, std::string& description)
|
2022-08-02 20:35:04 +00:00
|
|
|
{
|
2022-09-07 18:11:24 +00:00
|
|
|
qpdf_p = qpdf;
|
2022-08-02 20:35:04 +00:00
|
|
|
description = object_description;
|
2022-09-07 18:11:24 +00:00
|
|
|
return qpdf != nullptr;
|
2022-08-02 20:35:04 +00:00
|
|
|
}
|
|
|
|
bool
|
|
|
|
hasDescription()
|
|
|
|
{
|
2022-09-07 18:11:24 +00:00
|
|
|
return qpdf != nullptr && !object_description.empty();
|
2022-08-02 20:35:04 +00:00
|
|
|
}
|
|
|
|
void
|
|
|
|
setParsedOffset(qpdf_offset_t offset)
|
|
|
|
{
|
2022-08-10 12:16:06 +00:00
|
|
|
if (parsed_offset < 0) {
|
|
|
|
parsed_offset = offset;
|
|
|
|
}
|
2022-08-02 20:35:04 +00:00
|
|
|
}
|
|
|
|
qpdf_offset_t
|
|
|
|
getParsedOffset()
|
|
|
|
{
|
|
|
|
return parsed_offset;
|
|
|
|
}
|
2022-08-12 14:14:11 +00:00
|
|
|
QPDF*
|
|
|
|
getQPDF()
|
|
|
|
{
|
|
|
|
return qpdf;
|
|
|
|
}
|
|
|
|
QPDFObjGen
|
|
|
|
getObjGen()
|
|
|
|
{
|
|
|
|
return og;
|
|
|
|
}
|
2022-09-07 20:49:31 +00:00
|
|
|
virtual void
|
2022-09-08 15:06:15 +00:00
|
|
|
disconnect()
|
2022-09-07 20:49:31 +00:00
|
|
|
{
|
|
|
|
}
|
2022-12-21 13:14:05 +00:00
|
|
|
virtual std::string
|
|
|
|
getStringValue() const
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
2022-08-02 20:35:04 +00:00
|
|
|
|
|
|
|
protected:
|
2022-09-27 11:40:39 +00:00
|
|
|
QPDFValue() = default;
|
|
|
|
|
2022-08-02 21:57:33 +00:00
|
|
|
QPDFValue(qpdf_object_type_e type_code, char const* type_name) :
|
|
|
|
type_code(type_code),
|
|
|
|
type_name(type_name)
|
|
|
|
{
|
|
|
|
}
|
2022-08-12 14:14:11 +00:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
}
|
2022-09-03 23:58:53 +00:00
|
|
|
|
2022-09-08 15:29:23 +00:00
|
|
|
static std::shared_ptr<QPDFObject> do_create(QPDFValue*);
|
2022-08-02 20:35:04 +00:00
|
|
|
|
|
|
|
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"};
|
2022-08-12 14:14:11 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
QPDF* qpdf{nullptr};
|
2022-09-27 11:40:39 +00:00
|
|
|
QPDFObjGen og{};
|
|
|
|
qpdf_offset_t parsed_offset{-1};
|
2022-08-02 20:35:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QPDFVALUE_HH
|