Commit 6ad16cd1fdd25b195cec64582be589622dbb0f16

Authored by m-holger
1 parent f49f43fe

In FUTURE make QPDFObjectHandle methods const and noexcept where possible

include/qpdf/QPDFObjectHandle.hh
@@ -1371,12 +1371,12 @@ class QPDFObjectHandle @@ -1371,12 +1371,12 @@ class QPDFObjectHandle
1371 QPDF_Real* asReal() const; 1371 QPDF_Real* asReal() const;
1372 QPDF_Reserved* asReserved() const; 1372 QPDF_Reserved* asReserved() const;
1373 QPDF_Stream* asStream() const; 1373 QPDF_Stream* asStream() const;
1374 - QPDF_Stream* asStreamWithAssert(); 1374 + QPDF_Stream* asStreamWithAssert() const;
1375 QPDF_String* asString() const; 1375 QPDF_String* asString() const;
1376 1376
1377 - void typeWarning(char const* expected_type, std::string const& warning);  
1378 - void objectWarning(std::string const& warning);  
1379 - void assertType(char const* type_name, bool istype); 1377 + void typeWarning(char const* expected_type, std::string const& warning) const;
  1378 + void objectWarning(std::string const& warning) const;
  1379 + void assertType(char const* type_name, bool istype) const;
1380 void makeDirect(QPDFObjGen::set& visited, bool stop_at_streams); 1380 void makeDirect(QPDFObjGen::set& visited, bool stop_at_streams);
1381 void disconnect(); 1381 void disconnect();
1382 void setParsedOffset(qpdf_offset_t offset); 1382 void setParsedOffset(qpdf_offset_t offset);
include/qpdf/QPDFObjectHandle_future.hh
@@ -296,48 +296,48 @@ class QPDFObjectHandle @@ -296,48 +296,48 @@ class QPDFObjectHandle
296 QPDFObjectHandle& operator=(QPDFObjectHandle&&) = default; 296 QPDFObjectHandle& operator=(QPDFObjectHandle&&) = default;
297 297
298 QPDF_DLL 298 QPDF_DLL
299 - inline bool isInitialized() const; 299 + inline bool isInitialized() const noexcept;
300 300
301 // This method returns true if the QPDFObjectHandle objects point to exactly the same underlying 301 // This method returns true if the QPDFObjectHandle objects point to exactly the same underlying
302 // object, meaning that changes to one are reflected in the other, or "if you paint one, the 302 // object, meaning that changes to one are reflected in the other, or "if you paint one, the
303 // other one changes color." This does not perform a structural comparison of the contents of 303 // other one changes color." This does not perform a structural comparison of the contents of
304 // the objects. 304 // the objects.
305 QPDF_DLL 305 QPDF_DLL
306 - bool isSameObjectAs(QPDFObjectHandle const&) const; 306 + bool isSameObjectAs(QPDFObjectHandle const&) const noexcept;
307 307
308 // Return type code and type name of underlying object. These are useful for doing rapid type 308 // Return type code and type name of underlying object. These are useful for doing rapid type
309 // tests (like switch statements) or for testing and debugging. 309 // tests (like switch statements) or for testing and debugging.
310 QPDF_DLL 310 QPDF_DLL
311 - qpdf_object_type_e getTypeCode(); 311 + qpdf_object_type_e getTypeCode() const;
312 QPDF_DLL 312 QPDF_DLL
313 - char const* getTypeName(); 313 + char const* getTypeName() const;
314 314
315 // Exactly one of these will return true for any initialized object. Operator and InlineImage 315 // Exactly one of these will return true for any initialized object. Operator and InlineImage
316 // are only allowed in content streams. 316 // are only allowed in content streams.
317 QPDF_DLL 317 QPDF_DLL
318 - bool isBool(); 318 + bool isBool() const;
319 QPDF_DLL 319 QPDF_DLL
320 - bool isNull(); 320 + bool isNull() const;
321 QPDF_DLL 321 QPDF_DLL
322 - bool isInteger(); 322 + bool isInteger() const;
323 QPDF_DLL 323 QPDF_DLL
324 - bool isReal(); 324 + bool isReal() const;
325 QPDF_DLL 325 QPDF_DLL
326 - bool isName(); 326 + bool isName() const;
327 QPDF_DLL 327 QPDF_DLL
328 - bool isString(); 328 + bool isString() const;
329 QPDF_DLL 329 QPDF_DLL
330 - bool isOperator(); 330 + bool isOperator() const;
331 QPDF_DLL 331 QPDF_DLL
332 - bool isInlineImage(); 332 + bool isInlineImage() const;
333 QPDF_DLL 333 QPDF_DLL
334 - bool isArray(); 334 + bool isArray() const;
335 QPDF_DLL 335 QPDF_DLL
336 - bool isDictionary(); 336 + bool isDictionary() const;
337 QPDF_DLL 337 QPDF_DLL
338 - bool isStream(); 338 + bool isStream() const;
339 QPDF_DLL 339 QPDF_DLL
340 - bool isReserved(); 340 + bool isReserved() const;
341 341
342 // True for objects that are direct nulls. Does not attempt to resolve objects. This is intended 342 // True for objects that are direct nulls. Does not attempt to resolve objects. This is intended
343 // for internal use, but it can be used as an efficient way to check for nulls that are not 343 // for internal use, but it can be used as an efficient way to check for nulls that are not
@@ -352,23 +352,23 @@ class QPDFObjectHandle @@ -352,23 +352,23 @@ class QPDFObjectHandle
352 // This returns true for indirect objects from a QPDF that has been destroyed. Trying unparse 352 // This returns true for indirect objects from a QPDF that has been destroyed. Trying unparse
353 // such an object will throw a logic_error. 353 // such an object will throw a logic_error.
354 QPDF_DLL 354 QPDF_DLL
355 - bool isDestroyed(); 355 + bool isDestroyed() const;
356 356
357 // True for everything except array, dictionary, stream, word, and inline image. 357 // True for everything except array, dictionary, stream, word, and inline image.
358 QPDF_DLL 358 QPDF_DLL
359 - bool isScalar(); 359 + bool isScalar() const;
360 360
361 // True if the object is a name object representing the provided name. 361 // True if the object is a name object representing the provided name.
362 QPDF_DLL 362 QPDF_DLL
363 - bool isNameAndEquals(std::string const& name); 363 + bool isNameAndEquals(std::string const& name) const;
364 364
365 // True if the object is a dictionary of the specified type and subtype, if any. 365 // True if the object is a dictionary of the specified type and subtype, if any.
366 QPDF_DLL 366 QPDF_DLL
367 - bool isDictionaryOfType(std::string const& type, std::string const& subtype = ""); 367 + bool isDictionaryOfType(std::string const& type, std::string const& subtype = "") const;
368 368
369 // True if the object is a stream of the specified type and subtype, if any. 369 // True if the object is a stream of the specified type and subtype, if any.
370 QPDF_DLL 370 QPDF_DLL
371 - bool isStreamOfType(std::string const& type, std::string const& subtype = ""); 371 + bool isStreamOfType(std::string const& type, std::string const& subtype = "") const;
372 372
373 // Public factory methods 373 // Public factory methods
374 374
@@ -413,7 +413,7 @@ class QPDFObjectHandle @@ -413,7 +413,7 @@ class QPDFObjectHandle
413 // object was created without parsing. If the object is in a stream, the offset is from the 413 // object was created without parsing. If the object is in a stream, the offset is from the
414 // beginning of the stream. Otherwise, the offset is from the beginning of the file. 414 // beginning of the stream. Otherwise, the offset is from the beginning of the file.
415 QPDF_DLL 415 QPDF_DLL
416 - qpdf_offset_t getParsedOffset(); 416 + qpdf_offset_t getParsedOffset() const;
417 417
418 // Older method: stream_or_array should be the value of /Contents from a page object. It's more 418 // Older method: stream_or_array should be the value of /Contents from a page object. It's more
419 // convenient to just call QPDFPageObjectHelper::parsePageContents on the page object, and error 419 // convenient to just call QPDFPageObjectHelper::parsePageContents on the page object, and error
@@ -585,7 +585,7 @@ class QPDFObjectHandle @@ -585,7 +585,7 @@ class QPDFObjectHandle
585 QPDF_DLL 585 QPDF_DLL
586 void setObjectDescription(QPDF* owning_qpdf, std::string const& object_description); 586 void setObjectDescription(QPDF* owning_qpdf, std::string const& object_description);
587 QPDF_DLL 587 QPDF_DLL
588 - bool hasObjectDescription(); 588 + bool hasObjectDescription() const;
589 589
590 // Accessor methods 590 // Accessor methods
591 // 591 //
@@ -635,57 +635,57 @@ class QPDFObjectHandle @@ -635,57 +635,57 @@ class QPDFObjectHandle
635 635
636 // Methods for bool objects 636 // Methods for bool objects
637 QPDF_DLL 637 QPDF_DLL
638 - bool getBoolValue(); 638 + bool getBoolValue() const;
639 QPDF_DLL 639 QPDF_DLL
640 - bool getValueAsBool(bool&); 640 + bool getValueAsBool(bool&) const;
641 641
642 // Methods for integer objects. Note: if an integer value is too big (too far away from zero in 642 // Methods for integer objects. Note: if an integer value is too big (too far away from zero in
643 // either direction) to fit in the requested return type, the maximum or minimum value for that 643 // either direction) to fit in the requested return type, the maximum or minimum value for that
644 // return type may be returned. For example, on a system with 32-bit int, a numeric object with 644 // return type may be returned. For example, on a system with 32-bit int, a numeric object with
645 // a value of 2^40 (or anything too big for 32 bits) will be returned as INT_MAX. 645 // a value of 2^40 (or anything too big for 32 bits) will be returned as INT_MAX.
646 QPDF_DLL 646 QPDF_DLL
647 - long long getIntValue(); 647 + long long getIntValue() const;
648 QPDF_DLL 648 QPDF_DLL
649 - bool getValueAsInt(long long&); 649 + bool getValueAsInt(long long&) const;
650 QPDF_DLL 650 QPDF_DLL
651 - int getIntValueAsInt(); 651 + int getIntValueAsInt() const;
652 QPDF_DLL 652 QPDF_DLL
653 - bool getValueAsInt(int&); 653 + bool getValueAsInt(int&) const;
654 QPDF_DLL 654 QPDF_DLL
655 - unsigned long long getUIntValue(); 655 + unsigned long long getUIntValue() const;
656 QPDF_DLL 656 QPDF_DLL
657 - bool getValueAsUInt(unsigned long long&); 657 + bool getValueAsUInt(unsigned long long&) const;
658 QPDF_DLL 658 QPDF_DLL
659 - unsigned int getUIntValueAsUInt(); 659 + unsigned int getUIntValueAsUInt() const;
660 QPDF_DLL 660 QPDF_DLL
661 - bool getValueAsUInt(unsigned int&); 661 + bool getValueAsUInt(unsigned int&) const;
662 662
663 // Methods for real objects 663 // Methods for real objects
664 QPDF_DLL 664 QPDF_DLL
665 - std::string getRealValue(); 665 + std::string getRealValue() const;
666 QPDF_DLL 666 QPDF_DLL
667 - bool getValueAsReal(std::string&); 667 + bool getValueAsReal(std::string&) const;
668 668
669 // Methods that work for both integer and real objects 669 // Methods that work for both integer and real objects
670 QPDF_DLL 670 QPDF_DLL
671 - bool isNumber(); 671 + bool isNumber() const;
672 QPDF_DLL 672 QPDF_DLL
673 - double getNumericValue(); 673 + double getNumericValue() const;
674 QPDF_DLL 674 QPDF_DLL
675 - bool getValueAsNumber(double&); 675 + bool getValueAsNumber(double&) const;
676 676
677 // Methods for name objects. The returned name value is in qpdf's canonical form with all 677 // Methods for name objects. The returned name value is in qpdf's canonical form with all
678 // escaping resolved. See comments for newName() for details. 678 // escaping resolved. See comments for newName() for details.
679 QPDF_DLL 679 QPDF_DLL
680 - std::string getName(); 680 + std::string getName() const;
681 QPDF_DLL 681 QPDF_DLL
682 - bool getValueAsName(std::string&); 682 + bool getValueAsName(std::string&) const;
683 683
684 // Methods for string objects 684 // Methods for string objects
685 QPDF_DLL 685 QPDF_DLL
686 - std::string getStringValue(); 686 + std::string getStringValue() const;
687 QPDF_DLL 687 QPDF_DLL
688 - bool getValueAsString(std::string&); 688 + bool getValueAsString(std::string&) const;
689 689
690 // If a string starts with the UTF-16 marker, it is converted from UTF-16 to UTF-8. Otherwise, 690 // If a string starts with the UTF-16 marker, it is converted from UTF-16 to UTF-8. Otherwise,
691 // it is treated as a string encoded with PDF Doc Encoding. PDF Doc Encoding is identical to 691 // it is treated as a string encoded with PDF Doc Encoding. PDF Doc Encoding is identical to
@@ -693,19 +693,19 @@ class QPDFObjectHandle @@ -693,19 +693,19 @@ class QPDFObjectHandle
693 // to Unicode. QPDF versions prior to version 8.0.0 erroneously left characters in that range 693 // to Unicode. QPDF versions prior to version 8.0.0 erroneously left characters in that range
694 // unmapped. 694 // unmapped.
695 QPDF_DLL 695 QPDF_DLL
696 - std::string getUTF8Value(); 696 + std::string getUTF8Value() const;
697 QPDF_DLL 697 QPDF_DLL
698 - bool getValueAsUTF8(std::string&); 698 + bool getValueAsUTF8(std::string&) const;
699 699
700 // Methods for content stream objects 700 // Methods for content stream objects
701 QPDF_DLL 701 QPDF_DLL
702 - std::string getOperatorValue(); 702 + std::string getOperatorValue() const;
703 QPDF_DLL 703 QPDF_DLL
704 - bool getValueAsOperator(std::string&); 704 + bool getValueAsOperator(std::string&) const;
705 QPDF_DLL 705 QPDF_DLL
706 - std::string getInlineImageValue(); 706 + std::string getInlineImageValue() const;
707 QPDF_DLL 707 QPDF_DLL
708 - bool getValueAsInlineImage(std::string&); 708 + bool getValueAsInlineImage(std::string&) const;
709 709
710 // Methods for array objects; see also name and array objects. 710 // Methods for array objects; see also name and array objects.
711 711
@@ -720,26 +720,26 @@ class QPDFObjectHandle @@ -720,26 +720,26 @@ class QPDFObjectHandle
720 QPDFArrayItems aitems(); 720 QPDFArrayItems aitems();
721 721
722 QPDF_DLL 722 QPDF_DLL
723 - int getArrayNItems(); 723 + int getArrayNItems() const;
724 QPDF_DLL 724 QPDF_DLL
725 - QPDFObjectHandle getArrayItem(int n); 725 + QPDFObjectHandle getArrayItem(int n) const;
726 // Note: QPDF arrays internally optimize memory for arrays containing lots of nulls. Calling 726 // Note: QPDF arrays internally optimize memory for arrays containing lots of nulls. Calling
727 // getArrayAsVector may cause a lot of memory to be allocated for very large arrays with lots of 727 // getArrayAsVector may cause a lot of memory to be allocated for very large arrays with lots of
728 // nulls. 728 // nulls.
729 QPDF_DLL 729 QPDF_DLL
730 - std::vector<QPDFObjectHandle> getArrayAsVector(); 730 + std::vector<QPDFObjectHandle> getArrayAsVector() const;
731 QPDF_DLL 731 QPDF_DLL
732 - bool isRectangle(); 732 + bool isRectangle() const;
733 // If the array is an array of four numeric values, return as a rectangle. Otherwise, return the 733 // If the array is an array of four numeric values, return as a rectangle. Otherwise, return the
734 // rectangle [0, 0, 0, 0] 734 // rectangle [0, 0, 0, 0]
735 QPDF_DLL 735 QPDF_DLL
736 - Rectangle getArrayAsRectangle(); 736 + Rectangle getArrayAsRectangle() const;
737 QPDF_DLL 737 QPDF_DLL
738 - bool isMatrix(); 738 + bool isMatrix() const;
739 // If the array is an array of six numeric values, return as a matrix. Otherwise, return the 739 // If the array is an array of six numeric values, return as a matrix. Otherwise, return the
740 // matrix [1, 0, 0, 1, 0, 0] 740 // matrix [1, 0, 0, 1, 0, 0]
741 QPDF_DLL 741 QPDF_DLL
742 - Matrix getArrayAsMatrix(); 742 + Matrix getArrayAsMatrix() const;
743 743
744 // Methods for dictionary objects. In all dictionary methods, keys are specified/represented as 744 // Methods for dictionary objects. In all dictionary methods, keys are specified/represented as
745 // canonical name strings starting with a leading slash and not containing any PDF syntax 745 // canonical name strings starting with a leading slash and not containing any PDF syntax
@@ -759,27 +759,27 @@ class QPDFObjectHandle @@ -759,27 +759,27 @@ class QPDFObjectHandle
759 // Return true if key is present. Keys with null values are treated as if they are not present. 759 // Return true if key is present. Keys with null values are treated as if they are not present.
760 // This is as per the PDF spec. 760 // This is as per the PDF spec.
761 QPDF_DLL 761 QPDF_DLL
762 - bool hasKey(std::string const&); 762 + bool hasKey(std::string const&) const;
763 // Return the value for the key. If the key is not present, null is returned. 763 // Return the value for the key. If the key is not present, null is returned.
764 QPDF_DLL 764 QPDF_DLL
765 - QPDFObjectHandle getKey(std::string const&); 765 + QPDFObjectHandle getKey(std::string const&) const;
766 // If the object is null, return null. Otherwise, call getKey(). This makes it easier to access 766 // If the object is null, return null. Otherwise, call getKey(). This makes it easier to access
767 // lower-level dictionaries, as in 767 // lower-level dictionaries, as in
768 // auto font = page.getKeyIfDict("/Resources").getKeyIfDict("/Font"); 768 // auto font = page.getKeyIfDict("/Resources").getKeyIfDict("/Font");
769 QPDF_DLL 769 QPDF_DLL
770 - QPDFObjectHandle getKeyIfDict(std::string const&); 770 + QPDFObjectHandle getKeyIfDict(std::string const&) const;
771 // Return all keys. Keys with null values are treated as if they are not present. This is as 771 // Return all keys. Keys with null values are treated as if they are not present. This is as
772 // per the PDF spec. 772 // per the PDF spec.
773 QPDF_DLL 773 QPDF_DLL
774 - std::set<std::string> getKeys(); 774 + std::set<std::string> getKeys() const;
775 // Return dictionary as a map. Entries with null values are included. 775 // Return dictionary as a map. Entries with null values are included.
776 QPDF_DLL 776 QPDF_DLL
777 - std::map<std::string, QPDFObjectHandle> getDictAsMap(); 777 + std::map<std::string, QPDFObjectHandle> getDictAsMap() const;
778 778
779 // Methods for name and array objects. The name value is in qpdf's canonical form with all 779 // Methods for name and array objects. The name value is in qpdf's canonical form with all
780 // escaping resolved. See comments for newName() for details. 780 // escaping resolved. See comments for newName() for details.
781 QPDF_DLL 781 QPDF_DLL
782 - bool isOrHasName(std::string const&); 782 + bool isOrHasName(std::string const&) const;
783 783
784 // Make all resources in a resource dictionary indirect. This just goes through all entries of 784 // Make all resources in a resource dictionary indirect. This just goes through all entries of
785 // top-level subdictionaries and converts any direct objects to indirect objects. This can be 785 // top-level subdictionaries and converts any direct objects to indirect objects. This can be
@@ -829,7 +829,7 @@ class QPDFObjectHandle @@ -829,7 +829,7 @@ class QPDFObjectHandle
829 // method returns a set of all the keys in all top-level subdictionaries. For resources 829 // method returns a set of all the keys in all top-level subdictionaries. For resources
830 // dictionaries, this is the collection of names that may be referenced in the content stream. 830 // dictionaries, this is the collection of names that may be referenced in the content stream.
831 QPDF_DLL 831 QPDF_DLL
832 - std::set<std::string> getResourceNames(); 832 + std::set<std::string> getResourceNames() const;
833 833
834 // Find a unique name within a resource dictionary starting with a given prefix. This method 834 // Find a unique name within a resource dictionary starting with a given prefix. This method
835 // works by appending a number to the given prefix. It searches starting with min_suffix and 835 // works by appending a number to the given prefix. It searches starting with min_suffix and
@@ -844,7 +844,7 @@ class QPDFObjectHandle @@ -844,7 +844,7 @@ class QPDFObjectHandle
844 std::string getUniqueResourceName( 844 std::string getUniqueResourceName(
845 std::string const& prefix, 845 std::string const& prefix,
846 int& min_suffix, 846 int& min_suffix,
847 - std::set<std::string>* resource_names = nullptr); 847 + std::set<std::string>* resource_names = nullptr) const;
848 848
849 // A QPDFObjectHandle has an owning QPDF if it is associated with ("owned by") a specific QPDF 849 // A QPDFObjectHandle has an owning QPDF if it is associated with ("owned by") a specific QPDF
850 // object. Indirect objects always have an owning QPDF. Direct objects that are read from the 850 // object. Indirect objects always have an owning QPDF. Direct objects that are read from the
@@ -964,7 +964,7 @@ class QPDFObjectHandle @@ -964,7 +964,7 @@ class QPDFObjectHandle
964 964
965 // Methods for stream objects 965 // Methods for stream objects
966 QPDF_DLL 966 QPDF_DLL
967 - QPDFObjectHandle getDict(); 967 + QPDFObjectHandle getDict() const;
968 968
969 // By default, or if true passed, QPDFWriter will attempt to filter a stream based on decode 969 // By default, or if true passed, QPDFWriter will attempt to filter a stream based on decode
970 // level, whether compression is enabled, and its ability to filter. Passing false will prevent 970 // level, whether compression is enabled, and its ability to filter. Passing false will prevent
@@ -1153,12 +1153,12 @@ class QPDFObjectHandle @@ -1153,12 +1153,12 @@ class QPDFObjectHandle
1153 inline int getGeneration() const; 1153 inline int getGeneration() const;
1154 1154
1155 QPDF_DLL 1155 QPDF_DLL
1156 - std::string unparse(); 1156 + std::string unparse() const;
1157 QPDF_DLL 1157 QPDF_DLL
1158 - std::string unparseResolved(); 1158 + std::string unparseResolved() const;
1159 // For strings only, force binary representation. Otherwise, same as unparse. 1159 // For strings only, force binary representation. Otherwise, same as unparse.
1160 QPDF_DLL 1160 QPDF_DLL
1161 - std::string unparseBinary(); 1161 + std::string unparseBinary() const;
1162 1162
1163 // Return encoded as JSON. The constant JSON::LATEST can be used to specify the latest available 1163 // Return encoded as JSON. The constant JSON::LATEST can be used to specify the latest available
1164 // JSON version. The JSON is generated as follows: 1164 // JSON version. The JSON is generated as follows:
@@ -1192,19 +1192,19 @@ class QPDFObjectHandle @@ -1192,19 +1192,19 @@ class QPDFObjectHandle
1192 // the object. The effect of dereference_indirect applies only to this object. It is not 1192 // the object. The effect of dereference_indirect applies only to this object. It is not
1193 // recursive. 1193 // recursive.
1194 QPDF_DLL 1194 QPDF_DLL
1195 - JSON getJSON(int json_version, bool dereference_indirect = false); 1195 + JSON getJSON(int json_version, bool dereference_indirect = false) const;
1196 1196
1197 // Write the object encoded as JSON to a pipeline. This is equivalent to, but more efficient 1197 // Write the object encoded as JSON to a pipeline. This is equivalent to, but more efficient
1198 // than, calling getJSON(json_version, dereference_indirect).write(p, depth). See the 1198 // than, calling getJSON(json_version, dereference_indirect).write(p, depth). See the
1199 // documentation for getJSON and JSON::write for further detail. 1199 // documentation for getJSON and JSON::write for further detail.
1200 QPDF_DLL 1200 QPDF_DLL
1201 - void  
1202 - writeJSON(int json_version, Pipeline* p, bool dereference_indirect = false, size_t depth = 0); 1201 + void writeJSON(
  1202 + int json_version, Pipeline* p, bool dereference_indirect = false, size_t depth = 0) const;
1203 1203
1204 // Deprecated version uses v1 for backward compatibility. 1204 // Deprecated version uses v1 for backward compatibility.
1205 // ABI: remove for qpdf 12 1205 // ABI: remove for qpdf 12
1206 [[deprecated("Use getJSON(int version)")]] QPDF_DLL JSON 1206 [[deprecated("Use getJSON(int version)")]] QPDF_DLL JSON
1207 - getJSON(bool dereference_indirect = false); 1207 + getJSON(bool dereference_indirect = false) const;
1208 1208
1209 // This method can be called on a stream to get a more extended JSON representation of the 1209 // This method can be called on a stream to get a more extended JSON representation of the
1210 // stream that includes the stream's data. The JSON object returned is always a dictionary whose 1210 // stream that includes the stream's data. The JSON object returned is always a dictionary whose
@@ -1257,7 +1257,7 @@ class QPDFObjectHandle @@ -1257,7 +1257,7 @@ class QPDFObjectHandle
1257 // normally from the file have descriptions. See comments on setObjectDescription for additional 1257 // normally from the file have descriptions. See comments on setObjectDescription for additional
1258 // details. 1258 // details.
1259 QPDF_DLL 1259 QPDF_DLL
1260 - void warnIfPossible(std::string const& warning); 1260 + void warnIfPossible(std::string const& warning) const;
1261 1261
1262 // Provide access to specific classes for recursive disconnected(). 1262 // Provide access to specific classes for recursive disconnected().
1263 class DisconnectAccess 1263 class DisconnectAccess
@@ -1280,55 +1280,55 @@ class QPDFObjectHandle @@ -1280,55 +1280,55 @@ class QPDFObjectHandle
1280 void assertInitialized() const; 1280 void assertInitialized() const;
1281 1281
1282 QPDF_DLL 1282 QPDF_DLL
1283 - void assertNull(); 1283 + void assertNull() const;
1284 QPDF_DLL 1284 QPDF_DLL
1285 - void assertBool(); 1285 + void assertBool() const;
1286 QPDF_DLL 1286 QPDF_DLL
1287 - void assertInteger(); 1287 + void assertInteger() const;
1288 QPDF_DLL 1288 QPDF_DLL
1289 - void assertReal(); 1289 + void assertReal() const;
1290 QPDF_DLL 1290 QPDF_DLL
1291 - void assertName(); 1291 + void assertName() const;
1292 QPDF_DLL 1292 QPDF_DLL
1293 - void assertString(); 1293 + void assertString() const;
1294 QPDF_DLL 1294 QPDF_DLL
1295 - void assertOperator(); 1295 + void assertOperator() const;
1296 QPDF_DLL 1296 QPDF_DLL
1297 - void assertInlineImage(); 1297 + void assertInlineImage() const;
1298 QPDF_DLL 1298 QPDF_DLL
1299 - void assertArray(); 1299 + void assertArray() const;
1300 QPDF_DLL 1300 QPDF_DLL
1301 - void assertDictionary(); 1301 + void assertDictionary() const;
1302 QPDF_DLL 1302 QPDF_DLL
1303 - void assertStream(); 1303 + void assertStream() const;
1304 QPDF_DLL 1304 QPDF_DLL
1305 - void assertReserved(); 1305 + void assertReserved() const;
1306 1306
1307 QPDF_DLL 1307 QPDF_DLL
1308 - void assertIndirect(); 1308 + void assertIndirect() const;
1309 QPDF_DLL 1309 QPDF_DLL
1310 - void assertScalar(); 1310 + void assertScalar() const;
1311 QPDF_DLL 1311 QPDF_DLL
1312 - void assertNumber(); 1312 + void assertNumber() const;
1313 1313
1314 // The isPageObject method checks the /Type key of the object. This is not completely reliable 1314 // The isPageObject method checks the /Type key of the object. This is not completely reliable
1315 // as there are some otherwise valid files whose /Type is wrong for page objects. qpdf is 1315 // as there are some otherwise valid files whose /Type is wrong for page objects. qpdf is
1316 // slightly more accepting but may still return false here when treating the object as a page 1316 // slightly more accepting but may still return false here when treating the object as a page
1317 // would work. Use this sparingly. 1317 // would work. Use this sparingly.
1318 QPDF_DLL 1318 QPDF_DLL
1319 - bool isPageObject(); 1319 + bool isPageObject() const;
1320 QPDF_DLL 1320 QPDF_DLL
1321 - bool isPagesObject(); 1321 + bool isPagesObject() const;
1322 QPDF_DLL 1322 QPDF_DLL
1323 - void assertPageObject(); 1323 + void assertPageObject() const;
1324 1324
1325 QPDF_DLL 1325 QPDF_DLL
1326 - bool isFormXObject(); 1326 + bool isFormXObject() const;
1327 1327
1328 // Indicate if this is an image. If exclude_imagemask is true, don't count image masks as 1328 // Indicate if this is an image. If exclude_imagemask is true, don't count image masks as
1329 // images. 1329 // images.
1330 QPDF_DLL 1330 QPDF_DLL
1331 - bool isImage(bool exclude_imagemask = true); 1331 + bool isImage(bool exclude_imagemask = true) const;
1332 1332
1333 // The following methods do not form part of the public API and are for internal use only. 1333 // The following methods do not form part of the public API and are for internal use only.
1334 1334
@@ -1357,7 +1357,7 @@ class QPDFObjectHandle @@ -1357,7 +1357,7 @@ class QPDFObjectHandle
1357 return obj.get(); 1357 return obj.get();
1358 } 1358 }
1359 1359
1360 - void writeJSON(int json_version, JSON::Writer& p, bool dereference_indirect = false); 1360 + void writeJSON(int json_version, JSON::Writer& p, bool dereference_indirect = false) const;
1361 1361
1362 private: 1362 private:
1363 QPDF_Array* asArray() const; 1363 QPDF_Array* asArray() const;
@@ -1371,12 +1371,12 @@ class QPDFObjectHandle @@ -1371,12 +1371,12 @@ class QPDFObjectHandle
1371 QPDF_Real* asReal() const; 1371 QPDF_Real* asReal() const;
1372 QPDF_Reserved* asReserved() const; 1372 QPDF_Reserved* asReserved() const;
1373 QPDF_Stream* asStream() const; 1373 QPDF_Stream* asStream() const;
1374 - QPDF_Stream* asStreamWithAssert(); 1374 + QPDF_Stream* asStreamWithAssert() const;
1375 QPDF_String* asString() const; 1375 QPDF_String* asString() const;
1376 1376
1377 - void typeWarning(char const* expected_type, std::string const& warning);  
1378 - void objectWarning(std::string const& warning);  
1379 - void assertType(char const* type_name, bool istype); 1377 + void typeWarning(char const* expected_type, std::string const& warning) const;
  1378 + void objectWarning(std::string const& warning) const;
  1379 + void assertType(char const* type_name, bool istype) const;
1380 void makeDirect(QPDFObjGen::set& visited, bool stop_at_streams); 1380 void makeDirect(QPDFObjGen::set& visited, bool stop_at_streams);
1381 void disconnect(); 1381 void disconnect();
1382 void setParsedOffset(qpdf_offset_t offset); 1382 void setParsedOffset(qpdf_offset_t offset);
@@ -1405,11 +1405,11 @@ class QPDFObjectHandle @@ -1405,11 +1405,11 @@ class QPDFObjectHandle
1405 // from being here. 1405 // from being here.
1406 1406
1407 /* clang-format off */ 1407 /* clang-format off */
1408 -// Disable formatting for this declaration: emacs font-lock in cc-mode (as of 28.1) treats the rest  
1409 -// of the file as a string if clang-format removes the space after "operator", and as of  
1410 -// clang-format 15, there's no way to prevent it from doing so.  
1411 -QPDF_DLL  
1412 -QPDFObjectHandle operator ""_qpdf(char const* v, size_t len); 1408 + // Disable formatting for this declaration: emacs font-lock in cc-mode (as of 28.1) treats the rest
  1409 + // of the file as a string if clang-format removes the space after "operator", and as of
  1410 + // clang-format 15, there's no way to prevent it from doing so.
  1411 + QPDF_DLL
  1412 + QPDFObjectHandle operator ""_qpdf(char const* v, size_t len);
1413 /* clang-format on */ 1413 /* clang-format on */
1414 1414
1415 #endif // QPDF_NO_QPDF_STRING 1415 #endif // QPDF_NO_QPDF_STRING
@@ -1629,7 +1629,7 @@ QPDFObjectHandle::isIndirect() const @@ -1629,7 +1629,7 @@ QPDFObjectHandle::isIndirect() const
1629 } 1629 }
1630 1630
1631 inline bool 1631 inline bool
1632 -QPDFObjectHandle::isInitialized() const 1632 +QPDFObjectHandle::isInitialized() const noexcept
1633 { 1633 {
1634 return obj != nullptr; 1634 return obj != nullptr;
1635 } 1635 }
libqpdf/QPDFObjectHandle.cc
@@ -220,12 +220,19 @@ LastChar::getLastChar() @@ -220,12 +220,19 @@ LastChar::getLastChar()
220 return this->last_char; 220 return this->last_char;
221 } 221 }
222 222
  223 +#ifndef QPDF_FUTURE
223 bool 224 bool
224 QPDFObjectHandle::isSameObjectAs(QPDFObjectHandle const& rhs) const 225 QPDFObjectHandle::isSameObjectAs(QPDFObjectHandle const& rhs) const
225 { 226 {
226 return this->obj == rhs.obj; 227 return this->obj == rhs.obj;
227 } 228 }
228 - 229 +#else
  230 +bool
  231 +QPDFObjectHandle::isSameObjectAs(QPDFObjectHandle const& rhs) const noexcept
  232 +{
  233 + return this->obj == rhs.obj;
  234 +}
  235 +#endif
229 void 236 void
230 QPDFObjectHandle::disconnect() 237 QPDFObjectHandle::disconnect()
231 { 238 {
@@ -237,14 +244,24 @@ QPDFObjectHandle::disconnect() @@ -237,14 +244,24 @@ QPDFObjectHandle::disconnect()
237 } 244 }
238 } 245 }
239 246
  247 +#ifndef QPDF_FUTURE
240 qpdf_object_type_e 248 qpdf_object_type_e
241 QPDFObjectHandle::getTypeCode() 249 QPDFObjectHandle::getTypeCode()
  250 +#else
  251 +qpdf_object_type_e
  252 +QPDFObjectHandle::getTypeCode() const
  253 +#endif
242 { 254 {
243 return obj ? obj->getResolvedTypeCode() : ::ot_uninitialized; 255 return obj ? obj->getResolvedTypeCode() : ::ot_uninitialized;
244 } 256 }
245 257
  258 +#ifndef QPDF_FUTURE
246 char const* 259 char const*
247 QPDFObjectHandle::getTypeName() 260 QPDFObjectHandle::getTypeName()
  261 +#else
  262 +char const*
  263 +QPDFObjectHandle::getTypeName() const
  264 +#endif
248 { 265 {
249 return obj ? obj->getTypeName() : "uninitialized"; 266 return obj ? obj->getTypeName() : "uninitialized";
250 } 267 }
@@ -316,7 +333,7 @@ QPDFObjectHandle::asStream() const @@ -316,7 +333,7 @@ QPDFObjectHandle::asStream() const
316 } 333 }
317 334
318 QPDF_Stream* 335 QPDF_Stream*
319 -QPDFObjectHandle::asStreamWithAssert() 336 +QPDFObjectHandle::asStreamWithAssert() const
320 { 337 {
321 auto stream = asStream(); 338 auto stream = asStream();
322 assertType("stream", stream); 339 assertType("stream", stream);
@@ -329,14 +346,24 @@ QPDFObjectHandle::asString() const @@ -329,14 +346,24 @@ QPDFObjectHandle::asString() const
329 return obj ? obj->as<QPDF_String>() : nullptr; 346 return obj ? obj->as<QPDF_String>() : nullptr;
330 } 347 }
331 348
  349 +#ifndef QPDF_FUTURE
332 bool 350 bool
333 QPDFObjectHandle::isDestroyed() 351 QPDFObjectHandle::isDestroyed()
  352 +#else
  353 +bool
  354 +QPDFObjectHandle::isDestroyed() const
  355 +#endif
334 { 356 {
335 return obj && obj->getResolvedTypeCode() == ::ot_destroyed; 357 return obj && obj->getResolvedTypeCode() == ::ot_destroyed;
336 } 358 }
337 359
  360 +#ifndef QPDF_FUTURE
338 bool 361 bool
339 QPDFObjectHandle::isBool() 362 QPDFObjectHandle::isBool()
  363 +#else
  364 +bool
  365 +QPDFObjectHandle::isBool() const
  366 +#endif
340 { 367 {
341 return obj && obj->getResolvedTypeCode() == ::ot_boolean; 368 return obj && obj->getResolvedTypeCode() == ::ot_boolean;
342 } 369 }
@@ -349,47 +376,76 @@ QPDFObjectHandle::isDirectNull() const @@ -349,47 +376,76 @@ QPDFObjectHandle::isDirectNull() const
349 return (obj && getObjectID() == 0 && obj->getTypeCode() == ::ot_null); 376 return (obj && getObjectID() == 0 && obj->getTypeCode() == ::ot_null);
350 } 377 }
351 378
  379 +#ifndef QPDF_FUTURE
352 bool 380 bool
353 QPDFObjectHandle::isNull() 381 QPDFObjectHandle::isNull()
  382 +#else
  383 +bool
  384 +QPDFObjectHandle::isNull() const
  385 +#endif
354 { 386 {
355 return obj && obj->getResolvedTypeCode() == ::ot_null; 387 return obj && obj->getResolvedTypeCode() == ::ot_null;
356 } 388 }
357 389
  390 +#ifndef QPDF_FUTURE
358 bool 391 bool
359 QPDFObjectHandle::isInteger() 392 QPDFObjectHandle::isInteger()
  393 +#else
  394 +bool
  395 +QPDFObjectHandle::isInteger() const
  396 +#endif
360 { 397 {
361 return obj && obj->getResolvedTypeCode() == ::ot_integer; 398 return obj && obj->getResolvedTypeCode() == ::ot_integer;
362 } 399 }
363 400
  401 +#ifndef QPDF_FUTURE
364 bool 402 bool
365 QPDFObjectHandle::isReal() 403 QPDFObjectHandle::isReal()
  404 +#else
  405 +bool
  406 +QPDFObjectHandle::isReal() const
  407 +#endif
366 { 408 {
367 return obj && obj->getResolvedTypeCode() == ::ot_real; 409 return obj && obj->getResolvedTypeCode() == ::ot_real;
368 } 410 }
369 411
  412 +#ifndef QPDF_FUTURE
370 bool 413 bool
371 QPDFObjectHandle::isNumber() 414 QPDFObjectHandle::isNumber()
  415 +#else
  416 +bool
  417 +QPDFObjectHandle::isNumber() const
  418 +#endif
372 { 419 {
373 return (isInteger() || isReal()); 420 return (isInteger() || isReal());
374 } 421 }
375 422
  423 +#ifndef QPDF_FUTURE
376 double 424 double
377 QPDFObjectHandle::getNumericValue() 425 QPDFObjectHandle::getNumericValue()
  426 +#else
  427 +double
  428 +QPDFObjectHandle::getNumericValue() const
  429 +#endif
378 { 430 {
379 - double result = 0.0;  
380 if (isInteger()) { 431 if (isInteger()) {
381 - result = static_cast<double>(getIntValue()); 432 + return static_cast<double>(getIntValue());
382 } else if (isReal()) { 433 } else if (isReal()) {
383 - result = atof(getRealValue().c_str()); 434 + return atof(getRealValue().c_str());
384 } else { 435 } else {
385 typeWarning("number", "returning 0"); 436 typeWarning("number", "returning 0");
386 QTC::TC("qpdf", "QPDFObjectHandle numeric non-numeric"); 437 QTC::TC("qpdf", "QPDFObjectHandle numeric non-numeric");
  438 + return 0;
387 } 439 }
388 - return result;  
389 } 440 }
390 441
  442 +#ifndef QPDF_FUTURE
391 bool 443 bool
392 QPDFObjectHandle::getValueAsNumber(double& value) 444 QPDFObjectHandle::getValueAsNumber(double& value)
  445 +#else
  446 +bool
  447 +QPDFObjectHandle::getValueAsNumber(double& value) const
  448 +#endif
393 { 449 {
394 if (!isNumber()) { 450 if (!isNumber()) {
395 return false; 451 return false;
@@ -398,83 +454,148 @@ QPDFObjectHandle::getValueAsNumber(double&amp; value) @@ -398,83 +454,148 @@ QPDFObjectHandle::getValueAsNumber(double&amp; value)
398 return true; 454 return true;
399 } 455 }
400 456
  457 +#ifndef QPDF_FUTURE
401 bool 458 bool
402 QPDFObjectHandle::isName() 459 QPDFObjectHandle::isName()
  460 +#else
  461 +bool
  462 +QPDFObjectHandle::isName() const
  463 +#endif
403 { 464 {
404 return obj && obj->getResolvedTypeCode() == ::ot_name; 465 return obj && obj->getResolvedTypeCode() == ::ot_name;
405 } 466 }
406 467
  468 +#ifndef QPDF_FUTURE
407 bool 469 bool
408 QPDFObjectHandle::isString() 470 QPDFObjectHandle::isString()
  471 +#else
  472 +bool
  473 +QPDFObjectHandle::isString() const
  474 +#endif
409 { 475 {
410 return obj && obj->getResolvedTypeCode() == ::ot_string; 476 return obj && obj->getResolvedTypeCode() == ::ot_string;
411 } 477 }
412 478
  479 +#ifndef QPDF_FUTURE
413 bool 480 bool
414 QPDFObjectHandle::isOperator() 481 QPDFObjectHandle::isOperator()
  482 +#else
  483 +bool
  484 +QPDFObjectHandle::isOperator() const
  485 +#endif
415 { 486 {
416 return obj && obj->getResolvedTypeCode() == ::ot_operator; 487 return obj && obj->getResolvedTypeCode() == ::ot_operator;
417 } 488 }
418 489
  490 +#ifndef QPDF_FUTURE
419 bool 491 bool
420 QPDFObjectHandle::isInlineImage() 492 QPDFObjectHandle::isInlineImage()
  493 +#else
  494 +bool
  495 +QPDFObjectHandle::isInlineImage() const
  496 +#endif
421 { 497 {
422 return obj && obj->getResolvedTypeCode() == ::ot_inlineimage; 498 return obj && obj->getResolvedTypeCode() == ::ot_inlineimage;
423 } 499 }
424 500
  501 +#ifndef QPDF_FUTURE
425 bool 502 bool
426 QPDFObjectHandle::isArray() 503 QPDFObjectHandle::isArray()
  504 +#else
  505 +bool
  506 +QPDFObjectHandle::isArray() const
  507 +#endif
427 { 508 {
428 return obj && obj->getResolvedTypeCode() == ::ot_array; 509 return obj && obj->getResolvedTypeCode() == ::ot_array;
429 } 510 }
430 511
  512 +#ifndef QPDF_FUTURE
431 bool 513 bool
432 QPDFObjectHandle::isDictionary() 514 QPDFObjectHandle::isDictionary()
  515 +#else
  516 +bool
  517 +QPDFObjectHandle::isDictionary() const
  518 +#endif
433 { 519 {
434 return obj && obj->getResolvedTypeCode() == ::ot_dictionary; 520 return obj && obj->getResolvedTypeCode() == ::ot_dictionary;
435 } 521 }
436 522
  523 +#ifndef QPDF_FUTURE
437 bool 524 bool
438 QPDFObjectHandle::isStream() 525 QPDFObjectHandle::isStream()
  526 +#else
  527 +bool
  528 +QPDFObjectHandle::isStream() const
  529 +#endif
439 { 530 {
440 return obj && obj->getResolvedTypeCode() == ::ot_stream; 531 return obj && obj->getResolvedTypeCode() == ::ot_stream;
441 } 532 }
442 533
  534 +#ifndef QPDF_FUTURE
443 bool 535 bool
444 QPDFObjectHandle::isReserved() 536 QPDFObjectHandle::isReserved()
  537 +#else
  538 +bool
  539 +QPDFObjectHandle::isReserved() const
  540 +#endif
445 { 541 {
446 return obj && obj->getResolvedTypeCode() == ::ot_reserved; 542 return obj && obj->getResolvedTypeCode() == ::ot_reserved;
447 } 543 }
448 544
  545 +#ifndef QPDF_FUTURE
449 bool 546 bool
450 QPDFObjectHandle::isScalar() 547 QPDFObjectHandle::isScalar()
  548 +#else
  549 +bool
  550 +QPDFObjectHandle::isScalar() const
  551 +#endif
451 { 552 {
452 return isBool() || isInteger() || isName() || isNull() || isReal() || isString(); 553 return isBool() || isInteger() || isName() || isNull() || isReal() || isString();
453 } 554 }
454 555
  556 +#ifndef QPDF_FUTURE
455 bool 557 bool
456 QPDFObjectHandle::isNameAndEquals(std::string const& name) 558 QPDFObjectHandle::isNameAndEquals(std::string const& name)
  559 +#else
  560 +bool
  561 +QPDFObjectHandle::isNameAndEquals(std::string const& name) const
  562 +#endif
457 { 563 {
458 return isName() && (getName() == name); 564 return isName() && (getName() == name);
459 } 565 }
460 566
  567 +#ifndef QPDF_FUTURE
461 bool 568 bool
462 QPDFObjectHandle::isDictionaryOfType(std::string const& type, std::string const& subtype) 569 QPDFObjectHandle::isDictionaryOfType(std::string const& type, std::string const& subtype)
  570 +#else
  571 +bool
  572 +QPDFObjectHandle::isDictionaryOfType(std::string const& type, std::string const& subtype) const
  573 +#endif
463 { 574 {
464 return isDictionary() && (type.empty() || getKey("/Type").isNameAndEquals(type)) && 575 return isDictionary() && (type.empty() || getKey("/Type").isNameAndEquals(type)) &&
465 (subtype.empty() || getKey("/Subtype").isNameAndEquals(subtype)); 576 (subtype.empty() || getKey("/Subtype").isNameAndEquals(subtype));
466 } 577 }
467 578
  579 +#ifndef QPDF_FUTURE
468 bool 580 bool
469 QPDFObjectHandle::isStreamOfType(std::string const& type, std::string const& subtype) 581 QPDFObjectHandle::isStreamOfType(std::string const& type, std::string const& subtype)
  582 +#else
  583 +bool
  584 +QPDFObjectHandle::isStreamOfType(std::string const& type, std::string const& subtype) const
  585 +#endif
470 { 586 {
471 return isStream() && getDict().isDictionaryOfType(type, subtype); 587 return isStream() && getDict().isDictionaryOfType(type, subtype);
472 } 588 }
473 589
474 // Bool accessors 590 // Bool accessors
475 591
  592 +#ifndef QPDF_FUTURE
476 bool 593 bool
477 QPDFObjectHandle::getBoolValue() 594 QPDFObjectHandle::getBoolValue()
  595 +#else
  596 +bool
  597 +QPDFObjectHandle::getBoolValue() const
  598 +#endif
478 { 599 {
479 auto boolean = asBool(); 600 auto boolean = asBool();
480 if (boolean) { 601 if (boolean) {
@@ -486,8 +607,13 @@ QPDFObjectHandle::getBoolValue() @@ -486,8 +607,13 @@ QPDFObjectHandle::getBoolValue()
486 } 607 }
487 } 608 }
488 609
  610 +#ifndef QPDF_FUTURE
489 bool 611 bool
490 QPDFObjectHandle::getValueAsBool(bool& value) 612 QPDFObjectHandle::getValueAsBool(bool& value)
  613 +#else
  614 +bool
  615 +QPDFObjectHandle::getValueAsBool(bool& value) const
  616 +#endif
491 { 617 {
492 auto boolean = asBool(); 618 auto boolean = asBool();
493 if (boolean == nullptr) { 619 if (boolean == nullptr) {
@@ -499,8 +625,13 @@ QPDFObjectHandle::getValueAsBool(bool&amp; value) @@ -499,8 +625,13 @@ QPDFObjectHandle::getValueAsBool(bool&amp; value)
499 625
500 // Integer accessors 626 // Integer accessors
501 627
  628 +#ifndef QPDF_FUTURE
502 long long 629 long long
503 QPDFObjectHandle::getIntValue() 630 QPDFObjectHandle::getIntValue()
  631 +#else
  632 +long long
  633 +QPDFObjectHandle::getIntValue() const
  634 +#endif
504 { 635 {
505 auto integer = asInteger(); 636 auto integer = asInteger();
506 if (integer) { 637 if (integer) {
@@ -512,8 +643,13 @@ QPDFObjectHandle::getIntValue() @@ -512,8 +643,13 @@ QPDFObjectHandle::getIntValue()
512 } 643 }
513 } 644 }
514 645
  646 +#ifndef QPDF_FUTURE
515 bool 647 bool
516 QPDFObjectHandle::getValueAsInt(long long& value) 648 QPDFObjectHandle::getValueAsInt(long long& value)
  649 +#else
  650 +bool
  651 +QPDFObjectHandle::getValueAsInt(long long& value) const
  652 +#endif
517 { 653 {
518 auto integer = asInteger(); 654 auto integer = asInteger();
519 if (integer == nullptr) { 655 if (integer == nullptr) {
@@ -523,8 +659,13 @@ QPDFObjectHandle::getValueAsInt(long long&amp; value) @@ -523,8 +659,13 @@ QPDFObjectHandle::getValueAsInt(long long&amp; value)
523 return true; 659 return true;
524 } 660 }
525 661
  662 +#ifndef QPDF_FUTURE
526 int 663 int
527 QPDFObjectHandle::getIntValueAsInt() 664 QPDFObjectHandle::getIntValueAsInt()
  665 +#else
  666 +int
  667 +QPDFObjectHandle::getIntValueAsInt() const
  668 +#endif
528 { 669 {
529 int result = 0; 670 int result = 0;
530 long long v = getIntValue(); 671 long long v = getIntValue();
@@ -542,8 +683,13 @@ QPDFObjectHandle::getIntValueAsInt() @@ -542,8 +683,13 @@ QPDFObjectHandle::getIntValueAsInt()
542 return result; 683 return result;
543 } 684 }
544 685
  686 +#ifndef QPDF_FUTURE
545 bool 687 bool
546 QPDFObjectHandle::getValueAsInt(int& value) 688 QPDFObjectHandle::getValueAsInt(int& value)
  689 +#else
  690 +bool
  691 +QPDFObjectHandle::getValueAsInt(int& value) const
  692 +#endif
547 { 693 {
548 if (!isInteger()) { 694 if (!isInteger()) {
549 return false; 695 return false;
@@ -552,22 +698,31 @@ QPDFObjectHandle::getValueAsInt(int&amp; value) @@ -552,22 +698,31 @@ QPDFObjectHandle::getValueAsInt(int&amp; value)
552 return true; 698 return true;
553 } 699 }
554 700
  701 +#ifndef QPDF_FUTURE
555 unsigned long long 702 unsigned long long
556 QPDFObjectHandle::getUIntValue() 703 QPDFObjectHandle::getUIntValue()
  704 +#else
  705 +unsigned long long
  706 +QPDFObjectHandle::getUIntValue() const
  707 +#endif
557 { 708 {
558 - unsigned long long result = 0;  
559 long long v = getIntValue(); 709 long long v = getIntValue();
560 if (v < 0) { 710 if (v < 0) {
561 QTC::TC("qpdf", "QPDFObjectHandle uint returning 0"); 711 QTC::TC("qpdf", "QPDFObjectHandle uint returning 0");
562 warnIfPossible("unsigned value request for negative number; returning 0"); 712 warnIfPossible("unsigned value request for negative number; returning 0");
  713 + return 0;
563 } else { 714 } else {
564 - result = static_cast<unsigned long long>(v); 715 + return static_cast<unsigned long long>(v);
565 } 716 }
566 - return result;  
567 } 717 }
568 718
  719 +#ifndef QPDF_FUTURE
569 bool 720 bool
570 QPDFObjectHandle::getValueAsUInt(unsigned long long& value) 721 QPDFObjectHandle::getValueAsUInt(unsigned long long& value)
  722 +#else
  723 +bool
  724 +QPDFObjectHandle::getValueAsUInt(unsigned long long& value) const
  725 +#endif
571 { 726 {
572 if (!isInteger()) { 727 if (!isInteger()) {
573 return false; 728 return false;
@@ -576,27 +731,35 @@ QPDFObjectHandle::getValueAsUInt(unsigned long long&amp; value) @@ -576,27 +731,35 @@ QPDFObjectHandle::getValueAsUInt(unsigned long long&amp; value)
576 return true; 731 return true;
577 } 732 }
578 733
  734 +#ifndef QPDF_FUTURE
579 unsigned int 735 unsigned int
580 QPDFObjectHandle::getUIntValueAsUInt() 736 QPDFObjectHandle::getUIntValueAsUInt()
  737 +#else
  738 +unsigned int
  739 +QPDFObjectHandle::getUIntValueAsUInt() const
  740 +#endif
581 { 741 {
582 - unsigned int result = 0;  
583 long long v = getIntValue(); 742 long long v = getIntValue();
584 if (v < 0) { 743 if (v < 0) {
585 QTC::TC("qpdf", "QPDFObjectHandle uint uint returning 0"); 744 QTC::TC("qpdf", "QPDFObjectHandle uint uint returning 0");
586 warnIfPossible("unsigned integer value request for negative number; returning 0"); 745 warnIfPossible("unsigned integer value request for negative number; returning 0");
587 - result = 0; 746 + return 0;
588 } else if (v > UINT_MAX) { 747 } else if (v > UINT_MAX) {
589 QTC::TC("qpdf", "QPDFObjectHandle uint returning UINT_MAX"); 748 QTC::TC("qpdf", "QPDFObjectHandle uint returning UINT_MAX");
590 warnIfPossible("requested value of unsigned integer is too big; returning UINT_MAX"); 749 warnIfPossible("requested value of unsigned integer is too big; returning UINT_MAX");
591 - result = UINT_MAX; 750 + return UINT_MAX;
592 } else { 751 } else {
593 - result = static_cast<unsigned int>(v); 752 + return static_cast<unsigned int>(v);
594 } 753 }
595 - return result;  
596 } 754 }
597 755
  756 +#ifndef QPDF_FUTURE
598 bool 757 bool
599 QPDFObjectHandle::getValueAsUInt(unsigned int& value) 758 QPDFObjectHandle::getValueAsUInt(unsigned int& value)
  759 +#else
  760 +bool
  761 +QPDFObjectHandle::getValueAsUInt(unsigned int& value) const
  762 +#endif
600 { 763 {
601 if (!isInteger()) { 764 if (!isInteger()) {
602 return false; 765 return false;
@@ -607,8 +770,13 @@ QPDFObjectHandle::getValueAsUInt(unsigned int&amp; value) @@ -607,8 +770,13 @@ QPDFObjectHandle::getValueAsUInt(unsigned int&amp; value)
607 770
608 // Real accessors 771 // Real accessors
609 772
  773 +#ifndef QPDF_FUTURE
610 std::string 774 std::string
611 QPDFObjectHandle::getRealValue() 775 QPDFObjectHandle::getRealValue()
  776 +#else
  777 +std::string
  778 +QPDFObjectHandle::getRealValue() const
  779 +#endif
612 { 780 {
613 if (isReal()) { 781 if (isReal()) {
614 return obj->getStringValue(); 782 return obj->getStringValue();
@@ -619,8 +787,13 @@ QPDFObjectHandle::getRealValue() @@ -619,8 +787,13 @@ QPDFObjectHandle::getRealValue()
619 } 787 }
620 } 788 }
621 789
  790 +#ifndef QPDF_FUTURE
622 bool 791 bool
623 QPDFObjectHandle::getValueAsReal(std::string& value) 792 QPDFObjectHandle::getValueAsReal(std::string& value)
  793 +#else
  794 +bool
  795 +QPDFObjectHandle::getValueAsReal(std::string& value) const
  796 +#endif
624 { 797 {
625 if (!isReal()) { 798 if (!isReal()) {
626 return false; 799 return false;
@@ -631,8 +804,13 @@ QPDFObjectHandle::getValueAsReal(std::string&amp; value) @@ -631,8 +804,13 @@ QPDFObjectHandle::getValueAsReal(std::string&amp; value)
631 804
632 // Name accessors 805 // Name accessors
633 806
  807 +#ifndef QPDF_FUTURE
634 std::string 808 std::string
635 QPDFObjectHandle::getName() 809 QPDFObjectHandle::getName()
  810 +#else
  811 +std::string
  812 +QPDFObjectHandle::getName() const
  813 +#endif
636 { 814 {
637 if (isName()) { 815 if (isName()) {
638 return obj->getStringValue(); 816 return obj->getStringValue();
@@ -643,8 +821,13 @@ QPDFObjectHandle::getName() @@ -643,8 +821,13 @@ QPDFObjectHandle::getName()
643 } 821 }
644 } 822 }
645 823
  824 +#ifndef QPDF_FUTURE
646 bool 825 bool
647 QPDFObjectHandle::getValueAsName(std::string& value) 826 QPDFObjectHandle::getValueAsName(std::string& value)
  827 +#else
  828 +bool
  829 +QPDFObjectHandle::getValueAsName(std::string& value) const
  830 +#endif
648 { 831 {
649 if (!isName()) { 832 if (!isName()) {
650 return false; 833 return false;
@@ -655,8 +838,13 @@ QPDFObjectHandle::getValueAsName(std::string&amp; value) @@ -655,8 +838,13 @@ QPDFObjectHandle::getValueAsName(std::string&amp; value)
655 838
656 // String accessors 839 // String accessors
657 840
  841 +#ifndef QPDF_FUTURE
658 std::string 842 std::string
659 QPDFObjectHandle::getStringValue() 843 QPDFObjectHandle::getStringValue()
  844 +#else
  845 +std::string
  846 +QPDFObjectHandle::getStringValue() const
  847 +#endif
660 { 848 {
661 if (isString()) { 849 if (isString()) {
662 return obj->getStringValue(); 850 return obj->getStringValue();
@@ -667,8 +855,13 @@ QPDFObjectHandle::getStringValue() @@ -667,8 +855,13 @@ QPDFObjectHandle::getStringValue()
667 } 855 }
668 } 856 }
669 857
  858 +#ifndef QPDF_FUTURE
670 bool 859 bool
671 QPDFObjectHandle::getValueAsString(std::string& value) 860 QPDFObjectHandle::getValueAsString(std::string& value)
  861 +#else
  862 +bool
  863 +QPDFObjectHandle::getValueAsString(std::string& value) const
  864 +#endif
672 { 865 {
673 if (!isString()) { 866 if (!isString()) {
674 return false; 867 return false;
@@ -677,8 +870,13 @@ QPDFObjectHandle::getValueAsString(std::string&amp; value) @@ -677,8 +870,13 @@ QPDFObjectHandle::getValueAsString(std::string&amp; value)
677 return true; 870 return true;
678 } 871 }
679 872
  873 +#ifndef QPDF_FUTURE
680 std::string 874 std::string
681 QPDFObjectHandle::getUTF8Value() 875 QPDFObjectHandle::getUTF8Value()
  876 +#else
  877 +std::string
  878 +QPDFObjectHandle::getUTF8Value() const
  879 +#endif
682 { 880 {
683 auto str = asString(); 881 auto str = asString();
684 if (str) { 882 if (str) {
@@ -690,8 +888,13 @@ QPDFObjectHandle::getUTF8Value() @@ -690,8 +888,13 @@ QPDFObjectHandle::getUTF8Value()
690 } 888 }
691 } 889 }
692 890
  891 +#ifndef QPDF_FUTURE
693 bool 892 bool
694 QPDFObjectHandle::getValueAsUTF8(std::string& value) 893 QPDFObjectHandle::getValueAsUTF8(std::string& value)
  894 +#else
  895 +bool
  896 +QPDFObjectHandle::getValueAsUTF8(std::string& value) const
  897 +#endif
695 { 898 {
696 auto str = asString(); 899 auto str = asString();
697 if (str == nullptr) { 900 if (str == nullptr) {
@@ -703,8 +906,13 @@ QPDFObjectHandle::getValueAsUTF8(std::string&amp; value) @@ -703,8 +906,13 @@ QPDFObjectHandle::getValueAsUTF8(std::string&amp; value)
703 906
704 // Operator and Inline Image accessors 907 // Operator and Inline Image accessors
705 908
  909 +#ifndef QPDF_FUTURE
706 std::string 910 std::string
707 QPDFObjectHandle::getOperatorValue() 911 QPDFObjectHandle::getOperatorValue()
  912 +#else
  913 +std::string
  914 +QPDFObjectHandle::getOperatorValue() const
  915 +#endif
708 { 916 {
709 if (isOperator()) { 917 if (isOperator()) {
710 return obj->getStringValue(); 918 return obj->getStringValue();
@@ -715,8 +923,13 @@ QPDFObjectHandle::getOperatorValue() @@ -715,8 +923,13 @@ QPDFObjectHandle::getOperatorValue()
715 } 923 }
716 } 924 }
717 925
  926 +#ifndef QPDF_FUTURE
718 bool 927 bool
719 QPDFObjectHandle::getValueAsOperator(std::string& value) 928 QPDFObjectHandle::getValueAsOperator(std::string& value)
  929 +#else
  930 +bool
  931 +QPDFObjectHandle::getValueAsOperator(std::string& value) const
  932 +#endif
720 { 933 {
721 if (!isOperator()) { 934 if (!isOperator()) {
722 return false; 935 return false;
@@ -725,8 +938,13 @@ QPDFObjectHandle::getValueAsOperator(std::string&amp; value) @@ -725,8 +938,13 @@ QPDFObjectHandle::getValueAsOperator(std::string&amp; value)
725 return true; 938 return true;
726 } 939 }
727 940
  941 +#ifndef QPDF_FUTURE
728 std::string 942 std::string
729 QPDFObjectHandle::getInlineImageValue() 943 QPDFObjectHandle::getInlineImageValue()
  944 +#else
  945 +std::string
  946 +QPDFObjectHandle::getInlineImageValue() const
  947 +#endif
730 { 948 {
731 if (isInlineImage()) { 949 if (isInlineImage()) {
732 return obj->getStringValue(); 950 return obj->getStringValue();
@@ -737,8 +955,13 @@ QPDFObjectHandle::getInlineImageValue() @@ -737,8 +955,13 @@ QPDFObjectHandle::getInlineImageValue()
737 } 955 }
738 } 956 }
739 957
  958 +#ifndef QPDF_FUTURE
740 bool 959 bool
741 QPDFObjectHandle::getValueAsInlineImage(std::string& value) 960 QPDFObjectHandle::getValueAsInlineImage(std::string& value)
  961 +#else
  962 +bool
  963 +QPDFObjectHandle::getValueAsInlineImage(std::string& value) const
  964 +#endif
742 { 965 {
743 if (!isInlineImage()) { 966 if (!isInlineImage()) {
744 return false; 967 return false;
@@ -755,8 +978,13 @@ QPDFObjectHandle::aitems() @@ -755,8 +978,13 @@ QPDFObjectHandle::aitems()
755 return *this; 978 return *this;
756 } 979 }
757 980
  981 +#ifndef QPDF_FUTURE
758 int 982 int
759 QPDFObjectHandle::getArrayNItems() 983 QPDFObjectHandle::getArrayNItems()
  984 +#else
  985 +int
  986 +QPDFObjectHandle::getArrayNItems() const
  987 +#endif
760 { 988 {
761 if (auto array = asArray()) { 989 if (auto array = asArray()) {
762 return array->size(); 990 return array->size();
@@ -767,8 +995,13 @@ QPDFObjectHandle::getArrayNItems() @@ -767,8 +995,13 @@ QPDFObjectHandle::getArrayNItems()
767 } 995 }
768 } 996 }
769 997
  998 +#ifndef QPDF_FUTURE
770 QPDFObjectHandle 999 QPDFObjectHandle
771 QPDFObjectHandle::getArrayItem(int n) 1000 QPDFObjectHandle::getArrayItem(int n)
  1001 +#else
  1002 +QPDFObjectHandle
  1003 +QPDFObjectHandle::getArrayItem(int n) const
  1004 +#endif
772 { 1005 {
773 if (auto array = asArray()) { 1006 if (auto array = asArray()) {
774 if (auto result = array->at(n); result.obj != nullptr) { 1007 if (auto result = array->at(n); result.obj != nullptr) {
@@ -785,8 +1018,13 @@ QPDFObjectHandle::getArrayItem(int n) @@ -785,8 +1018,13 @@ QPDFObjectHandle::getArrayItem(int n)
785 return QPDF_Null::create(obj, msg, ""); 1018 return QPDF_Null::create(obj, msg, "");
786 } 1019 }
787 1020
  1021 +#ifndef QPDF_FUTURE
788 bool 1022 bool
789 QPDFObjectHandle::isRectangle() 1023 QPDFObjectHandle::isRectangle()
  1024 +#else
  1025 +bool
  1026 +QPDFObjectHandle::isRectangle() const
  1027 +#endif
790 { 1028 {
791 if (auto array = asArray()) { 1029 if (auto array = asArray()) {
792 for (int i = 0; i < 4; ++i) { 1030 for (int i = 0; i < 4; ++i) {
@@ -799,8 +1037,13 @@ QPDFObjectHandle::isRectangle() @@ -799,8 +1037,13 @@ QPDFObjectHandle::isRectangle()
799 return false; 1037 return false;
800 } 1038 }
801 1039
  1040 +#ifndef QPDF_FUTURE
802 bool 1041 bool
803 QPDFObjectHandle::isMatrix() 1042 QPDFObjectHandle::isMatrix()
  1043 +#else
  1044 +bool
  1045 +QPDFObjectHandle::isMatrix() const
  1046 +#endif
804 { 1047 {
805 if (auto array = asArray()) { 1048 if (auto array = asArray()) {
806 for (int i = 0; i < 6; ++i) { 1049 for (int i = 0; i < 6; ++i) {
@@ -813,8 +1056,13 @@ QPDFObjectHandle::isMatrix() @@ -813,8 +1056,13 @@ QPDFObjectHandle::isMatrix()
813 return false; 1056 return false;
814 } 1057 }
815 1058
  1059 +#ifndef QPDF_FUTURE
816 QPDFObjectHandle::Rectangle 1060 QPDFObjectHandle::Rectangle
817 QPDFObjectHandle::getArrayAsRectangle() 1061 QPDFObjectHandle::getArrayAsRectangle()
  1062 +#else
  1063 +QPDFObjectHandle::Rectangle
  1064 +QPDFObjectHandle::getArrayAsRectangle() const
  1065 +#endif
818 { 1066 {
819 if (auto array = asArray()) { 1067 if (auto array = asArray()) {
820 if (array->size() != 4) { 1068 if (array->size() != 4) {
@@ -835,8 +1083,13 @@ QPDFObjectHandle::getArrayAsRectangle() @@ -835,8 +1083,13 @@ QPDFObjectHandle::getArrayAsRectangle()
835 return {}; 1083 return {};
836 } 1084 }
837 1085
  1086 +#ifndef QPDF_FUTURE
838 QPDFObjectHandle::Matrix 1087 QPDFObjectHandle::Matrix
839 QPDFObjectHandle::getArrayAsMatrix() 1088 QPDFObjectHandle::getArrayAsMatrix()
  1089 +#else
  1090 +QPDFObjectHandle::Matrix
  1091 +QPDFObjectHandle::getArrayAsMatrix() const
  1092 +#endif
840 { 1093 {
841 if (auto array = asArray()) { 1094 if (auto array = asArray()) {
842 if (array->size() != 6) { 1095 if (array->size() != 6) {
@@ -853,8 +1106,13 @@ QPDFObjectHandle::getArrayAsMatrix() @@ -853,8 +1106,13 @@ QPDFObjectHandle::getArrayAsMatrix()
853 return {}; 1106 return {};
854 } 1107 }
855 1108
  1109 +#ifndef QPDF_FUTURE
856 std::vector<QPDFObjectHandle> 1110 std::vector<QPDFObjectHandle>
857 QPDFObjectHandle::getArrayAsVector() 1111 QPDFObjectHandle::getArrayAsVector()
  1112 +#else
  1113 +std::vector<QPDFObjectHandle>
  1114 +QPDFObjectHandle::getArrayAsVector() const
  1115 +#endif
858 { 1116 {
859 auto array = asArray(); 1117 auto array = asArray();
860 if (array) { 1118 if (array) {
@@ -962,8 +1220,13 @@ QPDFObjectHandle::ditems() @@ -962,8 +1220,13 @@ QPDFObjectHandle::ditems()
962 return {*this}; 1220 return {*this};
963 } 1221 }
964 1222
  1223 +#ifndef QPDF_FUTURE
965 bool 1224 bool
966 QPDFObjectHandle::hasKey(std::string const& key) 1225 QPDFObjectHandle::hasKey(std::string const& key)
  1226 +#else
  1227 +bool
  1228 +QPDFObjectHandle::hasKey(std::string const& key) const
  1229 +#endif
967 { 1230 {
968 auto dict = asDictionary(); 1231 auto dict = asDictionary();
969 if (dict) { 1232 if (dict) {
@@ -975,8 +1238,13 @@ QPDFObjectHandle::hasKey(std::string const&amp; key) @@ -975,8 +1238,13 @@ QPDFObjectHandle::hasKey(std::string const&amp; key)
975 } 1238 }
976 } 1239 }
977 1240
  1241 +#ifndef QPDF_FUTURE
978 QPDFObjectHandle 1242 QPDFObjectHandle
979 QPDFObjectHandle::getKey(std::string const& key) 1243 QPDFObjectHandle::getKey(std::string const& key)
  1244 +#else
  1245 +QPDFObjectHandle
  1246 +QPDFObjectHandle::getKey(std::string const& key) const
  1247 +#endif
980 { 1248 {
981 if (auto dict = asDictionary()) { 1249 if (auto dict = asDictionary()) {
982 return dict->getKey(key); 1250 return dict->getKey(key);
@@ -988,14 +1256,24 @@ QPDFObjectHandle::getKey(std::string const&amp; key) @@ -988,14 +1256,24 @@ QPDFObjectHandle::getKey(std::string const&amp; key)
988 } 1256 }
989 } 1257 }
990 1258
  1259 +#ifndef QPDF_FUTURE
991 QPDFObjectHandle 1260 QPDFObjectHandle
992 QPDFObjectHandle::getKeyIfDict(std::string const& key) 1261 QPDFObjectHandle::getKeyIfDict(std::string const& key)
  1262 +#else
  1263 +QPDFObjectHandle
  1264 +QPDFObjectHandle::getKeyIfDict(std::string const& key) const
  1265 +#endif
993 { 1266 {
994 return isNull() ? newNull() : getKey(key); 1267 return isNull() ? newNull() : getKey(key);
995 } 1268 }
996 1269
  1270 +#ifndef QPDF_FUTURE
997 std::set<std::string> 1271 std::set<std::string>
998 QPDFObjectHandle::getKeys() 1272 QPDFObjectHandle::getKeys()
  1273 +#else
  1274 +std::set<std::string>
  1275 +QPDFObjectHandle::getKeys() const
  1276 +#endif
999 { 1277 {
1000 std::set<std::string> result; 1278 std::set<std::string> result;
1001 auto dict = asDictionary(); 1279 auto dict = asDictionary();
@@ -1008,8 +1286,13 @@ QPDFObjectHandle::getKeys() @@ -1008,8 +1286,13 @@ QPDFObjectHandle::getKeys()
1008 return result; 1286 return result;
1009 } 1287 }
1010 1288
  1289 +#ifndef QPDF_FUTURE
1011 std::map<std::string, QPDFObjectHandle> 1290 std::map<std::string, QPDFObjectHandle>
1012 QPDFObjectHandle::getDictAsMap() 1291 QPDFObjectHandle::getDictAsMap()
  1292 +#else
  1293 +std::map<std::string, QPDFObjectHandle>
  1294 +QPDFObjectHandle::getDictAsMap() const
  1295 +#endif
1013 { 1296 {
1014 std::map<std::string, QPDFObjectHandle> result; 1297 std::map<std::string, QPDFObjectHandle> result;
1015 auto dict = asDictionary(); 1298 auto dict = asDictionary();
@@ -1023,13 +1306,18 @@ QPDFObjectHandle::getDictAsMap() @@ -1023,13 +1306,18 @@ QPDFObjectHandle::getDictAsMap()
1023 } 1306 }
1024 1307
1025 // Array and Name accessors 1308 // Array and Name accessors
  1309 +#ifndef QPDF_FUTURE
1026 bool 1310 bool
1027 QPDFObjectHandle::isOrHasName(std::string const& value) 1311 QPDFObjectHandle::isOrHasName(std::string const& value)
  1312 +#else
  1313 +bool
  1314 +QPDFObjectHandle::isOrHasName(std::string const& value) const
  1315 +#endif
1028 { 1316 {
1029 if (isNameAndEquals(value)) { 1317 if (isNameAndEquals(value)) {
1030 return true; 1318 return true;
1031 } else if (isArray()) { 1319 } else if (isArray()) {
1032 - for (auto& item: aitems()) { 1320 + for (auto& item: getArrayAsVector()) {
1033 if (item.isNameAndEquals(value)) { 1321 if (item.isNameAndEquals(value)) {
1034 return true; 1322 return true;
1035 } 1323 }
@@ -1152,8 +1440,13 @@ QPDFObjectHandle::mergeResources( @@ -1152,8 +1440,13 @@ QPDFObjectHandle::mergeResources(
1152 } 1440 }
1153 } 1441 }
1154 1442
  1443 +#ifndef QPDF_FUTURE
1155 std::set<std::string> 1444 std::set<std::string>
1156 QPDFObjectHandle::getResourceNames() 1445 QPDFObjectHandle::getResourceNames()
  1446 +#else
  1447 +std::set<std::string>
  1448 +QPDFObjectHandle::getResourceNames() const
  1449 +#endif
1157 { 1450 {
1158 // Return second-level dictionary keys 1451 // Return second-level dictionary keys
1159 std::set<std::string> result; 1452 std::set<std::string> result;
@@ -1171,9 +1464,15 @@ QPDFObjectHandle::getResourceNames() @@ -1171,9 +1464,15 @@ QPDFObjectHandle::getResourceNames()
1171 return result; 1464 return result;
1172 } 1465 }
1173 1466
  1467 +#ifndef QPDF_FUTURE
1174 std::string 1468 std::string
1175 QPDFObjectHandle::getUniqueResourceName( 1469 QPDFObjectHandle::getUniqueResourceName(
1176 std::string const& prefix, int& min_suffix, std::set<std::string>* namesp) 1470 std::string const& prefix, int& min_suffix, std::set<std::string>* namesp)
  1471 +#else
  1472 +std::string
  1473 +QPDFObjectHandle::getUniqueResourceName(
  1474 + std::string const& prefix, int& min_suffix, std::set<std::string>* namesp) const
  1475 +#endif
1177 1476
1178 { 1477 {
1179 std::set<std::string> names = (namesp ? *namesp : getResourceNames()); 1478 std::set<std::string> names = (namesp ? *namesp : getResourceNames());
@@ -1255,8 +1554,13 @@ QPDFObjectHandle::replaceOrRemoveKey(std::string const&amp; key, QPDFObjectHandle co @@ -1255,8 +1554,13 @@ QPDFObjectHandle::replaceOrRemoveKey(std::string const&amp; key, QPDFObjectHandle co
1255 } 1554 }
1256 1555
1257 // Stream accessors 1556 // Stream accessors
  1557 +#ifndef QPDF_FUTURE
1258 QPDFObjectHandle 1558 QPDFObjectHandle
1259 QPDFObjectHandle::getDict() 1559 QPDFObjectHandle::getDict()
  1560 +#else
  1561 +QPDFObjectHandle
  1562 +QPDFObjectHandle::getDict() const
  1563 +#endif
1260 { 1564 {
1261 return asStreamWithAssert()->getDict(); 1565 return asStreamWithAssert()->getDict();
1262 } 1566 }
@@ -1571,20 +1875,28 @@ QPDFObjectHandle::coalesceContentStreams() @@ -1571,20 +1875,28 @@ QPDFObjectHandle::coalesceContentStreams()
1571 new_contents.replaceStreamData(provider, newNull(), newNull()); 1875 new_contents.replaceStreamData(provider, newNull(), newNull());
1572 } 1876 }
1573 1877
  1878 +#ifndef QPDF_FUTURE
1574 std::string 1879 std::string
1575 QPDFObjectHandle::unparse() 1880 QPDFObjectHandle::unparse()
  1881 +#else
  1882 +std::string
  1883 +QPDFObjectHandle::unparse() const
  1884 +#endif
1576 { 1885 {
1577 - std::string result;  
1578 if (this->isIndirect()) { 1886 if (this->isIndirect()) {
1579 - result = getObjGen().unparse(' ') + " R"; 1887 + return getObjGen().unparse(' ') + " R";
1580 } else { 1888 } else {
1581 - result = unparseResolved(); 1889 + return unparseResolved();
1582 } 1890 }
1583 - return result;  
1584 } 1891 }
1585 1892
  1893 +#ifndef QPDF_FUTURE
1586 std::string 1894 std::string
1587 QPDFObjectHandle::unparseResolved() 1895 QPDFObjectHandle::unparseResolved()
  1896 +#else
  1897 +std::string
  1898 +QPDFObjectHandle::unparseResolved() const
  1899 +#endif
1588 { 1900 {
1589 if (!obj) { 1901 if (!obj) {
1590 throw std::logic_error("attempted to dereference an uninitialized QPDFObjectHandle"); 1902 throw std::logic_error("attempted to dereference an uninitialized QPDFObjectHandle");
@@ -1592,11 +1904,15 @@ QPDFObjectHandle::unparseResolved() @@ -1592,11 +1904,15 @@ QPDFObjectHandle::unparseResolved()
1592 return obj->unparse(); 1904 return obj->unparse();
1593 } 1905 }
1594 1906
  1907 +#ifndef QPDF_FUTURE
1595 std::string 1908 std::string
1596 QPDFObjectHandle::unparseBinary() 1909 QPDFObjectHandle::unparseBinary()
  1910 +#else
  1911 +std::string
  1912 +QPDFObjectHandle::unparseBinary() const
  1913 +#endif
1597 { 1914 {
1598 - auto str = asString();  
1599 - if (str) { 1915 + if (auto str = asString()) {
1600 return str->unparse(true); 1916 return str->unparse(true);
1601 } else { 1917 } else {
1602 return unparse(); 1918 return unparse();
@@ -1604,14 +1920,24 @@ QPDFObjectHandle::unparseBinary() @@ -1604,14 +1920,24 @@ QPDFObjectHandle::unparseBinary()
1604 } 1920 }
1605 1921
1606 // Deprecated versionless getJSON to be removed in qpdf 12 1922 // Deprecated versionless getJSON to be removed in qpdf 12
  1923 +#ifndef QPDF_FUTURE
1607 JSON 1924 JSON
1608 QPDFObjectHandle::getJSON(bool dereference_indirect) 1925 QPDFObjectHandle::getJSON(bool dereference_indirect)
  1926 +#else
  1927 +JSON
  1928 +QPDFObjectHandle::getJSON(bool dereference_indirect) const
  1929 +#endif
1609 { 1930 {
1610 return getJSON(1, dereference_indirect); 1931 return getJSON(1, dereference_indirect);
1611 } 1932 }
1612 1933
  1934 +#ifndef QPDF_FUTURE
1613 JSON 1935 JSON
1614 QPDFObjectHandle::getJSON(int json_version, bool dereference_indirect) 1936 QPDFObjectHandle::getJSON(int json_version, bool dereference_indirect)
  1937 +#else
  1938 +JSON
  1939 +QPDFObjectHandle::getJSON(int json_version, bool dereference_indirect) const
  1940 +#endif
1615 { 1941 {
1616 if ((!dereference_indirect) && isIndirect()) { 1942 if ((!dereference_indirect) && isIndirect()) {
1617 return JSON::makeString(unparse()); 1943 return JSON::makeString(unparse());
@@ -1626,8 +1952,13 @@ QPDFObjectHandle::getJSON(int json_version, bool dereference_indirect) @@ -1626,8 +1952,13 @@ QPDFObjectHandle::getJSON(int json_version, bool dereference_indirect)
1626 } 1952 }
1627 } 1953 }
1628 1954
  1955 +#ifndef QPDF_FUTURE
1629 void 1956 void
1630 QPDFObjectHandle::writeJSON(int json_version, JSON::Writer& p, bool dereference_indirect) 1957 QPDFObjectHandle::writeJSON(int json_version, JSON::Writer& p, bool dereference_indirect)
  1958 +#else
  1959 +void
  1960 +QPDFObjectHandle::writeJSON(int json_version, JSON::Writer& p, bool dereference_indirect) const
  1961 +#endif
1631 { 1962 {
1632 if (!dereference_indirect && isIndirect()) { 1963 if (!dereference_indirect && isIndirect()) {
1633 p << "\"" << getObjGen().unparse(' ') << " R\""; 1964 p << "\"" << getObjGen().unparse(' ') << " R\"";
@@ -1638,8 +1969,14 @@ QPDFObjectHandle::writeJSON(int json_version, JSON::Writer&amp; p, bool dereference_ @@ -1638,8 +1969,14 @@ QPDFObjectHandle::writeJSON(int json_version, JSON::Writer&amp; p, bool dereference_
1638 } 1969 }
1639 } 1970 }
1640 1971
  1972 +#ifndef QPDF_FUTURE
1641 void 1973 void
1642 QPDFObjectHandle::writeJSON(int json_version, Pipeline* p, bool dereference_indirect, size_t depth) 1974 QPDFObjectHandle::writeJSON(int json_version, Pipeline* p, bool dereference_indirect, size_t depth)
  1975 +#else
  1976 +void
  1977 +QPDFObjectHandle::writeJSON(
  1978 + int json_version, Pipeline* p, bool dereference_indirect, size_t depth) const
  1979 +#endif
1643 { 1980 {
1644 JSON::Writer jw{p, depth}; 1981 JSON::Writer jw{p, depth};
1645 writeJSON(json_version, jw, dereference_indirect); 1982 writeJSON(json_version, jw, dereference_indirect);
@@ -1871,8 +2208,13 @@ QPDFObjectHandle::parse( @@ -1871,8 +2208,13 @@ QPDFObjectHandle::parse(
1871 return QPDFParser(input, object_description, tokenizer, decrypter, context).parse(empty, false); 2208 return QPDFParser(input, object_description, tokenizer, decrypter, context).parse(empty, false);
1872 } 2209 }
1873 2210
  2211 +#ifndef QPDF_FUTURE
1874 qpdf_offset_t 2212 qpdf_offset_t
1875 QPDFObjectHandle::getParsedOffset() 2213 QPDFObjectHandle::getParsedOffset()
  2214 +#else
  2215 +qpdf_offset_t
  2216 +QPDFObjectHandle::getParsedOffset() const
  2217 +#endif
1876 { 2218 {
1877 return obj ? obj->getParsedOffset() : -1; 2219 return obj ? obj->getParsedOffset() : -1;
1878 } 2220 }
@@ -2057,8 +2399,13 @@ QPDFObjectHandle::setObjectDescription(QPDF* owning_qpdf, std::string const&amp; obj @@ -2057,8 +2399,13 @@ QPDFObjectHandle::setObjectDescription(QPDF* owning_qpdf, std::string const&amp; obj
2057 } 2399 }
2058 } 2400 }
2059 2401
  2402 +#ifndef QPDF_FUTURE
2060 bool 2403 bool
2061 QPDFObjectHandle::hasObjectDescription() 2404 QPDFObjectHandle::hasObjectDescription()
  2405 +#else
  2406 +bool
  2407 +QPDFObjectHandle::hasObjectDescription() const
  2408 +#endif
2062 { 2409 {
2063 return obj && obj->hasDescription(); 2410 return obj && obj->hasDescription();
2064 } 2411 }
@@ -2160,7 +2507,7 @@ QPDFObjectHandle::assertInitialized() const @@ -2160,7 +2507,7 @@ QPDFObjectHandle::assertInitialized() const
2160 } 2507 }
2161 2508
2162 void 2509 void
2163 -QPDFObjectHandle::typeWarning(char const* expected_type, std::string const& warning) 2510 +QPDFObjectHandle::typeWarning(char const* expected_type, std::string const& warning) const
2164 { 2511 {
2165 QPDF* context = nullptr; 2512 QPDF* context = nullptr;
2166 std::string description; 2513 std::string description;
@@ -2179,11 +2526,16 @@ QPDFObjectHandle::typeWarning(char const* expected_type, std::string const&amp; warn @@ -2179,11 +2526,16 @@ QPDFObjectHandle::typeWarning(char const* expected_type, std::string const&amp; warn
2179 description, 2526 description,
2180 0, 2527 0,
2181 std::string("operation for ") + expected_type + " attempted on object of type " + 2528 std::string("operation for ") + expected_type + " attempted on object of type " +
2182 - getTypeName() + ": " + warning)); 2529 + obj->getTypeName() + ": " + warning));
2183 } 2530 }
2184 2531
  2532 +#ifndef QPDF_FUTURE
2185 void 2533 void
2186 QPDFObjectHandle::warnIfPossible(std::string const& warning) 2534 QPDFObjectHandle::warnIfPossible(std::string const& warning)
  2535 +#else
  2536 +void
  2537 +QPDFObjectHandle::warnIfPossible(std::string const& warning) const
  2538 +#endif
2187 { 2539 {
2188 QPDF* context = nullptr; 2540 QPDF* context = nullptr;
2189 std::string description; 2541 std::string description;
@@ -2195,7 +2547,7 @@ QPDFObjectHandle::warnIfPossible(std::string const&amp; warning) @@ -2195,7 +2547,7 @@ QPDFObjectHandle::warnIfPossible(std::string const&amp; warning)
2195 } 2547 }
2196 2548
2197 void 2549 void
2198 -QPDFObjectHandle::objectWarning(std::string const& warning) 2550 +QPDFObjectHandle::objectWarning(std::string const& warning) const
2199 { 2551 {
2200 QPDF* context = nullptr; 2552 QPDF* context = nullptr;
2201 std::string description; 2553 std::string description;
@@ -2206,109 +2558,189 @@ QPDFObjectHandle::objectWarning(std::string const&amp; warning) @@ -2206,109 +2558,189 @@ QPDFObjectHandle::objectWarning(std::string const&amp; warning)
2206 } 2558 }
2207 2559
2208 void 2560 void
2209 -QPDFObjectHandle::assertType(char const* type_name, bool istype) 2561 +QPDFObjectHandle::assertType(char const* type_name, bool istype) const
2210 { 2562 {
2211 if (!istype) { 2563 if (!istype) {
2212 throw std::runtime_error( 2564 throw std::runtime_error(
2213 std::string("operation for ") + type_name + " attempted on object of type " + 2565 std::string("operation for ") + type_name + " attempted on object of type " +
2214 - getTypeName()); 2566 + (obj ? obj->getTypeName() : "uninitialized"));
2215 } 2567 }
2216 } 2568 }
2217 2569
  2570 +#ifndef QPDF_FUTURE
2218 void 2571 void
2219 QPDFObjectHandle::assertNull() 2572 QPDFObjectHandle::assertNull()
  2573 +#else
  2574 +void
  2575 +QPDFObjectHandle::assertNull() const
  2576 +#endif
2220 { 2577 {
2221 assertType("null", isNull()); 2578 assertType("null", isNull());
2222 } 2579 }
2223 2580
  2581 +#ifndef QPDF_FUTURE
2224 void 2582 void
2225 QPDFObjectHandle::assertBool() 2583 QPDFObjectHandle::assertBool()
  2584 +#else
  2585 +void
  2586 +QPDFObjectHandle::assertBool() const
  2587 +#endif
2226 { 2588 {
2227 assertType("boolean", isBool()); 2589 assertType("boolean", isBool());
2228 } 2590 }
2229 2591
  2592 +#ifndef QPDF_FUTURE
2230 void 2593 void
2231 QPDFObjectHandle::assertInteger() 2594 QPDFObjectHandle::assertInteger()
  2595 +#else
  2596 +void
  2597 +QPDFObjectHandle::assertInteger() const
  2598 +#endif
2232 { 2599 {
2233 assertType("integer", isInteger()); 2600 assertType("integer", isInteger());
2234 } 2601 }
2235 2602
  2603 +#ifndef QPDF_FUTURE
2236 void 2604 void
2237 QPDFObjectHandle::assertReal() 2605 QPDFObjectHandle::assertReal()
  2606 +#else
  2607 +void
  2608 +QPDFObjectHandle::assertReal() const
  2609 +#endif
2238 { 2610 {
2239 assertType("real", isReal()); 2611 assertType("real", isReal());
2240 } 2612 }
2241 2613
  2614 +#ifndef QPDF_FUTURE
2242 void 2615 void
2243 QPDFObjectHandle::assertName() 2616 QPDFObjectHandle::assertName()
  2617 +#else
  2618 +void
  2619 +QPDFObjectHandle::assertName() const
  2620 +#endif
2244 { 2621 {
2245 assertType("name", isName()); 2622 assertType("name", isName());
2246 } 2623 }
2247 2624
  2625 +#ifndef QPDF_FUTURE
2248 void 2626 void
2249 QPDFObjectHandle::assertString() 2627 QPDFObjectHandle::assertString()
  2628 +#else
  2629 +void
  2630 +QPDFObjectHandle::assertString() const
  2631 +#endif
2250 { 2632 {
2251 assertType("string", isString()); 2633 assertType("string", isString());
2252 } 2634 }
2253 2635
  2636 +#ifndef QPDF_FUTURE
2254 void 2637 void
2255 QPDFObjectHandle::assertOperator() 2638 QPDFObjectHandle::assertOperator()
  2639 +#else
  2640 +void
  2641 +QPDFObjectHandle::assertOperator() const
  2642 +#endif
2256 { 2643 {
2257 assertType("operator", isOperator()); 2644 assertType("operator", isOperator());
2258 } 2645 }
2259 2646
  2647 +#ifndef QPDF_FUTURE
2260 void 2648 void
2261 QPDFObjectHandle::assertInlineImage() 2649 QPDFObjectHandle::assertInlineImage()
  2650 +#else
  2651 +void
  2652 +QPDFObjectHandle::assertInlineImage() const
  2653 +#endif
2262 { 2654 {
2263 assertType("inlineimage", isInlineImage()); 2655 assertType("inlineimage", isInlineImage());
2264 } 2656 }
2265 2657
  2658 +#ifndef QPDF_FUTURE
2266 void 2659 void
2267 QPDFObjectHandle::assertArray() 2660 QPDFObjectHandle::assertArray()
  2661 +#else
  2662 +void
  2663 +QPDFObjectHandle::assertArray() const
  2664 +#endif
2268 { 2665 {
2269 assertType("array", isArray()); 2666 assertType("array", isArray());
2270 } 2667 }
2271 2668
  2669 +#ifndef QPDF_FUTURE
2272 void 2670 void
2273 QPDFObjectHandle::assertDictionary() 2671 QPDFObjectHandle::assertDictionary()
  2672 +#else
  2673 +void
  2674 +QPDFObjectHandle::assertDictionary() const
  2675 +#endif
2274 { 2676 {
2275 assertType("dictionary", isDictionary()); 2677 assertType("dictionary", isDictionary());
2276 } 2678 }
2277 2679
  2680 +#ifndef QPDF_FUTURE
2278 void 2681 void
2279 QPDFObjectHandle::assertStream() 2682 QPDFObjectHandle::assertStream()
  2683 +#else
  2684 +void
  2685 +QPDFObjectHandle::assertStream() const
  2686 +#endif
2280 { 2687 {
2281 assertType("stream", isStream()); 2688 assertType("stream", isStream());
2282 } 2689 }
2283 2690
  2691 +#ifndef QPDF_FUTURE
2284 void 2692 void
2285 QPDFObjectHandle::assertReserved() 2693 QPDFObjectHandle::assertReserved()
  2694 +#else
  2695 +void
  2696 +QPDFObjectHandle::assertReserved() const
  2697 +#endif
2286 { 2698 {
2287 assertType("reserved", isReserved()); 2699 assertType("reserved", isReserved());
2288 } 2700 }
2289 2701
  2702 +#ifndef QPDF_FUTURE
2290 void 2703 void
2291 QPDFObjectHandle::assertIndirect() 2704 QPDFObjectHandle::assertIndirect()
  2705 +#else
  2706 +void
  2707 +QPDFObjectHandle::assertIndirect() const
  2708 +#endif
2292 { 2709 {
2293 if (!isIndirect()) { 2710 if (!isIndirect()) {
2294 throw std::logic_error("operation for indirect object attempted on direct object"); 2711 throw std::logic_error("operation for indirect object attempted on direct object");
2295 } 2712 }
2296 } 2713 }
2297 2714
  2715 +#ifndef QPDF_FUTURE
2298 void 2716 void
2299 QPDFObjectHandle::assertScalar() 2717 QPDFObjectHandle::assertScalar()
  2718 +#else
  2719 +void
  2720 +QPDFObjectHandle::assertScalar() const
  2721 +#endif
2300 { 2722 {
2301 assertType("scalar", isScalar()); 2723 assertType("scalar", isScalar());
2302 } 2724 }
2303 2725
  2726 +#ifndef QPDF_FUTURE
2304 void 2727 void
2305 QPDFObjectHandle::assertNumber() 2728 QPDFObjectHandle::assertNumber()
  2729 +#else
  2730 +void
  2731 +QPDFObjectHandle::assertNumber() const
  2732 +#endif
2306 { 2733 {
2307 assertType("number", isNumber()); 2734 assertType("number", isNumber());
2308 } 2735 }
2309 2736
  2737 +#ifndef QPDF_FUTURE
2310 bool 2738 bool
2311 QPDFObjectHandle::isPageObject() 2739 QPDFObjectHandle::isPageObject()
  2740 +#else
  2741 +bool
  2742 +QPDFObjectHandle::isPageObject() const
  2743 +#endif
2312 { 2744 {
2313 // See comments in QPDFObjectHandle.hh. 2745 // See comments in QPDFObjectHandle.hh.
2314 if (getOwningQPDF() == nullptr) { 2746 if (getOwningQPDF() == nullptr) {
@@ -2319,8 +2751,13 @@ QPDFObjectHandle::isPageObject() @@ -2319,8 +2751,13 @@ QPDFObjectHandle::isPageObject()
2319 return isDictionaryOfType("/Page"); 2751 return isDictionaryOfType("/Page");
2320 } 2752 }
2321 2753
  2754 +#ifndef QPDF_FUTURE
2322 bool 2755 bool
2323 QPDFObjectHandle::isPagesObject() 2756 QPDFObjectHandle::isPagesObject()
  2757 +#else
  2758 +bool
  2759 +QPDFObjectHandle::isPagesObject() const
  2760 +#endif
2324 { 2761 {
2325 if (getOwningQPDF() == nullptr) { 2762 if (getOwningQPDF() == nullptr) {
2326 return false; 2763 return false;
@@ -2330,14 +2767,24 @@ QPDFObjectHandle::isPagesObject() @@ -2330,14 +2767,24 @@ QPDFObjectHandle::isPagesObject()
2330 return isDictionaryOfType("/Pages"); 2767 return isDictionaryOfType("/Pages");
2331 } 2768 }
2332 2769
  2770 +#ifndef QPDF_FUTURE
2333 bool 2771 bool
2334 QPDFObjectHandle::isFormXObject() 2772 QPDFObjectHandle::isFormXObject()
  2773 +#else
  2774 +bool
  2775 +QPDFObjectHandle::isFormXObject() const
  2776 +#endif
2335 { 2777 {
2336 return isStreamOfType("", "/Form"); 2778 return isStreamOfType("", "/Form");
2337 } 2779 }
2338 2780
  2781 +#ifndef QPDF_FUTURE
2339 bool 2782 bool
2340 QPDFObjectHandle::isImage(bool exclude_imagemask) 2783 QPDFObjectHandle::isImage(bool exclude_imagemask)
  2784 +#else
  2785 +bool
  2786 +QPDFObjectHandle::isImage(bool exclude_imagemask) const
  2787 +#endif
2341 { 2788 {
2342 return ( 2789 return (
2343 isStreamOfType("", "/Image") && 2790 isStreamOfType("", "/Image") &&
@@ -2358,8 +2805,13 @@ QPDFObjectHandle::checkOwnership(QPDFObjectHandle const&amp; item) const @@ -2358,8 +2805,13 @@ QPDFObjectHandle::checkOwnership(QPDFObjectHandle const&amp; item) const
2358 } 2805 }
2359 } 2806 }
2360 2807
  2808 +#ifndef QPDF_FUTURE
2361 void 2809 void
2362 QPDFObjectHandle::assertPageObject() 2810 QPDFObjectHandle::assertPageObject()
  2811 +#else
  2812 +void
  2813 +QPDFObjectHandle::assertPageObject() const
  2814 +#endif
2363 { 2815 {
2364 if (!isPageObject()) { 2816 if (!isPageObject()) {
2365 throw std::runtime_error("page operation called on non-Page object"); 2817 throw std::runtime_error("page operation called on non-Page object");