Commit 18a583e8d9c509039046330a64925fdc733bb277

Authored by Jay Berkenbilt
1 parent 25ccc7ea

Rename QPDFValueProxy back to QPDFObject

QPDFValueProxy wasn't a good name for it. We decided the evil of
having the header file be named QPDFObject_private.hh was less than
the evil of having the class be named something other than what it
should have been named.
@@ -789,7 +789,7 @@ Rejected Ideas @@ -789,7 +789,7 @@ Rejected Ideas
789 789
790 These are some ideas I had before m-holger's changes to split 790 These are some ideas I had before m-holger's changes to split
791 QPDFValue from QPDFObject. These notes were written prior to the 791 QPDFValue from QPDFObject. These notes were written prior to the
792 - split of QPDFObject into QPDFValueProxy and QPDFValue and don't work 792 + split of QPDFObject into QPDFObject and QPDFValue and don't work
793 directly with the new implementation. I think they are still basic 793 directly with the new implementation. I think they are still basic
794 valid after adjusting to the new structure, but I think they would 794 valid after adjusting to the new structure, but I think they would
795 come at too high a performance cost to be worth doing. 795 come at too high a performance cost to be worth doing.
include/qpdf/QPDF.hh
@@ -842,11 +842,11 @@ class QPDF @@ -842,11 +842,11 @@ class QPDF
842 } 842 }
843 }; 843 };
844 844
845 - // Resolver class is restricted to QPDFValueProxy so that only it 845 + // The Resolver class is restricted to QPDFObject so that only it
846 // can resolve indirect references. 846 // can resolve indirect references.
847 class Resolver 847 class Resolver
848 { 848 {
849 - friend class QPDFValueProxy; 849 + friend class QPDFObject;
850 850
851 private: 851 private:
852 static void 852 static void
@@ -952,7 +952,7 @@ class QPDF @@ -952,7 +952,7 @@ class QPDF
952 { 952 {
953 } 953 }
954 ObjCache( 954 ObjCache(
955 - std::shared_ptr<QPDFValueProxy> object, 955 + std::shared_ptr<QPDFObject> object,
956 qpdf_offset_t end_before_space, 956 qpdf_offset_t end_before_space,
957 qpdf_offset_t end_after_space) : 957 qpdf_offset_t end_after_space) :
958 object(object), 958 object(object),
@@ -961,7 +961,7 @@ class QPDF @@ -961,7 +961,7 @@ class QPDF
961 { 961 {
962 } 962 }
963 963
964 - std::shared_ptr<QPDFValueProxy> object; 964 + std::shared_ptr<QPDFObject> object;
965 qpdf_offset_t end_before_space; 965 qpdf_offset_t end_before_space;
966 qpdf_offset_t end_after_space; 966 qpdf_offset_t end_after_space;
967 }; 967 };
@@ -1186,12 +1186,12 @@ class QPDF @@ -1186,12 +1186,12 @@ class QPDF
1186 QPDFObjectHandle reserveObjectIfNotExists(QPDFObjGen const& og); 1186 QPDFObjectHandle reserveObjectIfNotExists(QPDFObjGen const& og);
1187 QPDFObjectHandle reserveStream(QPDFObjGen const& og); 1187 QPDFObjectHandle reserveStream(QPDFObjGen const& og);
1188 QPDFObjectHandle 1188 QPDFObjectHandle
1189 - newIndirect(QPDFObjGen const&, std::shared_ptr<QPDFValueProxy> const&); 1189 + newIndirect(QPDFObjGen const&, std::shared_ptr<QPDFObject> const&);
1190 bool isCached(QPDFObjGen const& og); 1190 bool isCached(QPDFObjGen const& og);
1191 bool isUnresolved(QPDFObjGen const& og); 1191 bool isUnresolved(QPDFObjGen const& og);
1192 void updateCache( 1192 void updateCache(
1193 QPDFObjGen const& og, 1193 QPDFObjGen const& og,
1194 - std::shared_ptr<QPDFValueProxy> const& object, 1194 + std::shared_ptr<QPDFObject> const& object,
1195 qpdf_offset_t end_before_space, 1195 qpdf_offset_t end_before_space,
1196 qpdf_offset_t end_after_space); 1196 qpdf_offset_t end_after_space);
1197 1197
include/qpdf/QPDFObjectHandle.hh
@@ -54,7 +54,7 @@ class QPDF_Real; @@ -54,7 +54,7 @@ class QPDF_Real;
54 class QPDF_Reserved; 54 class QPDF_Reserved;
55 class QPDF_Stream; 55 class QPDF_Stream;
56 class QPDF_String; 56 class QPDF_String;
57 -class QPDFValueProxy; 57 +class QPDFObject;
58 class QPDFTokenizer; 58 class QPDFTokenizer;
59 class QPDFExc; 59 class QPDFExc;
60 class Pl_QPDFTokenizer; 60 class Pl_QPDFTokenizer;
@@ -1493,7 +1493,7 @@ class QPDFObjectHandle @@ -1493,7 +1493,7 @@ class QPDFObjectHandle
1493 1493
1494 private: 1494 private:
1495 static QPDFObjectHandle 1495 static QPDFObjectHandle
1496 - newIndirect(std::shared_ptr<QPDFValueProxy> const& obj) 1496 + newIndirect(std::shared_ptr<QPDFObject> const& obj)
1497 { 1497 {
1498 return QPDFObjectHandle(obj); 1498 return QPDFObjectHandle(obj);
1499 } 1499 }
@@ -1518,7 +1518,7 @@ class QPDFObjectHandle @@ -1518,7 +1518,7 @@ class QPDFObjectHandle
1518 friend class QPDF; 1518 friend class QPDF;
1519 1519
1520 private: 1520 private:
1521 - static std::shared_ptr<QPDFValueProxy> 1521 + static std::shared_ptr<QPDFObject>
1522 getObject(QPDFObjectHandle& o) 1522 getObject(QPDFObjectHandle& o)
1523 { 1523 {
1524 if (!o.dereference()) { 1524 if (!o.dereference()) {
@@ -1617,7 +1617,7 @@ class QPDFObjectHandle @@ -1617,7 +1617,7 @@ class QPDFObjectHandle
1617 bool isImage(bool exclude_imagemask = true); 1617 bool isImage(bool exclude_imagemask = true);
1618 1618
1619 private: 1619 private:
1620 - QPDFObjectHandle(std::shared_ptr<QPDFValueProxy> const& obj) : 1620 + QPDFObjectHandle(std::shared_ptr<QPDFObject> const& obj) :
1621 obj(obj) 1621 obj(obj)
1622 { 1622 {
1623 } 1623 }
@@ -1671,7 +1671,7 @@ class QPDFObjectHandle @@ -1671,7 +1671,7 @@ class QPDFObjectHandle
1671 // Moving members of QPDFObjectHandle into a smart pointer incurs 1671 // Moving members of QPDFObjectHandle into a smart pointer incurs
1672 // a substantial performance penalty since QPDFObjectHandle 1672 // a substantial performance penalty since QPDFObjectHandle
1673 // objects are copied around so frequently. 1673 // objects are copied around so frequently.
1674 - std::shared_ptr<QPDFValueProxy> obj; 1674 + std::shared_ptr<QPDFObject> obj;
1675 }; 1675 };
1676 1676
1677 #ifndef QPDF_NO_QPDF_STRING 1677 #ifndef QPDF_NO_QPDF_STRING
libqpdf/QPDF.cc
@@ -2120,8 +2120,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number) @@ -2120,8 +2120,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
2120 } 2120 }
2121 2121
2122 QPDFObjectHandle 2122 QPDFObjectHandle
2123 -QPDF::newIndirect(  
2124 - QPDFObjGen const& og, std::shared_ptr<QPDFValueProxy> const& obj) 2123 +QPDF::newIndirect(QPDFObjGen const& og, std::shared_ptr<QPDFObject> const& obj)
2125 { 2124 {
2126 obj->setObjGen(this, og); 2125 obj->setObjGen(this, og);
2127 if (!obj->hasDescription()) { 2126 if (!obj->hasDescription()) {
@@ -2133,7 +2132,7 @@ QPDF::newIndirect( @@ -2133,7 +2132,7 @@ QPDF::newIndirect(
2133 void 2132 void
2134 QPDF::updateCache( 2133 QPDF::updateCache(
2135 QPDFObjGen const& og, 2134 QPDFObjGen const& og,
2136 - std::shared_ptr<QPDFValueProxy> const& object, 2135 + std::shared_ptr<QPDFObject> const& object,
2137 qpdf_offset_t end_before_space, 2136 qpdf_offset_t end_before_space,
2138 qpdf_offset_t end_after_space) 2137 qpdf_offset_t end_after_space)
2139 { 2138 {
libqpdf/QPDFObject.cc
@@ -4,14 +4,14 @@ @@ -4,14 +4,14 @@
4 #include <qpdf/QPDF_Destroyed.hh> 4 #include <qpdf/QPDF_Destroyed.hh>
5 5
6 void 6 void
7 -QPDFValueProxy::doResolve() 7 +QPDFObject::doResolve()
8 { 8 {
9 auto og = value->og; 9 auto og = value->og;
10 QPDF::Resolver::resolve(value->qpdf, og); 10 QPDF::Resolver::resolve(value->qpdf, og);
11 } 11 }
12 12
13 void 13 void
14 -QPDFValueProxy::destroy() 14 +QPDFObject::destroy()
15 { 15 {
16 value = QPDF_Destroyed::getInstance(); 16 value = QPDF_Destroyed::getInstance();
17 } 17 }
libqpdf/QPDFObjectHandle.cc
@@ -2287,7 +2287,7 @@ QPDFObjectHandle::copyObject( @@ -2287,7 +2287,7 @@ QPDFObjectHandle::copyObject(
2287 " reserved object handle direct"); 2287 " reserved object handle direct");
2288 } 2288 }
2289 2289
2290 - std::shared_ptr<QPDFValueProxy> new_obj; 2290 + std::shared_ptr<QPDFObject> new_obj;
2291 2291
2292 if (isBool() || isInteger() || isName() || isNull() || isReal() || 2292 if (isBool() || isInteger() || isName() || isNull() || isReal() ||
2293 isString()) { 2293 isString()) {
libqpdf/QPDFValue.cc
@@ -2,10 +2,10 @@ @@ -2,10 +2,10 @@
2 2
3 #include <qpdf/QPDFObject_private.hh> 3 #include <qpdf/QPDFObject_private.hh>
4 4
5 -std::shared_ptr<QPDFValueProxy> 5 +std::shared_ptr<QPDFObject>
6 QPDFValue::do_create(QPDFValue* object) 6 QPDFValue::do_create(QPDFValue* object)
7 { 7 {
8 - std::shared_ptr<QPDFValueProxy> obj(new QPDFValueProxy()); 8 + std::shared_ptr<QPDFObject> obj(new QPDFObject());
9 obj->value = std::shared_ptr<QPDFValue>(object); 9 obj->value = std::shared_ptr<QPDFValue>(object);
10 return obj; 10 return obj;
11 } 11 }
libqpdf/QPDF_Array.cc
@@ -16,19 +16,19 @@ QPDF_Array::QPDF_Array(SparseOHArray const&amp; items) : @@ -16,19 +16,19 @@ QPDF_Array::QPDF_Array(SparseOHArray const&amp; items) :
16 { 16 {
17 } 17 }
18 18
19 -std::shared_ptr<QPDFValueProxy> 19 +std::shared_ptr<QPDFObject>
20 QPDF_Array::create(std::vector<QPDFObjectHandle> const& items) 20 QPDF_Array::create(std::vector<QPDFObjectHandle> const& items)
21 { 21 {
22 return do_create(new QPDF_Array(items)); 22 return do_create(new QPDF_Array(items));
23 } 23 }
24 24
25 -std::shared_ptr<QPDFValueProxy> 25 +std::shared_ptr<QPDFObject>
26 QPDF_Array::create(SparseOHArray const& items) 26 QPDF_Array::create(SparseOHArray const& items)
27 { 27 {
28 return do_create(new QPDF_Array(items)); 28 return do_create(new QPDF_Array(items));
29 } 29 }
30 30
31 -std::shared_ptr<QPDFValueProxy> 31 +std::shared_ptr<QPDFObject>
32 QPDF_Array::shallowCopy() 32 QPDF_Array::shallowCopy()
33 { 33 {
34 return create(elements); 34 return create(elements);
libqpdf/QPDF_Bool.cc
@@ -6,13 +6,13 @@ QPDF_Bool::QPDF_Bool(bool val) : @@ -6,13 +6,13 @@ QPDF_Bool::QPDF_Bool(bool val) :
6 { 6 {
7 } 7 }
8 8
9 -std::shared_ptr<QPDFValueProxy> 9 +std::shared_ptr<QPDFObject>
10 QPDF_Bool::create(bool value) 10 QPDF_Bool::create(bool value)
11 { 11 {
12 return do_create(new QPDF_Bool(value)); 12 return do_create(new QPDF_Bool(value));
13 } 13 }
14 14
15 -std::shared_ptr<QPDFValueProxy> 15 +std::shared_ptr<QPDFObject>
16 QPDF_Bool::shallowCopy() 16 QPDF_Bool::shallowCopy()
17 { 17 {
18 return create(val); 18 return create(val);
libqpdf/QPDF_Destroyed.cc
@@ -14,7 +14,7 @@ QPDF_Destroyed::getInstance() @@ -14,7 +14,7 @@ QPDF_Destroyed::getInstance()
14 return instance; 14 return instance;
15 } 15 }
16 16
17 -std::shared_ptr<QPDFValueProxy> 17 +std::shared_ptr<QPDFObject>
18 QPDF_Destroyed::shallowCopy() 18 QPDF_Destroyed::shallowCopy()
19 { 19 {
20 throw std::logic_error( 20 throw std::logic_error(
libqpdf/QPDF_Dictionary.cc
@@ -9,13 +9,13 @@ QPDF_Dictionary::QPDF_Dictionary( @@ -9,13 +9,13 @@ QPDF_Dictionary::QPDF_Dictionary(
9 { 9 {
10 } 10 }
11 11
12 -std::shared_ptr<QPDFValueProxy> 12 +std::shared_ptr<QPDFObject>
13 QPDF_Dictionary::create(std::map<std::string, QPDFObjectHandle> const& items) 13 QPDF_Dictionary::create(std::map<std::string, QPDFObjectHandle> const& items)
14 { 14 {
15 return do_create(new QPDF_Dictionary(items)); 15 return do_create(new QPDF_Dictionary(items));
16 } 16 }
17 17
18 -std::shared_ptr<QPDFValueProxy> 18 +std::shared_ptr<QPDFObject>
19 QPDF_Dictionary::shallowCopy() 19 QPDF_Dictionary::shallowCopy()
20 { 20 {
21 return create(items); 21 return create(items);
libqpdf/QPDF_InlineImage.cc
@@ -6,13 +6,13 @@ QPDF_InlineImage::QPDF_InlineImage(std::string const&amp; val) : @@ -6,13 +6,13 @@ QPDF_InlineImage::QPDF_InlineImage(std::string const&amp; val) :
6 { 6 {
7 } 7 }
8 8
9 -std::shared_ptr<QPDFValueProxy> 9 +std::shared_ptr<QPDFObject>
10 QPDF_InlineImage::create(std::string const& val) 10 QPDF_InlineImage::create(std::string const& val)
11 { 11 {
12 return do_create(new QPDF_InlineImage(val)); 12 return do_create(new QPDF_InlineImage(val));
13 } 13 }
14 14
15 -std::shared_ptr<QPDFValueProxy> 15 +std::shared_ptr<QPDFObject>
16 QPDF_InlineImage::shallowCopy() 16 QPDF_InlineImage::shallowCopy()
17 { 17 {
18 return create(val); 18 return create(val);
libqpdf/QPDF_Integer.cc
@@ -8,13 +8,13 @@ QPDF_Integer::QPDF_Integer(long long val) : @@ -8,13 +8,13 @@ QPDF_Integer::QPDF_Integer(long long val) :
8 { 8 {
9 } 9 }
10 10
11 -std::shared_ptr<QPDFValueProxy> 11 +std::shared_ptr<QPDFObject>
12 QPDF_Integer::create(long long value) 12 QPDF_Integer::create(long long value)
13 { 13 {
14 return do_create(new QPDF_Integer(value)); 14 return do_create(new QPDF_Integer(value));
15 } 15 }
16 16
17 -std::shared_ptr<QPDFValueProxy> 17 +std::shared_ptr<QPDFObject>
18 QPDF_Integer::shallowCopy() 18 QPDF_Integer::shallowCopy()
19 { 19 {
20 return create(val); 20 return create(val);
libqpdf/QPDF_Name.cc
@@ -10,13 +10,13 @@ QPDF_Name::QPDF_Name(std::string const&amp; name) : @@ -10,13 +10,13 @@ QPDF_Name::QPDF_Name(std::string const&amp; name) :
10 { 10 {
11 } 11 }
12 12
13 -std::shared_ptr<QPDFValueProxy> 13 +std::shared_ptr<QPDFObject>
14 QPDF_Name::create(std::string const& name) 14 QPDF_Name::create(std::string const& name)
15 { 15 {
16 return do_create(new QPDF_Name(name)); 16 return do_create(new QPDF_Name(name));
17 } 17 }
18 18
19 -std::shared_ptr<QPDFValueProxy> 19 +std::shared_ptr<QPDFObject>
20 QPDF_Name::shallowCopy() 20 QPDF_Name::shallowCopy()
21 { 21 {
22 return create(name); 22 return create(name);
libqpdf/QPDF_Null.cc
@@ -5,13 +5,13 @@ QPDF_Null::QPDF_Null() : @@ -5,13 +5,13 @@ QPDF_Null::QPDF_Null() :
5 { 5 {
6 } 6 }
7 7
8 -std::shared_ptr<QPDFValueProxy> 8 +std::shared_ptr<QPDFObject>
9 QPDF_Null::create() 9 QPDF_Null::create()
10 { 10 {
11 return do_create(new QPDF_Null()); 11 return do_create(new QPDF_Null());
12 } 12 }
13 13
14 -std::shared_ptr<QPDFValueProxy> 14 +std::shared_ptr<QPDFObject>
15 QPDF_Null::shallowCopy() 15 QPDF_Null::shallowCopy()
16 { 16 {
17 return create(); 17 return create();
libqpdf/QPDF_Operator.cc
@@ -6,13 +6,13 @@ QPDF_Operator::QPDF_Operator(std::string const&amp; val) : @@ -6,13 +6,13 @@ QPDF_Operator::QPDF_Operator(std::string const&amp; val) :
6 { 6 {
7 } 7 }
8 8
9 -std::shared_ptr<QPDFValueProxy> 9 +std::shared_ptr<QPDFObject>
10 QPDF_Operator::create(std::string const& val) 10 QPDF_Operator::create(std::string const& val)
11 { 11 {
12 return do_create(new QPDF_Operator(val)); 12 return do_create(new QPDF_Operator(val));
13 } 13 }
14 14
15 -std::shared_ptr<QPDFValueProxy> 15 +std::shared_ptr<QPDFObject>
16 QPDF_Operator::shallowCopy() 16 QPDF_Operator::shallowCopy()
17 { 17 {
18 return create(val); 18 return create(val);
libqpdf/QPDF_Real.cc
@@ -15,20 +15,20 @@ QPDF_Real::QPDF_Real( @@ -15,20 +15,20 @@ QPDF_Real::QPDF_Real(
15 { 15 {
16 } 16 }
17 17
18 -std::shared_ptr<QPDFValueProxy> 18 +std::shared_ptr<QPDFObject>
19 QPDF_Real::create(std::string const& val) 19 QPDF_Real::create(std::string const& val)
20 { 20 {
21 return do_create(new QPDF_Real(val)); 21 return do_create(new QPDF_Real(val));
22 } 22 }
23 23
24 -std::shared_ptr<QPDFValueProxy> 24 +std::shared_ptr<QPDFObject>
25 QPDF_Real::create(double value, int decimal_places, bool trim_trailing_zeroes) 25 QPDF_Real::create(double value, int decimal_places, bool trim_trailing_zeroes)
26 { 26 {
27 return do_create( 27 return do_create(
28 new QPDF_Real(value, decimal_places, trim_trailing_zeroes)); 28 new QPDF_Real(value, decimal_places, trim_trailing_zeroes));
29 } 29 }
30 30
31 -std::shared_ptr<QPDFValueProxy> 31 +std::shared_ptr<QPDFObject>
32 QPDF_Real::shallowCopy() 32 QPDF_Real::shallowCopy()
33 { 33 {
34 return create(val); 34 return create(val);
libqpdf/QPDF_Reserved.cc
@@ -7,13 +7,13 @@ QPDF_Reserved::QPDF_Reserved() : @@ -7,13 +7,13 @@ QPDF_Reserved::QPDF_Reserved() :
7 { 7 {
8 } 8 }
9 9
10 -std::shared_ptr<QPDFValueProxy> 10 +std::shared_ptr<QPDFObject>
11 QPDF_Reserved::create() 11 QPDF_Reserved::create()
12 { 12 {
13 return do_create(new QPDF_Reserved()); 13 return do_create(new QPDF_Reserved());
14 } 14 }
15 15
16 -std::shared_ptr<QPDFValueProxy> 16 +std::shared_ptr<QPDFObject>
17 QPDF_Reserved::shallowCopy() 17 QPDF_Reserved::shallowCopy()
18 { 18 {
19 return create(); 19 return create();
libqpdf/QPDF_Stream.cc
@@ -130,7 +130,7 @@ QPDF_Stream::QPDF_Stream( @@ -130,7 +130,7 @@ QPDF_Stream::QPDF_Stream(
130 qpdf, qpdf->getFilename() + ", stream object " + og.unparse(' ')); 130 qpdf, qpdf->getFilename() + ", stream object " + og.unparse(' '));
131 } 131 }
132 132
133 -std::shared_ptr<QPDFValueProxy> 133 +std::shared_ptr<QPDFObject>
134 QPDF_Stream::create( 134 QPDF_Stream::create(
135 QPDF* qpdf, 135 QPDF* qpdf,
136 QPDFObjGen const& og, 136 QPDFObjGen const& og,
@@ -141,7 +141,7 @@ QPDF_Stream::create( @@ -141,7 +141,7 @@ QPDF_Stream::create(
141 return do_create(new QPDF_Stream(qpdf, og, stream_dict, offset, length)); 141 return do_create(new QPDF_Stream(qpdf, og, stream_dict, offset, length));
142 } 142 }
143 143
144 -std::shared_ptr<QPDFValueProxy> 144 +std::shared_ptr<QPDFObject>
145 QPDF_Stream::shallowCopy() 145 QPDF_Stream::shallowCopy()
146 { 146 {
147 throw std::logic_error("stream objects cannot be cloned"); 147 throw std::logic_error("stream objects cannot be cloned");
libqpdf/QPDF_String.cc
@@ -26,13 +26,13 @@ QPDF_String::QPDF_String(std::string const&amp; val) : @@ -26,13 +26,13 @@ QPDF_String::QPDF_String(std::string const&amp; val) :
26 { 26 {
27 } 27 }
28 28
29 -std::shared_ptr<QPDFValueProxy> 29 +std::shared_ptr<QPDFObject>
30 QPDF_String::create(std::string const& val) 30 QPDF_String::create(std::string const& val)
31 { 31 {
32 return do_create(new QPDF_String(val)); 32 return do_create(new QPDF_String(val));
33 } 33 }
34 34
35 -std::shared_ptr<QPDFValueProxy> 35 +std::shared_ptr<QPDFObject>
36 QPDF_String::create_utf16(std::string const& utf8_val) 36 QPDF_String::create_utf16(std::string const& utf8_val)
37 { 37 {
38 std::string result; 38 std::string result;
@@ -42,7 +42,7 @@ QPDF_String::create_utf16(std::string const&amp; utf8_val) @@ -42,7 +42,7 @@ QPDF_String::create_utf16(std::string const&amp; utf8_val)
42 return do_create(new QPDF_String(result)); 42 return do_create(new QPDF_String(result));
43 } 43 }
44 44
45 -std::shared_ptr<QPDFValueProxy> 45 +std::shared_ptr<QPDFObject>
46 QPDF_String::shallowCopy() 46 QPDF_String::shallowCopy()
47 { 47 {
48 return create(val); 48 return create(val);
libqpdf/QPDF_Unresolved.cc
@@ -7,13 +7,13 @@ QPDF_Unresolved::QPDF_Unresolved(QPDF* qpdf, QPDFObjGen const&amp; og) : @@ -7,13 +7,13 @@ QPDF_Unresolved::QPDF_Unresolved(QPDF* qpdf, QPDFObjGen const&amp; og) :
7 { 7 {
8 } 8 }
9 9
10 -std::shared_ptr<QPDFValueProxy> 10 +std::shared_ptr<QPDFObject>
11 QPDF_Unresolved::create(QPDF* qpdf, QPDFObjGen const& og) 11 QPDF_Unresolved::create(QPDF* qpdf, QPDFObjGen const& og)
12 { 12 {
13 return do_create(new QPDF_Unresolved(qpdf, og)); 13 return do_create(new QPDF_Unresolved(qpdf, og));
14 } 14 }
15 15
16 -std::shared_ptr<QPDFValueProxy> 16 +std::shared_ptr<QPDFObject>
17 QPDF_Unresolved::shallowCopy() 17 QPDF_Unresolved::shallowCopy()
18 { 18 {
19 throw std::logic_error( 19 throw std::logic_error(
libqpdf/qpdf/QPDFObject_private.hh
@@ -16,14 +16,14 @@ @@ -16,14 +16,14 @@
16 class QPDF; 16 class QPDF;
17 class QPDFObjectHandle; 17 class QPDFObjectHandle;
18 18
19 -class QPDFValueProxy 19 +class QPDFObject
20 { 20 {
21 friend class QPDFValue; 21 friend class QPDFValue;
22 22
23 public: 23 public:
24 - QPDFValueProxy() = default; 24 + QPDFObject() = default;
25 25
26 - std::shared_ptr<QPDFValueProxy> 26 + std::shared_ptr<QPDFObject>
27 shallowCopy() 27 shallowCopy()
28 { 28 {
29 return value->shallowCopy(); 29 return value->shallowCopy();
@@ -91,12 +91,12 @@ class QPDFValueProxy @@ -91,12 +91,12 @@ class QPDFValueProxy
91 return value->getParsedOffset(); 91 return value->getParsedOffset();
92 } 92 }
93 void 93 void
94 - assign(std::shared_ptr<QPDFValueProxy> o) 94 + assign(std::shared_ptr<QPDFObject> o)
95 { 95 {
96 value = o->value; 96 value = o->value;
97 } 97 }
98 void 98 void
99 - swapWith(std::shared_ptr<QPDFValueProxy> o) 99 + swapWith(std::shared_ptr<QPDFObject> o)
100 { 100 {
101 auto v = value; 101 auto v = value;
102 value = o->value; 102 value = o->value;
@@ -148,8 +148,8 @@ class QPDFValueProxy @@ -148,8 +148,8 @@ class QPDFValueProxy
148 } 148 }
149 149
150 private: 150 private:
151 - QPDFValueProxy(QPDFValueProxy const&) = delete;  
152 - QPDFValueProxy& operator=(QPDFValueProxy const&) = delete; 151 + QPDFObject(QPDFObject const&) = delete;
  152 + QPDFObject& operator=(QPDFObject const&) = delete;
153 std::shared_ptr<QPDFValue> value; 153 std::shared_ptr<QPDFValue> value;
154 }; 154 };
155 155
libqpdf/qpdf/QPDFValue.hh
@@ -11,16 +11,16 @@ @@ -11,16 +11,16 @@
11 11
12 class QPDF; 12 class QPDF;
13 class QPDFObjectHandle; 13 class QPDFObjectHandle;
14 -class QPDFValueProxy; 14 +class QPDFObject;
15 15
16 class QPDFValue 16 class QPDFValue
17 { 17 {
18 - friend class QPDFValueProxy; 18 + friend class QPDFObject;
19 19
20 public: 20 public:
21 virtual ~QPDFValue() = default; 21 virtual ~QPDFValue() = default;
22 22
23 - virtual std::shared_ptr<QPDFValueProxy> shallowCopy() = 0; 23 + virtual std::shared_ptr<QPDFObject> shallowCopy() = 0;
24 virtual std::string unparse() = 0; 24 virtual std::string unparse() = 0;
25 virtual JSON getJSON(int json_version) = 0; 25 virtual JSON getJSON(int json_version) = 0;
26 virtual void 26 virtual void
@@ -91,7 +91,7 @@ class QPDFValue @@ -91,7 +91,7 @@ class QPDFValue
91 { 91 {
92 } 92 }
93 93
94 - static std::shared_ptr<QPDFValueProxy> do_create(QPDFValue*); 94 + static std::shared_ptr<QPDFObject> do_create(QPDFValue*);
95 95
96 private: 96 private:
97 QPDFValue(QPDFValue const&) = delete; 97 QPDFValue(QPDFValue const&) = delete;
libqpdf/qpdf/QPDF_Array.hh
@@ -11,10 +11,10 @@ class QPDF_Array: public QPDFValue @@ -11,10 +11,10 @@ class QPDF_Array: public QPDFValue
11 { 11 {
12 public: 12 public:
13 virtual ~QPDF_Array() = default; 13 virtual ~QPDF_Array() = default;
14 - static std::shared_ptr<QPDFValueProxy> 14 + static std::shared_ptr<QPDFObject>
15 create(std::vector<QPDFObjectHandle> const& items); 15 create(std::vector<QPDFObjectHandle> const& items);
16 - static std::shared_ptr<QPDFValueProxy> create(SparseOHArray const& items);  
17 - virtual std::shared_ptr<QPDFValueProxy> shallowCopy(); 16 + static std::shared_ptr<QPDFObject> create(SparseOHArray const& items);
  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 void disconnect(); 20 virtual void disconnect();
libqpdf/qpdf/QPDF_Bool.hh
@@ -7,8 +7,8 @@ class QPDF_Bool: public QPDFValue @@ -7,8 +7,8 @@ class QPDF_Bool: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_Bool() = default; 9 virtual ~QPDF_Bool() = default;
10 - static std::shared_ptr<QPDFValueProxy> create(bool val);  
11 - virtual std::shared_ptr<QPDFValueProxy> shallowCopy(); 10 + static std::shared_ptr<QPDFObject> create(bool val);
  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 bool getVal() const; 14 bool getVal() const;
libqpdf/qpdf/QPDF_Destroyed.hh
@@ -7,7 +7,7 @@ class QPDF_Destroyed: public QPDFValue @@ -7,7 +7,7 @@ class QPDF_Destroyed: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_Destroyed() = default; 9 virtual ~QPDF_Destroyed() = default;
10 - virtual std::shared_ptr<QPDFValueProxy> shallowCopy(); 10 + virtual std::shared_ptr<QPDFObject> shallowCopy();
11 virtual std::string unparse(); 11 virtual std::string unparse();
12 virtual JSON getJSON(int json_version); 12 virtual JSON getJSON(int json_version);
13 static std::shared_ptr<QPDFValue> getInstance(); 13 static std::shared_ptr<QPDFValue> getInstance();
libqpdf/qpdf/QPDF_Dictionary.hh
@@ -12,9 +12,9 @@ class QPDF_Dictionary: public QPDFValue @@ -12,9 +12,9 @@ class QPDF_Dictionary: public QPDFValue
12 { 12 {
13 public: 13 public:
14 virtual ~QPDF_Dictionary() = default; 14 virtual ~QPDF_Dictionary() = default;
15 - static std::shared_ptr<QPDFValueProxy> 15 + static std::shared_ptr<QPDFObject>
16 create(std::map<std::string, QPDFObjectHandle> const& items); 16 create(std::map<std::string, QPDFObjectHandle> const& items);
17 - virtual std::shared_ptr<QPDFValueProxy> 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 void disconnect(); 20 virtual void disconnect();
libqpdf/qpdf/QPDF_InlineImage.hh
@@ -7,8 +7,8 @@ class QPDF_InlineImage: public QPDFValue @@ -7,8 +7,8 @@ class QPDF_InlineImage: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_InlineImage() = default; 9 virtual ~QPDF_InlineImage() = default;
10 - static std::shared_ptr<QPDFValueProxy> create(std::string const& val);  
11 - virtual std::shared_ptr<QPDFValueProxy> shallowCopy(); 10 + static std::shared_ptr<QPDFObject> create(std::string const& val);
  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 std::string getVal() const; 14 std::string getVal() const;
libqpdf/qpdf/QPDF_Integer.hh
@@ -7,8 +7,8 @@ class QPDF_Integer: public QPDFValue @@ -7,8 +7,8 @@ class QPDF_Integer: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_Integer() = default; 9 virtual ~QPDF_Integer() = default;
10 - static std::shared_ptr<QPDFValueProxy> create(long long value);  
11 - virtual std::shared_ptr<QPDFValueProxy> shallowCopy(); 10 + static std::shared_ptr<QPDFObject> create(long long value);
  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 long long getVal() const; 14 long long getVal() const;
libqpdf/qpdf/QPDF_Name.hh
@@ -7,8 +7,8 @@ class QPDF_Name: public QPDFValue @@ -7,8 +7,8 @@ class QPDF_Name: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_Name() = default; 9 virtual ~QPDF_Name() = default;
10 - static std::shared_ptr<QPDFValueProxy> create(std::string const& name);  
11 - virtual std::shared_ptr<QPDFValueProxy> shallowCopy(); 10 + static std::shared_ptr<QPDFObject> create(std::string const& name);
  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 std::string getName() const; 14 std::string getName() const;
libqpdf/qpdf/QPDF_Null.hh
@@ -7,8 +7,8 @@ class QPDF_Null: public QPDFValue @@ -7,8 +7,8 @@ class QPDF_Null: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_Null() = default; 9 virtual ~QPDF_Null() = default;
10 - static std::shared_ptr<QPDFValueProxy> create();  
11 - virtual std::shared_ptr<QPDFValueProxy> shallowCopy(); 10 + static std::shared_ptr<QPDFObject> create();
  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 14
libqpdf/qpdf/QPDF_Operator.hh
@@ -7,8 +7,8 @@ class QPDF_Operator: public QPDFValue @@ -7,8 +7,8 @@ class QPDF_Operator: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_Operator() = default; 9 virtual ~QPDF_Operator() = default;
10 - static std::shared_ptr<QPDFValueProxy> create(std::string const& val);  
11 - virtual std::shared_ptr<QPDFValueProxy> shallowCopy(); 10 + static std::shared_ptr<QPDFObject> create(std::string const& val);
  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 std::string getVal() const; 14 std::string getVal() const;
libqpdf/qpdf/QPDF_Real.hh
@@ -7,10 +7,10 @@ class QPDF_Real: public QPDFValue @@ -7,10 +7,10 @@ class QPDF_Real: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_Real() = default; 9 virtual ~QPDF_Real() = default;
10 - static std::shared_ptr<QPDFValueProxy> create(std::string const& val);  
11 - static std::shared_ptr<QPDFValueProxy> 10 + static std::shared_ptr<QPDFObject> create(std::string const& val);
  11 + static std::shared_ptr<QPDFObject>
12 create(double value, int decimal_places, bool trim_trailing_zeroes); 12 create(double value, int decimal_places, bool trim_trailing_zeroes);
13 - virtual std::shared_ptr<QPDFValueProxy> 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 std::string getVal(); 16 std::string getVal();
libqpdf/qpdf/QPDF_Reserved.hh
@@ -7,8 +7,8 @@ class QPDF_Reserved: public QPDFValue @@ -7,8 +7,8 @@ class QPDF_Reserved: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_Reserved() = default; 9 virtual ~QPDF_Reserved() = default;
10 - static std::shared_ptr<QPDFValueProxy> create();  
11 - virtual std::shared_ptr<QPDFValueProxy> shallowCopy(); 10 + static std::shared_ptr<QPDFObject> create();
  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 14
libqpdf/qpdf/QPDF_Stream.hh
@@ -17,13 +17,13 @@ class QPDF_Stream: public QPDFValue @@ -17,13 +17,13 @@ class QPDF_Stream: public QPDFValue
17 { 17 {
18 public: 18 public:
19 virtual ~QPDF_Stream() = default; 19 virtual ~QPDF_Stream() = default;
20 - static std::shared_ptr<QPDFValueProxy> create( 20 + static std::shared_ptr<QPDFObject> create(
21 QPDF*, 21 QPDF*,
22 QPDFObjGen const& og, 22 QPDFObjGen const& og,
23 QPDFObjectHandle stream_dict, 23 QPDFObjectHandle stream_dict,
24 qpdf_offset_t offset, 24 qpdf_offset_t offset,
25 size_t length); 25 size_t length);
26 - virtual std::shared_ptr<QPDFValueProxy> 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 void setDescription(QPDF*, std::string const&); 29 virtual void setDescription(QPDF*, std::string const&);
libqpdf/qpdf/QPDF_String.hh
@@ -11,10 +11,10 @@ class QPDF_String: public QPDFValue @@ -11,10 +11,10 @@ class QPDF_String: public QPDFValue
11 11
12 public: 12 public:
13 virtual ~QPDF_String() = default; 13 virtual ~QPDF_String() = default;
14 - static std::shared_ptr<QPDFValueProxy> create(std::string const& val);  
15 - static std::shared_ptr<QPDFValueProxy> 14 + static std::shared_ptr<QPDFObject> create(std::string const& val);
  15 + static std::shared_ptr<QPDFObject>
16 create_utf16(std::string const& utf8_val); 16 create_utf16(std::string const& utf8_val);
17 - virtual std::shared_ptr<QPDFValueProxy> shallowCopy(); 17 + virtual std::shared_ptr<QPDFObject> shallowCopy();
18 virtual std::string unparse(); 18 virtual std::string unparse();
19 std::string unparse(bool force_binary); 19 std::string unparse(bool force_binary);
20 virtual JSON getJSON(int json_version); 20 virtual JSON getJSON(int json_version);
libqpdf/qpdf/QPDF_Unresolved.hh
@@ -7,9 +7,8 @@ class QPDF_Unresolved: public QPDFValue @@ -7,9 +7,8 @@ class QPDF_Unresolved: public QPDFValue
7 { 7 {
8 public: 8 public:
9 virtual ~QPDF_Unresolved() = default; 9 virtual ~QPDF_Unresolved() = default;
10 - static std::shared_ptr<QPDFValueProxy>  
11 - create(QPDF* qpdf, QPDFObjGen const& og);  
12 - virtual std::shared_ptr<QPDFValueProxy> shallowCopy(); 10 + static std::shared_ptr<QPDFObject> create(QPDF* qpdf, QPDFObjGen const& og);
  11 + virtual std::shared_ptr<QPDFObject> shallowCopy();
13 virtual std::string unparse(); 12 virtual std::string unparse();
14 virtual JSON getJSON(int json_version); 13 virtual JSON getJSON(int json_version);
15 14
manual/design.rst
@@ -349,18 +349,18 @@ Objects in qpdf 11 and Newer @@ -349,18 +349,18 @@ Objects in qpdf 11 and Newer
349 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 349 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
350 350
351 The object cache in ``QPDF`` contains a shared pointer to 351 The object cache in ``QPDF`` contains a shared pointer to
352 -``QPDFValueProxy``. Any ``QPDFObjectHandle`` resolved from an indirect 352 +``QPDFObject``. Any ``QPDFObjectHandle`` resolved from an indirect
353 reference to that object has a copy of that shared pointer. Each 353 reference to that object has a copy of that shared pointer. Each
354 -``QPDFValueProxy`` object contains a shared pointer to an object of  
355 -type ``QPDFValue``. The ``QPDFValue`` type is an abstract base class.  
356 -There is an implementation for each of the basic object types (array, 354 +``QPDFObject`` object contains a shared pointer to an object of type
  355 +``QPDFValue``. The ``QPDFValue`` type is an abstract base class. There
  356 +is an implementation for each of the basic object types (array,
357 dictionary, null, boolean, string, number, etc.) as well as a few 357 dictionary, null, boolean, string, number, etc.) as well as a few
358 -special ones including ``uninitialized``, ``unresolved``, and  
359 -``reserved``. When an object is first referenced, its underlying  
360 -``QPDFValue`` has type ``unresolved``. When the object is first  
361 -resolved, the ``QPDFValueProxy`` in the cache has its internal 358 +special ones including ``uninitialized``, ``unresolved``,
  359 +``reserved``, and ``destroyed``. When an object is first referenced,
  360 +its underlying ``QPDFValue`` has type ``unresolved``. When the object
  361 +is first resolved, the ``QPDFObject`` in the cache has its internal
362 ``QPDFValue`` replaced with the object as read from the file. Since it 362 ``QPDFValue`` replaced with the object as read from the file. Since it
363 -is the ``QPDFValueProxy`` object that is shared by all referencing 363 +is the ``QPDFObject`` object that is shared by all referencing
364 ``QPDFObjectHandle`` objects as well as by the owning ``QPDF`` object, 364 ``QPDFObjectHandle`` objects as well as by the owning ``QPDF`` object,
365 this ensures that any future changes to the object, including 365 this ensures that any future changes to the object, including
366 replacing the object with a completely different one, will be 366 replacing the object with a completely different one, will be
@@ -368,22 +368,24 @@ reflected across all ``QPDFObjectHandle`` objects that reference it. @@ -368,22 +368,24 @@ reflected across all ``QPDFObjectHandle`` objects that reference it.
368 368
369 A ``QPDFValue`` that originated from a PDF input source maintains a 369 A ``QPDFValue`` that originated from a PDF input source maintains a
370 pointer to the ``QPDF`` object that read it (its *owner*). When that 370 pointer to the ``QPDF`` object that read it (its *owner*). When that
371 -``QPDF`` object is destroyed, it replaces the value of each  
372 -``QPDFValueProxy`` in its cache with a direct ``null`` object and  
373 -clears the pointer to the owning ``QPDF``. This means that, if there  
374 -are still any referencing ``QPDFObjectHandle`` objects floating  
375 -around, requesting their owning ``QPDF`` will return a null pointer  
376 -rather than a pointer to a ``QPDF`` object that is either invalid or  
377 -points to something else. This operation also has the effect of  
378 -breaking any circular references (which are common and, in some cases,  
379 -required by the PDF specification), thus preventing memory leaks when  
380 -``QPDF`` objects are destroyed. 371 +``QPDF`` object is destroyed, it disconnects all reachable from it by
  372 +clearing their owner. For indirect objects (all objects in the object
  373 +cache), it also replaces the object's value with an object of type
  374 +``destroyed``. This means that, if there are still any referencing
  375 +``QPDFObjectHandle`` objects floating around, requesting their owning
  376 +``QPDF`` will return a null pointer rather than a pointer to a
  377 +``QPDF`` object that is either invalid or points to something else,
  378 +and any attempt to access an indirect object that is associated with a
  379 +destroyed ``QPDF`` object will throw an exception. This operation also
  380 +has the effect of breaking any circular references (which are common
  381 +and, in some cases, required by the PDF specification), thus
  382 +preventing memory leaks when ``QPDF`` objects are destroyed.
381 383
382 Objects prior to qpdf 11 384 Objects prior to qpdf 11
383 ~~~~~~~~~~~~~~~~~~~~~~~~ 385 ~~~~~~~~~~~~~~~~~~~~~~~~
384 386
385 Prior to qpdf 11, the functionality of the ``QPDFValue`` and 387 Prior to qpdf 11, the functionality of the ``QPDFValue`` and
386 -``QPDFValueProxy`` classes were combined into a single ``QPDFObject`` 388 +``QPDFObject`` classes were contained in a single ``QPDFObject``
387 class, which served the dual purpose of being the cache entry for 389 class, which served the dual purpose of being the cache entry for
388 ``QPDF`` and being the abstract base class for all the different PDF 390 ``QPDF`` and being the abstract base class for all the different PDF
389 object types. The behavior was nearly the same, but there were a few 391 object types. The behavior was nearly the same, but there were a few
@@ -415,7 +417,7 @@ problems: @@ -415,7 +417,7 @@ problems:
415 was still valid. 417 was still valid.
416 418
417 All of these problems were effectively solved by splitting 419 All of these problems were effectively solved by splitting
418 -``QPDFObject`` into ``QPDFValueProxy`` and ``QPDFValue``. 420 +``QPDFObject`` into ``QPDFObject`` and ``QPDFValue``.
419 421
420 .. _casting: 422 .. _casting:
421 423