2022-02-04 21:36:22 +00:00
|
|
|
// Copyright (c) 2005-2022 Jay Berkenbilt
|
2008-04-29 12:55:25 +00:00
|
|
|
//
|
2017-09-14 16:44:31 +00:00
|
|
|
// This file is part of qpdf.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
// Versions of qpdf prior to version 7 were released under the terms
|
|
|
|
// of version 2.0 of the Artistic License. At your option, you may
|
|
|
|
// continue to consider qpdf to be licensed under those terms. Please
|
|
|
|
// see the manual for additional information.
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2018-08-12 18:07:22 +00:00
|
|
|
#ifndef QPDFOBJECT_HH
|
|
|
|
#define QPDFOBJECT_HH
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2009-10-19 20:17:14 +00:00
|
|
|
#include <qpdf/DLL.h>
|
2019-10-02 11:30:53 +00:00
|
|
|
#include <qpdf/Types.h>
|
2018-12-17 22:40:29 +00:00
|
|
|
#include <qpdf/JSON.hh>
|
2021-12-17 17:34:48 +00:00
|
|
|
#include <qpdf/Constants.h>
|
2009-08-06 19:00:25 +00:00
|
|
|
|
2008-04-29 12:55:25 +00:00
|
|
|
#include <string>
|
|
|
|
|
2010-06-06 13:32:08 +00:00
|
|
|
class QPDF;
|
|
|
|
class QPDFObjectHandle;
|
|
|
|
|
2020-04-07 14:35:03 +00:00
|
|
|
class QPDF_DLL_CLASS QPDFObject
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-02-16 22:25:27 +00:00
|
|
|
QPDFObject();
|
2013-01-22 14:57:07 +00:00
|
|
|
|
|
|
|
// Objects derived from QPDFObject are accessible through
|
2021-12-17 17:34:48 +00:00
|
|
|
// QPDFObjectHandle. Each object returns a unique type code that
|
|
|
|
// has one of the valid qpdf_object_type_e values. As new object
|
|
|
|
// types are added to qpdf, additional items may be added to the
|
|
|
|
// list, so code that switches on these values should take that
|
|
|
|
// into consideration.
|
|
|
|
|
|
|
|
// Prior to qpdf 10.5, qpdf_object_type_e was
|
|
|
|
// QPDFObject::object_type_e but was moved to make it accessible
|
|
|
|
// to the C API. The code below is for backward compatibility.
|
|
|
|
typedef enum qpdf_object_type_e object_type_e;
|
2021-12-20 19:41:44 +00:00
|
|
|
static constexpr object_type_e ot_uninitialized = ::ot_uninitialized;
|
|
|
|
static constexpr object_type_e ot_reserved = ::ot_reserved;
|
|
|
|
static constexpr object_type_e ot_null = ::ot_null;
|
|
|
|
static constexpr object_type_e ot_boolean = ::ot_boolean;
|
|
|
|
static constexpr object_type_e ot_integer = ::ot_integer;
|
|
|
|
static constexpr object_type_e ot_real = ::ot_real;
|
|
|
|
static constexpr object_type_e ot_string = ::ot_string;
|
|
|
|
static constexpr object_type_e ot_name = ::ot_name;
|
|
|
|
static constexpr object_type_e ot_array = ::ot_array;
|
|
|
|
static constexpr object_type_e ot_dictionary = ::ot_dictionary;
|
|
|
|
static constexpr object_type_e ot_stream = ::ot_stream;
|
|
|
|
static constexpr object_type_e ot_operator = ::ot_operator;
|
|
|
|
static constexpr object_type_e ot_inlineimage = ::ot_inlineimage;
|
2013-01-22 14:57:07 +00:00
|
|
|
|
2008-04-29 12:55:25 +00:00
|
|
|
virtual ~QPDFObject() {}
|
|
|
|
virtual std::string unparse() = 0;
|
2018-12-17 22:40:29 +00:00
|
|
|
virtual JSON getJSON() = 0;
|
2010-06-06 13:32:08 +00:00
|
|
|
|
2013-01-22 14:57:07 +00:00
|
|
|
// Return a unique type code for the object
|
|
|
|
virtual object_type_e getTypeCode() const = 0;
|
|
|
|
|
|
|
|
// Return a string literal that describes the type, useful for
|
|
|
|
// debugging and testing
|
|
|
|
virtual char const* getTypeName() const = 0;
|
|
|
|
|
2010-06-06 13:32:08 +00:00
|
|
|
// Accessor to give specific access to non-public methods
|
|
|
|
class ObjAccessor
|
|
|
|
{
|
2022-02-08 14:18:08 +00:00
|
|
|
friend class QPDF;
|
|
|
|
friend class QPDFObjectHandle;
|
2010-06-06 13:32:08 +00:00
|
|
|
private:
|
2022-02-08 14:18:08 +00:00
|
|
|
static void releaseResolved(QPDFObject* o)
|
|
|
|
{
|
|
|
|
if (o)
|
|
|
|
{
|
|
|
|
o->releaseResolved();
|
|
|
|
}
|
|
|
|
}
|
2010-06-06 13:32:08 +00:00
|
|
|
};
|
|
|
|
friend class ObjAccessor;
|
|
|
|
|
2018-02-16 22:25:27 +00:00
|
|
|
virtual void setDescription(QPDF*, std::string const&);
|
|
|
|
bool getDescription(QPDF*&, std::string&);
|
|
|
|
bool hasDescription();
|
|
|
|
|
2019-10-02 11:30:53 +00:00
|
|
|
void setParsedOffset(qpdf_offset_t offset);
|
|
|
|
qpdf_offset_t getParsedOffset();
|
|
|
|
|
2010-06-06 13:32:08 +00:00
|
|
|
protected:
|
|
|
|
virtual void releaseResolved() {}
|
2018-02-16 22:25:27 +00:00
|
|
|
|
|
|
|
private:
|
2020-04-02 22:52:31 +00:00
|
|
|
QPDFObject(QPDFObject const&) = delete;
|
|
|
|
QPDFObject& operator=(QPDFObject const&) = delete;
|
|
|
|
|
|
|
|
QPDF* owning_qpdf;
|
|
|
|
std::string object_description;
|
|
|
|
qpdf_offset_t parsed_offset;
|
2008-04-29 12:55:25 +00:00
|
|
|
};
|
|
|
|
|
2018-08-12 18:07:22 +00:00
|
|
|
#endif // QPDFOBJECT_HH
|