diff --git a/ChangeLog b/ChangeLog index 0a3b3d81..cd2ee734 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,23 @@ +2013-01-22 Jay Berkenbilt + + * Add QPDFObjectHandle::getTypeCode(). This method returns a + unique integer (enumerated type) value corresponding to the object + type of the QPDFObjectHandle. It can be used as an alternative to + the QPDFObjectHandle::is* methods for type testing, particularly + where there is a desire to use a switch statement or optimize for + performance when testing object types. + + * Add QPDFObjectHandle::getTypeName(). This method returns a + string literal describing the object type. It is useful for + testing and debugging. + 2013-01-20 Jay Berkenbilt - * Added QPDFObjectHandle::parseContentStream, which parses the + * Add QPDFObjectHandle::parseContentStream, which parses the objects in a content stream and calls handlers in a callback class. The example pdf-parse-content illustrates it use. - * Added QPDF_Keyword and QPDF_InlineImage types along with + * Add QPDF_Keyword and QPDF_InlineImage types along with appropriate wrapper methods in QPDFObjectHandle. These new object types are to facilitate content stream parsing. diff --git a/examples/pdf-parse-content.cc b/examples/pdf-parse-content.cc index 1c3cae16..430c0a06 100644 --- a/examples/pdf-parse-content.cc +++ b/examples/pdf-parse-content.cc @@ -30,10 +30,10 @@ class ParserCallbacks: public QPDFObjectHandle::ParserCallbacks void ParserCallbacks::handleObject(QPDFObjectHandle obj) { + std::cout << obj.getTypeName() << ": "; if (obj.isInlineImage()) { std::string val = obj.getInlineImageValue(); - std::cout << "inline image: "; char buf[3]; buf[2] = '\0'; for (size_t i = 0; i < val.length(); ++i) diff --git a/examples/qtest/parse-content/content.out b/examples/qtest/parse-content/content.out index 9c07edc2..dc6bd8d1 100644 --- a/examples/qtest/parse-content/content.out +++ b/examples/qtest/parse-content/content.out @@ -1,11 +1,11 @@ -BT -/F1 -24 -Tf -72 -720 -Td -(Potato) -Tj -ET +keyword: BT +name: /F1 +integer: 24 +keyword: Tf +integer: 72 +integer: 720 +keyword: Td +string: (Potato) +keyword: Tj +keyword: ET -EOF- diff --git a/include/qpdf/QPDFObject.hh b/include/qpdf/QPDFObject.hh index 8bb61022..4a5f2dec 100644 --- a/include/qpdf/QPDFObject.hh +++ b/include/qpdf/QPDFObject.hh @@ -18,9 +18,42 @@ class QPDFObjectHandle; class QPDFObject { public: + + // Objects derived from QPDFObject are accessible through + // QPDFObjectHandle. Each object returns a unique type code that + // has one of the values in the list below. As new object types + // are added to qpdf, additional items may be added to the list, + // so code that switches on these values should take that into + // consideration. + enum object_type_e { + // Object types internal to qpdf + ot_uninitialized, + ot_reserved, + // Object types that can occur in the main document + ot_boolean, + ot_null, + ot_integer, + ot_real, + ot_name, + ot_string, + ot_array, + ot_dictionary, + ot_stream, + // Additional object types that can occur in content streams + ot_keyword, + ot_inlineimage, + }; + virtual ~QPDFObject() {} virtual std::string unparse() = 0; + // Return a unique type code for the object + virtual object_type_e getTypeCode() const = 0; + + // Return a string literal that describes the type, useful for + // debugging and testing + virtual char const* getTypeName() const = 0; + // Accessor to give specific access to non-public methods class ObjAccessor { diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh index c4a922d1..a23d81df 100644 --- a/include/qpdf/QPDFObjectHandle.hh +++ b/include/qpdf/QPDFObjectHandle.hh @@ -91,6 +91,14 @@ class QPDFObjectHandle QPDF_DLL bool isInitialized() const; + // Return type code and type name of underlying object. These are + // useful for doing rapid type tests (like switch statements) or + // for testing and debugging. + QPDF_DLL + QPDFObject::object_type_e getTypeCode() const; + QPDF_DLL + char const* getTypeName() const; + // Exactly one of these will return true for any object. Keyword // and InlineImage are only allowed in content streams. QPDF_DLL diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index bfca3f08..b53dd577 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -76,6 +76,32 @@ QPDFObjectHandle::isInitialized() const return this->initialized; } +QPDFObject::object_type_e +QPDFObjectHandle::getTypeCode() const +{ + if (obj.getPointer()) + { + return obj->getTypeCode(); + } + else + { + return QPDFObject::ot_uninitialized; + } +} + +char const* +QPDFObjectHandle::getTypeName() const +{ + if (obj.getPointer()) + { + return obj->getTypeName(); + } + else + { + return "uninitialized"; + } +} + template class QPDFObjectTypeAccessor { diff --git a/libqpdf/QPDF_Array.cc b/libqpdf/QPDF_Array.cc index 9f720287..0c2be92f 100644 --- a/libqpdf/QPDF_Array.cc +++ b/libqpdf/QPDF_Array.cc @@ -34,6 +34,18 @@ QPDF_Array::unparse() return result; } +QPDFObject::object_type_e +QPDF_Array::getTypeCode() const +{ + return QPDFObject::ot_array; +} + +char const* +QPDF_Array::getTypeName() const +{ + return "array"; +} + int QPDF_Array::getNItems() const { diff --git a/libqpdf/QPDF_Bool.cc b/libqpdf/QPDF_Bool.cc index 4bcbfc32..781a7ad9 100644 --- a/libqpdf/QPDF_Bool.cc +++ b/libqpdf/QPDF_Bool.cc @@ -15,6 +15,18 @@ QPDF_Bool::unparse() return (val ? "true" : "false"); } +QPDFObject::object_type_e +QPDF_Bool::getTypeCode() const +{ + return QPDFObject::ot_boolean; +} + +char const* +QPDF_Bool::getTypeName() const +{ + return "boolean"; +} + bool QPDF_Bool::getVal() const { diff --git a/libqpdf/QPDF_Dictionary.cc b/libqpdf/QPDF_Dictionary.cc index 3be138a4..0af2f4bf 100644 --- a/libqpdf/QPDF_Dictionary.cc +++ b/libqpdf/QPDF_Dictionary.cc @@ -39,6 +39,18 @@ QPDF_Dictionary::unparse() return result; } +QPDFObject::object_type_e +QPDF_Dictionary::getTypeCode() const +{ + return QPDFObject::ot_dictionary; +} + +char const* +QPDF_Dictionary::getTypeName() const +{ + return "dictionary"; +} + bool QPDF_Dictionary::hasKey(std::string const& key) { diff --git a/libqpdf/QPDF_InlineImage.cc b/libqpdf/QPDF_InlineImage.cc index e42ddbf2..48be6387 100644 --- a/libqpdf/QPDF_InlineImage.cc +++ b/libqpdf/QPDF_InlineImage.cc @@ -17,6 +17,18 @@ QPDF_InlineImage::unparse() return this->val; } +QPDFObject::object_type_e +QPDF_InlineImage::getTypeCode() const +{ + return QPDFObject::ot_inlineimage; +} + +char const* +QPDF_InlineImage::getTypeName() const +{ + return "inline-image"; +} + std::string QPDF_InlineImage::getVal() const { diff --git a/libqpdf/QPDF_Integer.cc b/libqpdf/QPDF_Integer.cc index fb25af1b..572b34e0 100644 --- a/libqpdf/QPDF_Integer.cc +++ b/libqpdf/QPDF_Integer.cc @@ -17,6 +17,18 @@ QPDF_Integer::unparse() return QUtil::int_to_string(this->val); } +QPDFObject::object_type_e +QPDF_Integer::getTypeCode() const +{ + return QPDFObject::ot_integer; +} + +char const* +QPDF_Integer::getTypeName() const +{ + return "integer"; +} + long long QPDF_Integer::getVal() const { diff --git a/libqpdf/QPDF_Keyword.cc b/libqpdf/QPDF_Keyword.cc index e2537842..f55088e2 100644 --- a/libqpdf/QPDF_Keyword.cc +++ b/libqpdf/QPDF_Keyword.cc @@ -17,6 +17,18 @@ QPDF_Keyword::unparse() return this->val; } +QPDFObject::object_type_e +QPDF_Keyword::getTypeCode() const +{ + return QPDFObject::ot_keyword; +} + +char const* +QPDF_Keyword::getTypeName() const +{ + return "keyword"; +} + std::string QPDF_Keyword::getVal() const { diff --git a/libqpdf/QPDF_Name.cc b/libqpdf/QPDF_Name.cc index ce2184f8..19610bff 100644 --- a/libqpdf/QPDF_Name.cc +++ b/libqpdf/QPDF_Name.cc @@ -41,6 +41,18 @@ QPDF_Name::unparse() return normalizeName(this->name); } +QPDFObject::object_type_e +QPDF_Name::getTypeCode() const +{ + return QPDFObject::ot_name; +} + +char const* +QPDF_Name::getTypeName() const +{ + return "name"; +} + std::string QPDF_Name::getName() const { diff --git a/libqpdf/QPDF_Null.cc b/libqpdf/QPDF_Null.cc index 811ddd2e..05c35b09 100644 --- a/libqpdf/QPDF_Null.cc +++ b/libqpdf/QPDF_Null.cc @@ -9,3 +9,15 @@ QPDF_Null::unparse() { return "null"; } + +QPDFObject::object_type_e +QPDF_Null::getTypeCode() const +{ + return QPDFObject::ot_null; +} + +char const* +QPDF_Null::getTypeName() const +{ + return "null"; +} diff --git a/libqpdf/QPDF_Real.cc b/libqpdf/QPDF_Real.cc index 466ddb72..fa0a60cb 100644 --- a/libqpdf/QPDF_Real.cc +++ b/libqpdf/QPDF_Real.cc @@ -22,6 +22,18 @@ QPDF_Real::unparse() return this->val; } +QPDFObject::object_type_e +QPDF_Real::getTypeCode() const +{ + return QPDFObject::ot_real; +} + +char const* +QPDF_Real::getTypeName() const +{ + return "real"; +} + std::string QPDF_Real::getVal() { diff --git a/libqpdf/QPDF_Reserved.cc b/libqpdf/QPDF_Reserved.cc index 368db3b4..ad8d94a3 100644 --- a/libqpdf/QPDF_Reserved.cc +++ b/libqpdf/QPDF_Reserved.cc @@ -11,3 +11,15 @@ QPDF_Reserved::unparse() throw std::logic_error("attempt to unparse QPDF_Reserved"); return ""; } + +QPDFObject::object_type_e +QPDF_Reserved::getTypeCode() const +{ + return QPDFObject::ot_reserved; +} + +char const* +QPDF_Reserved::getTypeName() const +{ + return "reserved"; +} diff --git a/libqpdf/QPDF_Stream.cc b/libqpdf/QPDF_Stream.cc index 88b8e8ff..15024849 100644 --- a/libqpdf/QPDF_Stream.cc +++ b/libqpdf/QPDF_Stream.cc @@ -63,6 +63,18 @@ QPDF_Stream::unparse() QUtil::int_to_string(this->generation) + " R"; } +QPDFObject::object_type_e +QPDF_Stream::getTypeCode() const +{ + return QPDFObject::ot_stream; +} + +char const* +QPDF_Stream::getTypeName() const +{ + return "stream"; +} + QPDFObjectHandle QPDF_Stream::getDict() const { diff --git a/libqpdf/QPDF_String.cc b/libqpdf/QPDF_String.cc index 2ac2ed32..3a8e7074 100644 --- a/libqpdf/QPDF_String.cc +++ b/libqpdf/QPDF_String.cc @@ -33,6 +33,18 @@ QPDF_String::unparse() return unparse(false); } +QPDFObject::object_type_e +QPDF_String::getTypeCode() const +{ + return QPDFObject::ot_string; +} + +char const* +QPDF_String::getTypeName() const +{ + return "string"; +} + std::string QPDF_String::unparse(bool force_binary) { diff --git a/libqpdf/qpdf/QPDF_Array.hh b/libqpdf/qpdf/QPDF_Array.hh index 338f6eb2..e81f8664 100644 --- a/libqpdf/qpdf/QPDF_Array.hh +++ b/libqpdf/qpdf/QPDF_Array.hh @@ -12,6 +12,8 @@ class QPDF_Array: public QPDFObject QPDF_Array(std::vector const& items); virtual ~QPDF_Array(); virtual std::string unparse(); + virtual QPDFObject::object_type_e getTypeCode() const; + virtual char const* getTypeName() const; int getNItems() const; QPDFObjectHandle getItem(int n) const; diff --git a/libqpdf/qpdf/QPDF_Bool.hh b/libqpdf/qpdf/QPDF_Bool.hh index 90dc590e..2ec8eb10 100644 --- a/libqpdf/qpdf/QPDF_Bool.hh +++ b/libqpdf/qpdf/QPDF_Bool.hh @@ -9,6 +9,8 @@ class QPDF_Bool: public QPDFObject QPDF_Bool(bool val); virtual ~QPDF_Bool(); virtual std::string unparse(); + virtual QPDFObject::object_type_e getTypeCode() const; + virtual char const* getTypeName() const; bool getVal() const; private: diff --git a/libqpdf/qpdf/QPDF_Dictionary.hh b/libqpdf/qpdf/QPDF_Dictionary.hh index af9f7f09..5b5630cf 100644 --- a/libqpdf/qpdf/QPDF_Dictionary.hh +++ b/libqpdf/qpdf/QPDF_Dictionary.hh @@ -14,6 +14,8 @@ class QPDF_Dictionary: public QPDFObject QPDF_Dictionary(std::map const& items); virtual ~QPDF_Dictionary(); virtual std::string unparse(); + virtual QPDFObject::object_type_e getTypeCode() const; + virtual char const* getTypeName() const; // hasKey() and getKeys() treat keys with null values as if they // aren't there. getKey() returns null for the value of a diff --git a/libqpdf/qpdf/QPDF_InlineImage.hh b/libqpdf/qpdf/QPDF_InlineImage.hh index 6408a2f1..6be034a9 100644 --- a/libqpdf/qpdf/QPDF_InlineImage.hh +++ b/libqpdf/qpdf/QPDF_InlineImage.hh @@ -9,6 +9,8 @@ class QPDF_InlineImage: public QPDFObject QPDF_InlineImage(std::string const& val); virtual ~QPDF_InlineImage(); virtual std::string unparse(); + virtual QPDFObject::object_type_e getTypeCode() const; + virtual char const* getTypeName() const; std::string getVal() const; private: diff --git a/libqpdf/qpdf/QPDF_Integer.hh b/libqpdf/qpdf/QPDF_Integer.hh index f9964693..091392ab 100644 --- a/libqpdf/qpdf/QPDF_Integer.hh +++ b/libqpdf/qpdf/QPDF_Integer.hh @@ -9,6 +9,8 @@ class QPDF_Integer: public QPDFObject QPDF_Integer(long long val); virtual ~QPDF_Integer(); virtual std::string unparse(); + virtual QPDFObject::object_type_e getTypeCode() const; + virtual char const* getTypeName() const; long long getVal() const; private: diff --git a/libqpdf/qpdf/QPDF_Keyword.hh b/libqpdf/qpdf/QPDF_Keyword.hh index 1a5c0ee6..78ae5791 100644 --- a/libqpdf/qpdf/QPDF_Keyword.hh +++ b/libqpdf/qpdf/QPDF_Keyword.hh @@ -9,6 +9,8 @@ class QPDF_Keyword: public QPDFObject QPDF_Keyword(std::string const& val); virtual ~QPDF_Keyword(); virtual std::string unparse(); + virtual QPDFObject::object_type_e getTypeCode() const; + virtual char const* getTypeName() const; std::string getVal() const; private: diff --git a/libqpdf/qpdf/QPDF_Name.hh b/libqpdf/qpdf/QPDF_Name.hh index 361556a0..5f50c41d 100644 --- a/libqpdf/qpdf/QPDF_Name.hh +++ b/libqpdf/qpdf/QPDF_Name.hh @@ -9,6 +9,8 @@ class QPDF_Name: public QPDFObject QPDF_Name(std::string const& name); virtual ~QPDF_Name(); virtual std::string unparse(); + virtual QPDFObject::object_type_e getTypeCode() const; + virtual char const* getTypeName() const; std::string getName() const; // Put # into strings with characters unsuitable for name token diff --git a/libqpdf/qpdf/QPDF_Null.hh b/libqpdf/qpdf/QPDF_Null.hh index dffe0260..16ca4755 100644 --- a/libqpdf/qpdf/QPDF_Null.hh +++ b/libqpdf/qpdf/QPDF_Null.hh @@ -8,6 +8,8 @@ class QPDF_Null: public QPDFObject public: virtual ~QPDF_Null(); virtual std::string unparse(); + virtual QPDFObject::object_type_e getTypeCode() const; + virtual char const* getTypeName() const; }; #endif // __QPDF_NULL_HH__ diff --git a/libqpdf/qpdf/QPDF_Real.hh b/libqpdf/qpdf/QPDF_Real.hh index 2895cee5..d59ed982 100644 --- a/libqpdf/qpdf/QPDF_Real.hh +++ b/libqpdf/qpdf/QPDF_Real.hh @@ -10,6 +10,8 @@ class QPDF_Real: public QPDFObject QPDF_Real(double value, int decimal_places = 0); virtual ~QPDF_Real(); virtual std::string unparse(); + virtual QPDFObject::object_type_e getTypeCode() const; + virtual char const* getTypeName() const; std::string getVal(); private: diff --git a/libqpdf/qpdf/QPDF_Reserved.hh b/libqpdf/qpdf/QPDF_Reserved.hh index b149f776..8dbf4fe4 100644 --- a/libqpdf/qpdf/QPDF_Reserved.hh +++ b/libqpdf/qpdf/QPDF_Reserved.hh @@ -8,6 +8,8 @@ class QPDF_Reserved: public QPDFObject public: virtual ~QPDF_Reserved(); virtual std::string unparse(); + virtual QPDFObject::object_type_e getTypeCode() const; + virtual char const* getTypeName() const; }; #endif // __QPDF_RESERVED_HH__ diff --git a/libqpdf/qpdf/QPDF_Stream.hh b/libqpdf/qpdf/QPDF_Stream.hh index 6e5dacf0..5a5d555b 100644 --- a/libqpdf/qpdf/QPDF_Stream.hh +++ b/libqpdf/qpdf/QPDF_Stream.hh @@ -17,6 +17,8 @@ class QPDF_Stream: public QPDFObject qpdf_offset_t offset, size_t length); virtual ~QPDF_Stream(); virtual std::string unparse(); + virtual QPDFObject::object_type_e getTypeCode() const; + virtual char const* getTypeName() const; QPDFObjectHandle getDict() const; // See comments in QPDFObjectHandle.hh for these methods. diff --git a/libqpdf/qpdf/QPDF_String.hh b/libqpdf/qpdf/QPDF_String.hh index 82860e9d..abf8291a 100644 --- a/libqpdf/qpdf/QPDF_String.hh +++ b/libqpdf/qpdf/QPDF_String.hh @@ -11,6 +11,8 @@ class QPDF_String: public QPDFObject QPDF_String(std::string const& val); virtual ~QPDF_String(); virtual std::string unparse(); + virtual QPDFObject::object_type_e getTypeCode() const; + virtual char const* getTypeName() const; std::string unparse(bool force_binary); std::string getVal() const; std::string getUTF8Val() const; diff --git a/qpdf/qtest/qpdf/eof-in-inline-image.out b/qpdf/qtest/qpdf/eof-in-inline-image.out index 8ac365c4..6fa0cfe1 100644 --- a/qpdf/qtest/qpdf/eof-in-inline-image.out +++ b/qpdf/qtest/qpdf/eof-in-inline-image.out @@ -1,25 +1,25 @@ -BT -/F1 -24 -Tf -72 -720 -Td -(Potato) -Tj -ET -BI -/CS -/G -/W -1 -/H -1 -/BPC -8 -/F -/Fl -/DP -<< /Columns 1 /Predictor 15 >> -ID +keyword: BT +name: /F1 +integer: 24 +keyword: Tf +integer: 72 +integer: 720 +keyword: Td +string: (Potato) +keyword: Tj +keyword: ET +keyword: BI +name: /CS +name: /G +name: /W +integer: 1 +name: /H +integer: 1 +name: /BPC +integer: 8 +name: /F +name: /Fl +name: /DP +dictionary: << /Columns 1 /Predictor 15 >> +keyword: ID content stream object 4 0 (stream data, file position 139): EOF found while reading inline image diff --git a/qpdf/qtest/qpdf/tokenize-content-streams.out b/qpdf/qtest/qpdf/tokenize-content-streams.out index 9bc933dc..31813861 100644 --- a/qpdf/qtest/qpdf/tokenize-content-streams.out +++ b/qpdf/qtest/qpdf/tokenize-content-streams.out @@ -1,95 +1,95 @@ -BT -/F1 -24 -Tf -72 -720 -Td -(Potato) -Tj -ET +keyword: BT +name: /F1 +integer: 24 +keyword: Tf +integer: 72 +integer: 720 +keyword: Td +string: (Potato) +keyword: Tj +keyword: ET -EOF- -0.1 -0 -0 -0.1 -0 -0 -cm -q -0 -1.1999 --1.1999 -0 -121.19 -150.009 -cm -BI -/CS -/G -/W -1 -/H -1 -/BPC -8 -/F -/Fl -/DP -<< /Columns 1 /Predictor 15 >> -ID -inline image: 789c63fc0f0001030101 -EI -Q -q -0 -35.997 --128.389 -0 -431.964 -7269.02 -cm -BI -/CS -/G -/W -30 -/H -107 -/BPC -8 -/F -/Fl -/DP -<< /Columns 30 /Predictor 15 >> -ID -inline image: 789cedd1a11100300800b1b2ffd06503148283bc8dfcf8af2a306ee352eff2e06318638c31c63b3801627b620a -EI -Q -q -0 -38.3968 --93.5922 -0 -431.964 -7567.79 -cm -BI -/CS -/G -/W -32 -/H -78 -/BPC -8 -/F -/Fl -/DP -<< /Columns 32 /Predictor 15 >> -ID -inline image: 789c63fccf801f308e2a185530aa60882a20203faa605401890a0643aa1e5530aa6054010d140000bdd03c13 -EI -Q +real: 0.1 +integer: 0 +integer: 0 +real: 0.1 +integer: 0 +integer: 0 +keyword: cm +keyword: q +integer: 0 +real: 1.1999 +real: -1.1999 +integer: 0 +real: 121.19 +real: 150.009 +keyword: cm +keyword: BI +name: /CS +name: /G +name: /W +integer: 1 +name: /H +integer: 1 +name: /BPC +integer: 8 +name: /F +name: /Fl +name: /DP +dictionary: << /Columns 1 /Predictor 15 >> +keyword: ID +inline-image: 789c63fc0f0001030101 +keyword: EI +keyword: Q +keyword: q +integer: 0 +real: 35.997 +real: -128.389 +integer: 0 +real: 431.964 +real: 7269.02 +keyword: cm +keyword: BI +name: /CS +name: /G +name: /W +integer: 30 +name: /H +integer: 107 +name: /BPC +integer: 8 +name: /F +name: /Fl +name: /DP +dictionary: << /Columns 30 /Predictor 15 >> +keyword: ID +inline-image: 789cedd1a11100300800b1b2ffd06503148283bc8dfcf8af2a306ee352eff2e06318638c31c63b3801627b620a +keyword: EI +keyword: Q +keyword: q +integer: 0 +real: 38.3968 +real: -93.5922 +integer: 0 +real: 431.964 +real: 7567.79 +keyword: cm +keyword: BI +name: /CS +name: /G +name: /W +integer: 32 +name: /H +integer: 78 +name: /BPC +integer: 8 +name: /F +name: /Fl +name: /DP +dictionary: << /Columns 32 /Predictor 15 >> +keyword: ID +inline-image: 789c63fccf801f308e2a185530aa60882a20203faa605401890a0643aa1e5530aa6054010d140000bdd03c13 +keyword: EI +keyword: Q -EOF- test 37 done diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc index cd6aa991..799ea4ba 100644 --- a/qpdf/test_driver.cc +++ b/qpdf/test_driver.cc @@ -72,10 +72,11 @@ class ParserCallbacks: public QPDFObjectHandle::ParserCallbacks void ParserCallbacks::handleObject(QPDFObjectHandle obj) { + std::cout << obj.getTypeName() << ": "; if (obj.isInlineImage()) { + assert(obj.getTypeCode() == QPDFObject::ot_inlineimage); std::string val = obj.getInlineImageValue(); - std::cout << "inline image: "; char buf[3]; buf[2] = '\0'; for (size_t i = 0; i < val.length(); ++i) @@ -142,6 +143,10 @@ void runtest(int n, char const* filename1, char const* arg2) assert(password.length() == 32); QPDF::trim_user_password(password); assert(password == "1234567890123456789012(45678"); + + QPDFObjectHandle uninitialized; + assert(uninitialized.getTypeCode() == QPDFObject::ot_uninitialized); + assert(strcmp(uninitialized.getTypeName(), "uninitialized") == 0); } QPDF pdf;