Commit 431bd666c0504af0c8a016a96a73b7efbf9737c9

Authored by m-holger
1 parent 43983109

Split QPDFObject into QPDFObject and QPDFValue

include/qpdf/QPDFObject.hh
@@ -25,6 +25,7 @@ @@ -25,6 +25,7 @@
25 #include <qpdf/Constants.h> 25 #include <qpdf/Constants.h>
26 #include <qpdf/DLL.h> 26 #include <qpdf/DLL.h>
27 #include <qpdf/JSON.hh> 27 #include <qpdf/JSON.hh>
  28 +#include <qpdf/QPDFValue.hh>
28 #include <qpdf/Types.h> 29 #include <qpdf/Types.h>
29 30
30 #include <string> 31 #include <string>
@@ -34,9 +35,9 @@ class QPDFObjectHandle; @@ -34,9 +35,9 @@ class QPDFObjectHandle;
34 35
35 class QPDFObject 36 class QPDFObject
36 { 37 {
37 - public:  
38 - QPDFObject(); 38 + friend class QPDFValue;
39 39
  40 + public:
40 // Objects derived from QPDFObject are accessible through 41 // Objects derived from QPDFObject are accessible through
41 // QPDFObjectHandle. Each object returns a unique type code that 42 // QPDFObjectHandle. Each object returns a unique type code that
42 // has one of the valid qpdf_object_type_e values. As new object 43 // has one of the valid qpdf_object_type_e values. As new object
@@ -63,17 +64,84 @@ class QPDFObject @@ -63,17 +64,84 @@ class QPDFObject
63 static constexpr object_type_e ot_inlineimage = ::ot_inlineimage; 64 static constexpr object_type_e ot_inlineimage = ::ot_inlineimage;
64 static constexpr object_type_e ot_unresolved = ::ot_unresolved; 65 static constexpr object_type_e ot_unresolved = ::ot_unresolved;
65 66
  67 + QPDFObject() = default;
66 virtual ~QPDFObject() = default; 68 virtual ~QPDFObject() = default;
67 - virtual std::shared_ptr<QPDFObject> shallowCopy() = 0;  
68 - virtual std::string unparse() = 0;  
69 - virtual JSON getJSON(int json_version) = 0; 69 +
  70 + std::shared_ptr<QPDFObject>
  71 + shallowCopy()
  72 + {
  73 + return value->shallowCopy();
  74 + }
  75 + std::string
  76 + unparse()
  77 + {
  78 + return value->unparse();
  79 + }
  80 + JSON
  81 + getJSON(int json_version)
  82 + {
  83 + return value->getJSON(json_version);
  84 + }
70 85
71 // Return a unique type code for the object 86 // Return a unique type code for the object
72 - virtual object_type_e getTypeCode() const = 0; 87 + object_type_e
  88 + getTypeCode() const
  89 + {
  90 + return value->getTypeCode();
  91 + }
73 92
74 // Return a string literal that describes the type, useful for 93 // Return a string literal that describes the type, useful for
75 // debugging and testing 94 // debugging and testing
76 - virtual char const* getTypeName() const = 0; 95 + char const*
  96 + getTypeName() const
  97 + {
  98 + return value->getTypeName();
  99 + }
  100 +
  101 + void
  102 + setDescription(QPDF* qpdf, std::string const& description)
  103 + {
  104 + return value->setDescription(qpdf, description);
  105 + }
  106 + bool
  107 + getDescription(QPDF*& qpdf, std::string& description)
  108 + {
  109 + return value->getDescription(qpdf, description);
  110 + }
  111 + bool
  112 + hasDescription()
  113 + {
  114 + return value->hasDescription();
  115 + }
  116 + void
  117 + setParsedOffset(qpdf_offset_t offset)
  118 + {
  119 + value->setParsedOffset(offset);
  120 + }
  121 + qpdf_offset_t
  122 + getParsedOffset()
  123 + {
  124 + return value->getParsedOffset();
  125 + }
  126 + void
  127 + assign(std::shared_ptr<QPDFObject> o)
  128 + {
  129 + value = o->value;
  130 + }
  131 + void
  132 + swapWith(std::shared_ptr<QPDFObject> o)
  133 + {
  134 + auto v = value;
  135 + value = o->value;
  136 + o->value = v;
  137 + }
  138 +
  139 + template <typename T>
  140 + T*
  141 + as()
  142 + {
  143 + return dynamic_cast<T*>(value.get());
  144 + }
77 145
78 // Accessor to give specific access to non-public methods 146 // Accessor to give specific access to non-public methods
79 class ObjAccessor 147 class ObjAccessor
@@ -90,29 +158,20 @@ class QPDFObject @@ -90,29 +158,20 @@ class QPDFObject
90 } 158 }
91 } 159 }
92 }; 160 };
93 - friend class ObjAccessor;  
94 -  
95 - virtual void setDescription(QPDF*, std::string const&);  
96 - bool getDescription(QPDF*&, std::string&);  
97 - bool hasDescription();  
98 161
99 - void setParsedOffset(qpdf_offset_t offset);  
100 - qpdf_offset_t getParsedOffset(); 162 + friend class ObjAccessor;
101 163
102 protected: 164 protected:
103 virtual void 165 virtual void
104 releaseResolved() 166 releaseResolved()
105 { 167 {
  168 + value->releaseResolved();
106 } 169 }
107 - static std::shared_ptr<QPDFObject> do_create(QPDFObject*);  
108 170
109 private: 171 private:
110 QPDFObject(QPDFObject const&) = delete; 172 QPDFObject(QPDFObject const&) = delete;
111 QPDFObject& operator=(QPDFObject const&) = delete; 173 QPDFObject& operator=(QPDFObject const&) = delete;
112 -  
113 - QPDF* owning_qpdf;  
114 - std::string object_description;  
115 - qpdf_offset_t parsed_offset; 174 + std::shared_ptr<QPDFValue> value;
116 }; 175 };
117 176
118 #endif // QPDFOBJECT_HH 177 #endif // QPDFOBJECT_HH
include/qpdf/QPDFValue.hh 0 โ†’ 100644
  1 +// Copyright (c) 2005-2022 Jay Berkenbilt
  2 +//
  3 +// This file is part of qpdf.
  4 +//
  5 +// Licensed under the Apache License, Version 2.0 (the "License");
  6 +// you may not use this file except in compliance with the License.
  7 +// You may obtain a copy of the License at
  8 +//
  9 +// http://www.apache.org/licenses/LICENSE-2.0
  10 +//
  11 +// Unless required by applicable law or agreed to in writing, software
  12 +// distributed under the License is distributed on an "AS IS" BASIS,
  13 +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14 +// See the License for the specific language governing permissions and
  15 +// limitations under the License.
  16 +//
  17 +// Versions of qpdf prior to version 7 were released under the terms
  18 +// of version 2.0 of the Artistic License. At your option, you may
  19 +// continue to consider qpdf to be licensed under those terms. Please
  20 +// see the manual for additional information.
  21 +
  22 +#ifndef QPDFVALUE_HH
  23 +#define QPDFVALUE_HH
  24 +
  25 +#include <qpdf/Constants.h>
  26 +#include <qpdf/DLL.h>
  27 +#include <qpdf/JSON.hh>
  28 +#include <qpdf/Types.h>
  29 +
  30 +#include <string>
  31 +
  32 +class QPDF;
  33 +class QPDFObjectHandle;
  34 +class QPDFObject;
  35 +
  36 +class QPDFValue
  37 +{
  38 + friend class QPDFObject;
  39 +
  40 + public:
  41 + virtual ~QPDFValue() = default;
  42 +
  43 + virtual std::shared_ptr<QPDFObject> shallowCopy() = 0;
  44 + virtual std::string unparse() = 0;
  45 + virtual JSON getJSON(int json_version) = 0;
  46 + virtual qpdf_object_type_e getTypeCode() const = 0;
  47 + virtual char const* getTypeName() const = 0;
  48 + virtual void
  49 + setDescription(QPDF* qpdf, std::string const& description)
  50 + {
  51 + owning_qpdf = qpdf;
  52 + object_description = description;
  53 + }
  54 + bool
  55 + getDescription(QPDF*& qpdf, std::string& description)
  56 + {
  57 + qpdf = owning_qpdf;
  58 + description = object_description;
  59 + return owning_qpdf != nullptr;
  60 + }
  61 + bool
  62 + hasDescription()
  63 + {
  64 + return owning_qpdf != nullptr;
  65 + }
  66 + void
  67 + setParsedOffset(qpdf_offset_t offset)
  68 + {
  69 + parsed_offset = offset;
  70 + }
  71 + qpdf_offset_t
  72 + getParsedOffset()
  73 + {
  74 + return parsed_offset;
  75 + }
  76 +
  77 + protected:
  78 + QPDFValue() = default;
  79 + virtual void
  80 + releaseResolved()
  81 + {
  82 + }
  83 + static std::shared_ptr<QPDFObject> do_create(QPDFValue*);
  84 +
  85 + private:
  86 + QPDFValue(QPDFValue const&) = delete;
  87 + QPDFValue& operator=(QPDFValue const&) = delete;
  88 + QPDF* owning_qpdf{nullptr};
  89 + std::string object_description;
  90 + qpdf_offset_t parsed_offset{-1};
  91 +};
  92 +
  93 +#endif // QPDFVALUE_HH
libqpdf/CMakeLists.txt
@@ -85,6 +85,7 @@ set(libqpdf_SOURCES @@ -85,6 +85,7 @@ set(libqpdf_SOURCES
85 QPDFSystemError.cc 85 QPDFSystemError.cc
86 QPDFTokenizer.cc 86 QPDFTokenizer.cc
87 QPDFUsage.cc 87 QPDFUsage.cc
  88 + QPDFValue.cc
88 QPDFWriter.cc 89 QPDFWriter.cc
89 QPDFXRefEntry.cc 90 QPDFXRefEntry.cc
90 QPDF_Array.cc 91 QPDF_Array.cc
libqpdf/QPDFObject.cc
1 #include <qpdf/QPDFObject.hh> 1 #include <qpdf/QPDFObject.hh>
2 -  
3 -QPDFObject::QPDFObject() :  
4 - owning_qpdf(nullptr),  
5 - parsed_offset(-1)  
6 -{  
7 -}  
8 -  
9 -std::shared_ptr<QPDFObject>  
10 -QPDFObject::do_create(QPDFObject* object)  
11 -{  
12 - std::shared_ptr<QPDFObject> obj(object);  
13 - return obj;  
14 -}  
15 -  
16 -void  
17 -QPDFObject::setDescription(QPDF* qpdf, std::string const& description)  
18 -{  
19 - this->owning_qpdf = qpdf;  
20 - this->object_description = description;  
21 -}  
22 -  
23 -bool  
24 -QPDFObject::getDescription(QPDF*& qpdf, std::string& description)  
25 -{  
26 - qpdf = this->owning_qpdf;  
27 - description = this->object_description;  
28 - return this->owning_qpdf != nullptr;  
29 -}  
30 -  
31 -bool  
32 -QPDFObject::hasDescription()  
33 -{  
34 - return this->owning_qpdf != nullptr;  
35 -}  
36 -  
37 -void  
38 -QPDFObject::setParsedOffset(qpdf_offset_t offset)  
39 -{  
40 - this->parsed_offset = offset;  
41 -}  
42 -  
43 -qpdf_offset_t  
44 -QPDFObject::getParsedOffset()  
45 -{  
46 - return this->parsed_offset;  
47 -}  
libqpdf/QPDFObjectHandle.cc
@@ -280,68 +280,67 @@ QPDFObjectHandle::getTypeName() @@ -280,68 +280,67 @@ QPDFObjectHandle::getTypeName()
280 QPDF_Array* 280 QPDF_Array*
281 QPDFObjectHandle::asArray() 281 QPDFObjectHandle::asArray()
282 { 282 {
283 - return isArray() ? dynamic_cast<QPDF_Array*>(obj.get()) : nullptr; 283 + return dereference() ? obj->as<QPDF_Array>() : nullptr;
284 } 284 }
285 285
286 QPDF_Bool* 286 QPDF_Bool*
287 QPDFObjectHandle::asBool() 287 QPDFObjectHandle::asBool()
288 { 288 {
289 - return isBool() ? dynamic_cast<QPDF_Bool*>(obj.get()) : nullptr; 289 + return dereference() ? obj->as<QPDF_Bool>() : nullptr;
290 } 290 }
291 291
292 QPDF_Dictionary* 292 QPDF_Dictionary*
293 QPDFObjectHandle::asDictionary() 293 QPDFObjectHandle::asDictionary()
294 { 294 {
295 - return isDictionary() ? dynamic_cast<QPDF_Dictionary*>(obj.get()) : nullptr; 295 + return dereference() ? obj->as<QPDF_Dictionary>() : nullptr;
296 } 296 }
297 297
298 QPDF_InlineImage* 298 QPDF_InlineImage*
299 QPDFObjectHandle::asInlineImage() 299 QPDFObjectHandle::asInlineImage()
300 { 300 {
301 - return isInlineImage() ? dynamic_cast<QPDF_InlineImage*>(obj.get())  
302 - : nullptr; 301 + return dereference() ? obj->as<QPDF_InlineImage>() : nullptr;
303 } 302 }
304 303
305 QPDF_Integer* 304 QPDF_Integer*
306 QPDFObjectHandle::asInteger() 305 QPDFObjectHandle::asInteger()
307 { 306 {
308 - return isInteger() ? dynamic_cast<QPDF_Integer*>(obj.get()) : nullptr; 307 + return dereference() ? obj->as<QPDF_Integer>() : nullptr;
309 } 308 }
310 309
311 QPDF_Name* 310 QPDF_Name*
312 QPDFObjectHandle::asName() 311 QPDFObjectHandle::asName()
313 { 312 {
314 - return isName() ? dynamic_cast<QPDF_Name*>(obj.get()) : nullptr; 313 + return dereference() ? obj->as<QPDF_Name>() : nullptr;
315 } 314 }
316 315
317 QPDF_Null* 316 QPDF_Null*
318 QPDFObjectHandle::asNull() 317 QPDFObjectHandle::asNull()
319 { 318 {
320 - return isNull() ? dynamic_cast<QPDF_Null*>(obj.get()) : nullptr; 319 + return dereference() ? obj->as<QPDF_Null>() : nullptr;
321 } 320 }
322 321
323 QPDF_Operator* 322 QPDF_Operator*
324 QPDFObjectHandle::asOperator() 323 QPDFObjectHandle::asOperator()
325 { 324 {
326 - return isOperator() ? dynamic_cast<QPDF_Operator*>(obj.get()) : nullptr; 325 + return dereference() ? obj->as<QPDF_Operator>() : nullptr;
327 } 326 }
328 327
329 QPDF_Real* 328 QPDF_Real*
330 QPDFObjectHandle::asReal() 329 QPDFObjectHandle::asReal()
331 { 330 {
332 - return isReal() ? dynamic_cast<QPDF_Real*>(obj.get()) : nullptr; 331 + return dereference() ? obj->as<QPDF_Real>() : nullptr;
333 } 332 }
334 333
335 QPDF_Reserved* 334 QPDF_Reserved*
336 QPDFObjectHandle::asReserved() 335 QPDFObjectHandle::asReserved()
337 { 336 {
338 - return isReserved() ? dynamic_cast<QPDF_Reserved*>(obj.get()) : nullptr; 337 + return dereference() ? obj->as<QPDF_Reserved>() : nullptr;
339 } 338 }
340 339
341 QPDF_Stream* 340 QPDF_Stream*
342 QPDFObjectHandle::asStream() 341 QPDFObjectHandle::asStream()
343 { 342 {
344 - return isStream() ? dynamic_cast<QPDF_Stream*>(obj.get()) : nullptr; 343 + return dereference() ? obj->as<QPDF_Stream>() : nullptr;
345 } 344 }
346 345
347 QPDF_Stream* 346 QPDF_Stream*
@@ -355,7 +354,7 @@ QPDFObjectHandle::asStreamWithAssert() @@ -355,7 +354,7 @@ QPDFObjectHandle::asStreamWithAssert()
355 QPDF_String* 354 QPDF_String*
356 QPDFObjectHandle::asString() 355 QPDFObjectHandle::asString()
357 { 356 {
358 - return isString() ? dynamic_cast<QPDF_String*>(obj.get()) : nullptr; 357 + return dereference() ? obj->as<QPDF_String>() : nullptr;
359 } 358 }
360 359
361 bool 360 bool
@@ -1716,11 +1715,8 @@ QPDFObjectHandle::unparseResolved() @@ -1716,11 +1715,8 @@ QPDFObjectHandle::unparseResolved()
1716 if (!dereference()) { 1715 if (!dereference()) {
1717 throw std::logic_error( 1716 throw std::logic_error(
1718 "attempted to dereference an uninitialized QPDFObjectHandle"); 1717 "attempted to dereference an uninitialized QPDFObjectHandle");
1719 - } else if (isReserved()) {  
1720 - throw std::logic_error(  
1721 - "QPDFObjectHandle: attempting to unparse a reserved object");  
1722 } 1718 }
1723 - return this->obj->unparse(); 1719 + return obj->unparse();
1724 } 1720 }
1725 1721
1726 std::string 1722 std::string
@@ -1749,9 +1745,6 @@ QPDFObjectHandle::getJSON(int json_version, bool dereference_indirect) @@ -1749,9 +1745,6 @@ QPDFObjectHandle::getJSON(int json_version, bool dereference_indirect)
1749 } else if (!dereference()) { 1745 } else if (!dereference()) {
1750 throw std::logic_error( 1746 throw std::logic_error(
1751 "attempted to dereference an uninitialized QPDFObjectHandle"); 1747 "attempted to dereference an uninitialized QPDFObjectHandle");
1752 - } else if (isReserved()) {  
1753 - throw std::logic_error(  
1754 - "QPDFObjectHandle: attempting to unparse a reserved object");  
1755 } else { 1748 } else {
1756 return obj->getJSON(json_version); 1749 return obj->getJSON(json_version);
1757 } 1750 }
libqpdf/QPDFValue.cc 0 โ†’ 100644
  1 +#include <qpdf/QPDFValue.hh>
  2 +
  3 +#include <qpdf/QPDFObject.hh>
  4 +
  5 +std::shared_ptr<QPDFObject>
  6 +QPDFValue::do_create(QPDFValue* object)
  7 +{
  8 + std::shared_ptr<QPDFObject> obj(new QPDFObject());
  9 + obj->value = std::shared_ptr<QPDFValue>(object);
  10 + return obj;
  11 +}
libqpdf/QPDF_Array.cc
@@ -62,10 +62,10 @@ QPDF_Array::getJSON(int json_version) @@ -62,10 +62,10 @@ QPDF_Array::getJSON(int json_version)
62 return j; 62 return j;
63 } 63 }
64 64
65 -QPDFObject::object_type_e 65 +qpdf_object_type_e
66 QPDF_Array::getTypeCode() const 66 QPDF_Array::getTypeCode() const
67 { 67 {
68 - return QPDFObject::ot_array; 68 + return ::ot_array;
69 } 69 }
70 70
71 char const* 71 char const*
libqpdf/QPDF_Bool.cc
@@ -29,10 +29,10 @@ QPDF_Bool::getJSON(int json_version) @@ -29,10 +29,10 @@ QPDF_Bool::getJSON(int json_version)
29 return JSON::makeBool(this->val); 29 return JSON::makeBool(this->val);
30 } 30 }
31 31
32 -QPDFObject::object_type_e 32 +qpdf_object_type_e
33 QPDF_Bool::getTypeCode() const 33 QPDF_Bool::getTypeCode() const
34 { 34 {
35 - return QPDFObject::ot_boolean; 35 + return ::ot_boolean;
36 } 36 }
37 37
38 char const* 38 char const*
libqpdf/QPDF_Dictionary.cc
1 #include <qpdf/QPDF_Dictionary.hh> 1 #include <qpdf/QPDF_Dictionary.hh>
2 2
3 #include <qpdf/QPDF_Name.hh> 3 #include <qpdf/QPDF_Name.hh>
4 -#include <qpdf/QPDF_Null.hh>  
5 4
6 QPDF_Dictionary::QPDF_Dictionary( 5 QPDF_Dictionary::QPDF_Dictionary(
7 std::map<std::string, QPDFObjectHandle> const& items) : 6 std::map<std::string, QPDFObjectHandle> const& items) :
@@ -58,10 +57,10 @@ QPDF_Dictionary::getJSON(int json_version) @@ -58,10 +57,10 @@ QPDF_Dictionary::getJSON(int json_version)
58 return j; 57 return j;
59 } 58 }
60 59
61 -QPDFObject::object_type_e 60 +qpdf_object_type_e
62 QPDF_Dictionary::getTypeCode() const 61 QPDF_Dictionary::getTypeCode() const
63 { 62 {
64 - return QPDFObject::ot_dictionary; 63 + return ::ot_dictionary;
65 } 64 }
66 65
67 char const* 66 char const*
libqpdf/QPDF_InlineImage.cc
@@ -29,10 +29,10 @@ QPDF_InlineImage::getJSON(int json_version) @@ -29,10 +29,10 @@ QPDF_InlineImage::getJSON(int json_version)
29 return JSON::makeNull(); 29 return JSON::makeNull();
30 } 30 }
31 31
32 -QPDFObject::object_type_e 32 +qpdf_object_type_e
33 QPDF_InlineImage::getTypeCode() const 33 QPDF_InlineImage::getTypeCode() const
34 { 34 {
35 - return QPDFObject::ot_inlineimage; 35 + return ::ot_inlineimage;
36 } 36 }
37 37
38 char const* 38 char const*
libqpdf/QPDF_Integer.cc
@@ -31,10 +31,10 @@ QPDF_Integer::getJSON(int json_version) @@ -31,10 +31,10 @@ QPDF_Integer::getJSON(int json_version)
31 return JSON::makeInt(this->val); 31 return JSON::makeInt(this->val);
32 } 32 }
33 33
34 -QPDFObject::object_type_e 34 +qpdf_object_type_e
35 QPDF_Integer::getTypeCode() const 35 QPDF_Integer::getTypeCode() const
36 { 36 {
37 - return QPDFObject::ot_integer; 37 + return ::ot_integer;
38 } 38 }
39 39
40 char const* 40 char const*
libqpdf/QPDF_Name.cc
@@ -61,10 +61,10 @@ QPDF_Name::getJSON(int json_version) @@ -61,10 +61,10 @@ QPDF_Name::getJSON(int json_version)
61 } 61 }
62 } 62 }
63 63
64 -QPDFObject::object_type_e 64 +qpdf_object_type_e
65 QPDF_Name::getTypeCode() const 65 QPDF_Name::getTypeCode() const
66 { 66 {
67 - return QPDFObject::ot_name; 67 + return ::ot_name;
68 } 68 }
69 69
70 char const* 70 char const*
libqpdf/QPDF_Null.cc
@@ -24,10 +24,10 @@ QPDF_Null::getJSON(int json_version) @@ -24,10 +24,10 @@ QPDF_Null::getJSON(int json_version)
24 return JSON::makeNull(); 24 return JSON::makeNull();
25 } 25 }
26 26
27 -QPDFObject::object_type_e 27 +qpdf_object_type_e
28 QPDF_Null::getTypeCode() const 28 QPDF_Null::getTypeCode() const
29 { 29 {
30 - return QPDFObject::ot_null; 30 + return ::ot_null;
31 } 31 }
32 32
33 char const* 33 char const*
libqpdf/QPDF_Operator.cc
@@ -20,7 +20,7 @@ QPDF_Operator::shallowCopy() @@ -20,7 +20,7 @@ QPDF_Operator::shallowCopy()
20 std::string 20 std::string
21 QPDF_Operator::unparse() 21 QPDF_Operator::unparse()
22 { 22 {
23 - return this->val; 23 + return val;
24 } 24 }
25 25
26 JSON 26 JSON
@@ -29,10 +29,10 @@ QPDF_Operator::getJSON(int json_version) @@ -29,10 +29,10 @@ QPDF_Operator::getJSON(int json_version)
29 return JSON::makeNull(); 29 return JSON::makeNull();
30 } 30 }
31 31
32 -QPDFObject::object_type_e 32 +qpdf_object_type_e
33 QPDF_Operator::getTypeCode() const 33 QPDF_Operator::getTypeCode() const
34 { 34 {
35 - return QPDFObject::ot_operator; 35 + return ::ot_operator;
36 } 36 }
37 37
38 char const* 38 char const*
libqpdf/QPDF_Real.cc
@@ -60,10 +60,10 @@ QPDF_Real::getJSON(int json_version) @@ -60,10 +60,10 @@ QPDF_Real::getJSON(int json_version)
60 return JSON::makeNumber(result); 60 return JSON::makeNumber(result);
61 } 61 }
62 62
63 -QPDFObject::object_type_e 63 +qpdf_object_type_e
64 QPDF_Real::getTypeCode() const 64 QPDF_Real::getTypeCode() const
65 { 65 {
66 - return QPDFObject::ot_real; 66 + return ::ot_real;
67 } 67 }
68 68
69 char const* 69 char const*
libqpdf/QPDF_Reserved.cc
@@ -30,10 +30,10 @@ QPDF_Reserved::getJSON(int json_version) @@ -30,10 +30,10 @@ QPDF_Reserved::getJSON(int json_version)
30 return JSON::makeNull(); 30 return JSON::makeNull();
31 } 31 }
32 32
33 -QPDFObject::object_type_e 33 +qpdf_object_type_e
34 QPDF_Reserved::getTypeCode() const 34 QPDF_Reserved::getTypeCode() const
35 { 35 {
36 - return QPDFObject::ot_reserved; 36 + return ::ot_reserved;
37 } 37 }
38 38
39 char const* 39 char const*
libqpdf/QPDF_Stream.cc
@@ -291,10 +291,10 @@ QPDF_Stream::getStreamJSON( @@ -291,10 +291,10 @@ QPDF_Stream::getStreamJSON(
291 return result; 291 return result;
292 } 292 }
293 293
294 -QPDFObject::object_type_e 294 +qpdf_object_type_e
295 QPDF_Stream::getTypeCode() const 295 QPDF_Stream::getTypeCode() const
296 { 296 {
297 - return QPDFObject::ot_stream; 297 + return ::ot_stream;
298 } 298 }
299 299
300 char const* 300 char const*
@@ -306,7 +306,7 @@ QPDF_Stream::getTypeName() const @@ -306,7 +306,7 @@ QPDF_Stream::getTypeName() const
306 void 306 void
307 QPDF_Stream::setDescription(QPDF* qpdf, std::string const& description) 307 QPDF_Stream::setDescription(QPDF* qpdf, std::string const& description)
308 { 308 {
309 - this->QPDFObject::setDescription(qpdf, description); 309 + this->QPDFValue::setDescription(qpdf, description);
310 setDictDescription(); 310 setDictDescription();
311 } 311 }
312 312
libqpdf/QPDF_String.cc
@@ -84,10 +84,10 @@ QPDF_String::getJSON(int json_version) @@ -84,10 +84,10 @@ QPDF_String::getJSON(int json_version)
84 return JSON::makeString(result); 84 return JSON::makeString(result);
85 } 85 }
86 86
87 -QPDFObject::object_type_e 87 +qpdf_object_type_e
88 QPDF_String::getTypeCode() const 88 QPDF_String::getTypeCode() const
89 { 89 {
90 - return QPDFObject::ot_string; 90 + return ::ot_string;
91 } 91 }
92 92
93 char const* 93 char const*
libqpdf/QPDF_Unresolved.cc
@@ -18,7 +18,7 @@ std::string @@ -18,7 +18,7 @@ std::string
18 QPDF_Unresolved::unparse() 18 QPDF_Unresolved::unparse()
19 { 19 {
20 throw std::logic_error( 20 throw std::logic_error(
21 - "attempted to unparse an unresolveded QPDFObjectHandle"); 21 + "attempted to unparse an unresolved QPDFObjectHandle");
22 return ""; 22 return "";
23 } 23 }
24 24
@@ -28,10 +28,10 @@ QPDF_Unresolved::getJSON(int json_version) @@ -28,10 +28,10 @@ QPDF_Unresolved::getJSON(int json_version)
28 return JSON::makeNull(); 28 return JSON::makeNull();
29 } 29 }
30 30
31 -QPDFObject::object_type_e 31 +qpdf_object_type_e
32 QPDF_Unresolved::getTypeCode() const 32 QPDF_Unresolved::getTypeCode() const
33 { 33 {
34 - return QPDFObject::ot_unresolved; 34 + return ::ot_unresolved;
35 } 35 }
36 36
37 char const* 37 char const*
libqpdf/qpdf/QPDF_Array.hh
1 #ifndef QPDF_ARRAY_HH 1 #ifndef QPDF_ARRAY_HH
2 #define QPDF_ARRAY_HH 2 #define QPDF_ARRAY_HH
3 3
4 -#include <qpdf/QPDFObject.hh> 4 +#include <qpdf/QPDFValue.hh>
5 5
6 #include <qpdf/SparseOHArray.hh> 6 #include <qpdf/SparseOHArray.hh>
7 #include <list> 7 #include <list>
8 #include <vector> 8 #include <vector>
9 9
10 -class QPDF_Array: public QPDFObject 10 +class QPDF_Array: public QPDFValue
11 { 11 {
12 public: 12 public:
13 virtual ~QPDF_Array() = default; 13 virtual ~QPDF_Array() = default;
@@ -17,7 +17,7 @@ class QPDF_Array: public QPDFObject @@ -17,7 +17,7 @@ class QPDF_Array: public QPDFObject
17 virtual std::shared_ptr<QPDFObject> shallowCopy(); 17 virtual std::shared_ptr<QPDFObject> shallowCopy();
18 virtual std::string unparse(); 18 virtual std::string unparse();
19 virtual JSON getJSON(int json_version); 19 virtual JSON getJSON(int json_version);
20 - virtual QPDFObject::object_type_e getTypeCode() const; 20 + virtual qpdf_object_type_e getTypeCode() const;
21 virtual char const* getTypeName() const; 21 virtual char const* getTypeName() const;
22 22
23 int getNItems() const; 23 int getNItems() const;
libqpdf/qpdf/QPDF_Bool.hh
1 #ifndef QPDF_BOOL_HH 1 #ifndef QPDF_BOOL_HH
2 #define QPDF_BOOL_HH 2 #define QPDF_BOOL_HH
3 3
4 -#include <qpdf/QPDFObject.hh> 4 +#include <qpdf/QPDFValue.hh>
5 5
6 -class QPDF_Bool: public QPDFObject 6 +class QPDF_Bool: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_Bool() = default; 9 virtual ~QPDF_Bool() = default;
@@ -11,7 +11,7 @@ class QPDF_Bool: public QPDFObject @@ -11,7 +11,7 @@ class QPDF_Bool: public QPDFObject
11 virtual std::shared_ptr<QPDFObject> shallowCopy(); 11 virtual std::shared_ptr<QPDFObject> shallowCopy();
12 virtual std::string unparse(); 12 virtual std::string unparse();
13 virtual JSON getJSON(int json_version); 13 virtual JSON getJSON(int json_version);
14 - virtual QPDFObject::object_type_e getTypeCode() const; 14 + virtual qpdf_object_type_e getTypeCode() const;
15 virtual char const* getTypeName() const; 15 virtual char const* getTypeName() const;
16 bool getVal() const; 16 bool getVal() const;
17 17
libqpdf/qpdf/QPDF_Dictionary.hh
1 #ifndef QPDF_DICTIONARY_HH 1 #ifndef QPDF_DICTIONARY_HH
2 #define QPDF_DICTIONARY_HH 2 #define QPDF_DICTIONARY_HH
3 3
4 -#include <qpdf/QPDFObject.hh> 4 +#include <qpdf/QPDFValue.hh>
5 5
6 #include <map> 6 #include <map>
7 #include <set> 7 #include <set>
8 8
9 #include <qpdf/QPDFObjectHandle.hh> 9 #include <qpdf/QPDFObjectHandle.hh>
10 10
11 -class QPDF_Dictionary: public QPDFObject 11 +class QPDF_Dictionary: public QPDFValue
12 { 12 {
13 public: 13 public:
14 virtual ~QPDF_Dictionary() = default; 14 virtual ~QPDF_Dictionary() = default;
@@ -17,7 +17,7 @@ class QPDF_Dictionary: public QPDFObject @@ -17,7 +17,7 @@ class QPDF_Dictionary: public QPDFObject
17 virtual std::shared_ptr<QPDFObject> shallowCopy(); 17 virtual std::shared_ptr<QPDFObject> shallowCopy();
18 virtual std::string unparse(); 18 virtual std::string unparse();
19 virtual JSON getJSON(int json_version); 19 virtual JSON getJSON(int json_version);
20 - virtual QPDFObject::object_type_e getTypeCode() const; 20 + virtual qpdf_object_type_e getTypeCode() const;
21 virtual char const* getTypeName() const; 21 virtual char const* getTypeName() const;
22 22
23 // hasKey() and getKeys() treat keys with null values as if they 23 // hasKey() and getKeys() treat keys with null values as if they
libqpdf/qpdf/QPDF_InlineImage.hh
1 #ifndef QPDF_INLINEIMAGE_HH 1 #ifndef QPDF_INLINEIMAGE_HH
2 #define QPDF_INLINEIMAGE_HH 2 #define QPDF_INLINEIMAGE_HH
3 3
4 -#include <qpdf/QPDFObject.hh> 4 +#include <qpdf/QPDFValue.hh>
5 5
6 -class QPDF_InlineImage: public QPDFObject 6 +class QPDF_InlineImage: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_InlineImage() = default; 9 virtual ~QPDF_InlineImage() = default;
@@ -11,7 +11,7 @@ class QPDF_InlineImage: public QPDFObject @@ -11,7 +11,7 @@ class QPDF_InlineImage: public QPDFObject
11 virtual std::shared_ptr<QPDFObject> shallowCopy(); 11 virtual std::shared_ptr<QPDFObject> shallowCopy();
12 virtual std::string unparse(); 12 virtual std::string unparse();
13 virtual JSON getJSON(int json_version); 13 virtual JSON getJSON(int json_version);
14 - virtual QPDFObject::object_type_e getTypeCode() const; 14 + virtual qpdf_object_type_e getTypeCode() const;
15 virtual char const* getTypeName() const; 15 virtual char const* getTypeName() const;
16 std::string getVal() const; 16 std::string getVal() const;
17 17
libqpdf/qpdf/QPDF_Integer.hh
1 #ifndef QPDF_INTEGER_HH 1 #ifndef QPDF_INTEGER_HH
2 #define QPDF_INTEGER_HH 2 #define QPDF_INTEGER_HH
3 3
4 -#include <qpdf/QPDFObject.hh> 4 +#include <qpdf/QPDFValue.hh>
5 5
6 -class QPDF_Integer: public QPDFObject 6 +class QPDF_Integer: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_Integer() = default; 9 virtual ~QPDF_Integer() = default;
@@ -11,7 +11,7 @@ class QPDF_Integer: public QPDFObject @@ -11,7 +11,7 @@ class QPDF_Integer: public QPDFObject
11 virtual std::shared_ptr<QPDFObject> shallowCopy(); 11 virtual std::shared_ptr<QPDFObject> shallowCopy();
12 virtual std::string unparse(); 12 virtual std::string unparse();
13 virtual JSON getJSON(int json_version); 13 virtual JSON getJSON(int json_version);
14 - virtual QPDFObject::object_type_e getTypeCode() const; 14 + virtual qpdf_object_type_e getTypeCode() const;
15 virtual char const* getTypeName() const; 15 virtual char const* getTypeName() const;
16 long long getVal() const; 16 long long getVal() const;
17 17
libqpdf/qpdf/QPDF_Name.hh
1 #ifndef QPDF_NAME_HH 1 #ifndef QPDF_NAME_HH
2 #define QPDF_NAME_HH 2 #define QPDF_NAME_HH
3 3
4 -#include <qpdf/QPDFObject.hh> 4 +#include <qpdf/QPDFValue.hh>
5 5
6 -class QPDF_Name: public QPDFObject 6 +class QPDF_Name: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_Name() = default; 9 virtual ~QPDF_Name() = default;
@@ -11,7 +11,7 @@ class QPDF_Name: public QPDFObject @@ -11,7 +11,7 @@ class QPDF_Name: public QPDFObject
11 virtual std::shared_ptr<QPDFObject> shallowCopy(); 11 virtual std::shared_ptr<QPDFObject> shallowCopy();
12 virtual std::string unparse(); 12 virtual std::string unparse();
13 virtual JSON getJSON(int json_version); 13 virtual JSON getJSON(int json_version);
14 - virtual QPDFObject::object_type_e getTypeCode() const; 14 + virtual qpdf_object_type_e getTypeCode() const;
15 virtual char const* getTypeName() const; 15 virtual char const* getTypeName() const;
16 std::string getName() const; 16 std::string getName() const;
17 17
libqpdf/qpdf/QPDF_Null.hh
1 #ifndef QPDF_NULL_HH 1 #ifndef QPDF_NULL_HH
2 #define QPDF_NULL_HH 2 #define QPDF_NULL_HH
3 3
4 -#include <qpdf/QPDFObject.hh> 4 +#include <qpdf/QPDFValue.hh>
5 5
6 -class QPDF_Null: public QPDFObject 6 +class QPDF_Null: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_Null() = default; 9 virtual ~QPDF_Null() = default;
@@ -11,7 +11,7 @@ class QPDF_Null: public QPDFObject @@ -11,7 +11,7 @@ class QPDF_Null: public QPDFObject
11 virtual std::shared_ptr<QPDFObject> shallowCopy(); 11 virtual std::shared_ptr<QPDFObject> shallowCopy();
12 virtual std::string unparse(); 12 virtual std::string unparse();
13 virtual JSON getJSON(int json_version); 13 virtual JSON getJSON(int json_version);
14 - virtual QPDFObject::object_type_e getTypeCode() const; 14 + virtual qpdf_object_type_e getTypeCode() const;
15 virtual char const* getTypeName() const; 15 virtual char const* getTypeName() const;
16 16
17 private: 17 private:
libqpdf/qpdf/QPDF_Operator.hh
1 #ifndef QPDF_OPERATOR_HH 1 #ifndef QPDF_OPERATOR_HH
2 #define QPDF_OPERATOR_HH 2 #define QPDF_OPERATOR_HH
3 3
4 -#include <qpdf/QPDFObject.hh> 4 +#include <qpdf/QPDFValue.hh>
5 5
6 -class QPDF_Operator: public QPDFObject 6 +class QPDF_Operator: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_Operator() = default; 9 virtual ~QPDF_Operator() = default;
@@ -11,7 +11,7 @@ class QPDF_Operator: public QPDFObject @@ -11,7 +11,7 @@ class QPDF_Operator: public QPDFObject
11 virtual std::shared_ptr<QPDFObject> shallowCopy(); 11 virtual std::shared_ptr<QPDFObject> shallowCopy();
12 virtual std::string unparse(); 12 virtual std::string unparse();
13 virtual JSON getJSON(int json_version); 13 virtual JSON getJSON(int json_version);
14 - virtual QPDFObject::object_type_e getTypeCode() const; 14 + virtual qpdf_object_type_e getTypeCode() const;
15 virtual char const* getTypeName() const; 15 virtual char const* getTypeName() const;
16 std::string getVal() const; 16 std::string getVal() const;
17 17
libqpdf/qpdf/QPDF_Real.hh
1 #ifndef QPDF_REAL_HH 1 #ifndef QPDF_REAL_HH
2 #define QPDF_REAL_HH 2 #define QPDF_REAL_HH
3 3
4 -#include <qpdf/QPDFObject.hh> 4 +#include <qpdf/QPDFValue.hh>
5 5
6 -class QPDF_Real: public QPDFObject 6 +class QPDF_Real: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_Real() = default; 9 virtual ~QPDF_Real() = default;
@@ -13,7 +13,7 @@ class QPDF_Real: public QPDFObject @@ -13,7 +13,7 @@ class QPDF_Real: public QPDFObject
13 virtual std::shared_ptr<QPDFObject> shallowCopy(); 13 virtual std::shared_ptr<QPDFObject> shallowCopy();
14 virtual std::string unparse(); 14 virtual std::string unparse();
15 virtual JSON getJSON(int json_version); 15 virtual JSON getJSON(int json_version);
16 - virtual QPDFObject::object_type_e getTypeCode() const; 16 + virtual qpdf_object_type_e getTypeCode() const;
17 virtual char const* getTypeName() const; 17 virtual char const* getTypeName() const;
18 std::string getVal(); 18 std::string getVal();
19 19
libqpdf/qpdf/QPDF_Reserved.hh
1 #ifndef QPDF_RESERVED_HH 1 #ifndef QPDF_RESERVED_HH
2 #define QPDF_RESERVED_HH 2 #define QPDF_RESERVED_HH
3 3
4 -#include <qpdf/QPDFObject.hh> 4 +#include <qpdf/QPDFValue.hh>
5 5
6 -class QPDF_Reserved: public QPDFObject 6 +class QPDF_Reserved: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_Reserved() = default; 9 virtual ~QPDF_Reserved() = default;
@@ -11,7 +11,7 @@ class QPDF_Reserved: public QPDFObject @@ -11,7 +11,7 @@ class QPDF_Reserved: public QPDFObject
11 virtual std::shared_ptr<QPDFObject> shallowCopy(); 11 virtual std::shared_ptr<QPDFObject> shallowCopy();
12 virtual std::string unparse(); 12 virtual std::string unparse();
13 virtual JSON getJSON(int json_version); 13 virtual JSON getJSON(int json_version);
14 - virtual QPDFObject::object_type_e getTypeCode() const; 14 + virtual qpdf_object_type_e getTypeCode() const;
15 virtual char const* getTypeName() const; 15 virtual char const* getTypeName() const;
16 16
17 private: 17 private:
libqpdf/qpdf/QPDF_Stream.hh
@@ -3,9 +3,9 @@ @@ -3,9 +3,9 @@
3 3
4 #include <qpdf/Types.h> 4 #include <qpdf/Types.h>
5 5
6 -#include <qpdf/QPDFObject.hh>  
7 #include <qpdf/QPDFObjectHandle.hh> 6 #include <qpdf/QPDFObjectHandle.hh>
8 #include <qpdf/QPDFStreamFilter.hh> 7 #include <qpdf/QPDFStreamFilter.hh>
  8 +#include <qpdf/QPDFValue.hh>
9 9
10 #include <functional> 10 #include <functional>
11 #include <memory> 11 #include <memory>
@@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
13 class Pipeline; 13 class Pipeline;
14 class QPDF; 14 class QPDF;
15 15
16 -class QPDF_Stream: public QPDFObject 16 +class QPDF_Stream: public QPDFValue
17 { 17 {
18 public: 18 public:
19 virtual ~QPDF_Stream() = default; 19 virtual ~QPDF_Stream() = default;
@@ -26,7 +26,7 @@ class QPDF_Stream: public QPDFObject @@ -26,7 +26,7 @@ class QPDF_Stream: public QPDFObject
26 virtual std::shared_ptr<QPDFObject> shallowCopy(); 26 virtual std::shared_ptr<QPDFObject> shallowCopy();
27 virtual std::string unparse(); 27 virtual std::string unparse();
28 virtual JSON getJSON(int json_version); 28 virtual JSON getJSON(int json_version);
29 - virtual QPDFObject::object_type_e getTypeCode() const; 29 + virtual qpdf_object_type_e getTypeCode() const;
30 virtual char const* getTypeName() const; 30 virtual char const* getTypeName() const;
31 virtual void setDescription(QPDF*, std::string const&); 31 virtual void setDescription(QPDF*, std::string const&);
32 QPDFObjectHandle getDict() const; 32 QPDFObjectHandle getDict() const;
libqpdf/qpdf/QPDF_String.hh
1 #ifndef QPDF_STRING_HH 1 #ifndef QPDF_STRING_HH
2 #define QPDF_STRING_HH 2 #define QPDF_STRING_HH
3 3
4 -#include <qpdf/QPDFObject.hh> 4 +#include <qpdf/QPDFValue.hh>
5 5
6 // QPDF_Strings may included embedded null characters. 6 // QPDF_Strings may included embedded null characters.
7 7
8 -class QPDF_String: public QPDFObject 8 +class QPDF_String: public QPDFValue
9 { 9 {
10 friend class QPDFWriter; 10 friend class QPDFWriter;
11 11
@@ -16,7 +16,7 @@ class QPDF_String: public QPDFObject @@ -16,7 +16,7 @@ class QPDF_String: public QPDFObject
16 create_utf16(std::string const& utf8_val); 16 create_utf16(std::string const& utf8_val);
17 virtual std::shared_ptr<QPDFObject> shallowCopy(); 17 virtual std::shared_ptr<QPDFObject> shallowCopy();
18 virtual std::string unparse(); 18 virtual std::string unparse();
19 - virtual QPDFObject::object_type_e getTypeCode() const; 19 + virtual qpdf_object_type_e getTypeCode() const;
20 virtual char const* getTypeName() const; 20 virtual char const* getTypeName() const;
21 std::string unparse(bool force_binary); 21 std::string unparse(bool force_binary);
22 virtual JSON getJSON(int json_version); 22 virtual JSON getJSON(int json_version);
libqpdf/qpdf/QPDF_Unresolved.hh
1 #ifndef QPDF_UNRESOLVED_HH 1 #ifndef QPDF_UNRESOLVED_HH
2 #define QPDF_UNRESOLVED_HH 2 #define QPDF_UNRESOLVED_HH
3 3
4 -#include <qpdf/QPDFObject.hh> 4 +#include <qpdf/QPDFValue.hh>
5 5
6 -class QPDF_Unresolved: public QPDFObject 6 +class QPDF_Unresolved: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_Unresolved() = default; 9 virtual ~QPDF_Unresolved() = default;
@@ -11,7 +11,7 @@ class QPDF_Unresolved: public QPDFObject @@ -11,7 +11,7 @@ class QPDF_Unresolved: public QPDFObject
11 virtual std::shared_ptr<QPDFObject> shallowCopy(); 11 virtual std::shared_ptr<QPDFObject> shallowCopy();
12 virtual std::string unparse(); 12 virtual std::string unparse();
13 virtual JSON getJSON(int json_version); 13 virtual JSON getJSON(int json_version);
14 - virtual QPDFObject::object_type_e getTypeCode() const; 14 + virtual qpdf_object_type_e getTypeCode() const;
15 virtual char const* getTypeName() const; 15 virtual char const* getTypeName() const;
16 16
17 private: 17 private: