ObjectHandle.hh
2.87 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright (c) 2005-2021 Jay Berkenbilt
// Copyright (c) 2022-2025 Jay Berkenbilt and Manfred Holger
//
// 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.
#ifndef OBJECTHANDLE_HH
#define OBJECTHANDLE_HH
#include <qpdf/Constants.h>
#include <qpdf/DLL.h>
#include <qpdf/QPDFObjGen.hh>
#include <qpdf/Types.h>
#include <cstdint>
#include <memory>
class QPDF;
class QPDF_Dictionary;
class QPDFObject;
class QPDFObjectHandle;
namespace qpdf
{
class Array;
class BaseDictionary;
class Dictionary;
class Stream;
enum typed : std::uint8_t { strict = 0, any_flag = 1, optional = 2, any = 3, error = 4 };
// Basehandle is only used as a base-class for QPDFObjectHandle like classes. Currently the only
// methods exposed in public API are operators to convert derived objects to QPDFObjectHandle,
// QPDFObjGen and bool.
class BaseHandle
{
public:
explicit inline operator bool() const;
inline operator QPDFObjectHandle() const;
operator QPDFObjGen() const;
// The rest of the header file is for qpdf internal use only.
std::shared_ptr<QPDFObject> copy(bool shallow = false) const;
inline QPDFObjGen id_gen() const;
inline bool indirect() const;
inline bool null() const;
inline QPDF* qpdf() const;
inline qpdf_object_type_e raw_type_code() const;
inline qpdf_object_type_e type_code() const;
std::string unparse() const;
void write_json(int json_version, JSON::Writer& p) const;
protected:
BaseHandle() = default;
BaseHandle(std::shared_ptr<QPDFObject> const& obj) :
obj(obj) {};
BaseHandle(std::shared_ptr<QPDFObject>&& obj) :
obj(std::move(obj)) {};
BaseHandle(BaseHandle const&) = default;
BaseHandle& operator=(BaseHandle const&) = default;
BaseHandle(BaseHandle&&) = default;
BaseHandle& operator=(BaseHandle&&) = default;
~BaseHandle() = default;
template <typename T>
T* as() const;
std::shared_ptr<QPDFObject> obj;
};
} // namespace qpdf
#endif // QPDFOBJECTHANDLE_HH