diff --git a/examples/pdf-custom-filter.cc b/examples/pdf-custom-filter.cc index 2cc4199..1cd4665 100644 --- a/examples/pdf-custom-filter.cc +++ b/examples/pdf-custom-filter.cc @@ -1,3 +1,5 @@ + +#include #include #include #include diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index dba648b..1ac5351 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -803,32 +802,6 @@ class QPDF // JSON import void importJSON(std::shared_ptr, bool must_be_complete); - // Type conversion helper methods - template - static qpdf_offset_t - toO(T const& i) - { - return QIntC::to_offset(i); - } - template - static size_t - toS(T const& i) - { - return QIntC::to_size(i); - } - template - static int - toI(T const& i) - { - return QIntC::to_int(i); - } - template - static unsigned long long - toULL(T const& i) - { - return QIntC::to_ulonglong(i); - } - class Members; // Keep all member variables inside the Members object, which we dynamically allocate. This diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index c9669b5..07faa88 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -761,7 +761,10 @@ QPDF::pipeStreamData( auto buf = file->read(length, offset); if (buf.size() != length) { throw qpdf_for_warning.m->c.damagedPDF( - *file, "", offset + toO(buf.size()), "unexpected EOF reading stream data"); + *file, + "", + offset + QIntC::to_offset(buf.size()), + "unexpected EOF reading stream data"); } pipeline->write(buf.data(), length); attempted_finish = true; diff --git a/libqpdf/QPDF_encryption.cc b/libqpdf/QPDF_encryption.cc index 5a0f2c0..e0fe8dc 100644 --- a/libqpdf/QPDF_encryption.cc +++ b/libqpdf/QPDF_encryption.cc @@ -1010,7 +1010,7 @@ QPDF::decryptString(std::string& str, QPDFObjGen og) // Using std::shared_ptr guarantees that tmp will be freed even if rc4.process throws an // exception. auto tmp = QUtil::make_unique_cstr(str); - RC4 rc4(QUtil::unsigned_char_pointer(key), toI(key.length())); + RC4 rc4(QUtil::unsigned_char_pointer(key), QIntC::to_int(key.length())); auto data = QUtil::unsigned_char_pointer(tmp.get()); rc4.process(data, vlen, data); str = std::string(tmp.get(), vlen); diff --git a/libqpdf/QPDF_objects.cc b/libqpdf/QPDF_objects.cc index b8c43dc..b5653bc 100644 --- a/libqpdf/QPDF_objects.cc +++ b/libqpdf/QPDF_objects.cc @@ -1138,7 +1138,7 @@ QPDF::getObjectCount() if (!m->obj_cache.empty()) { og = (*(m->obj_cache.rbegin())).first; } - return toS(og.getObj()); + return QIntC::to_size(og.getObj()); } std::vector diff --git a/libqpdf/qpdf/QPDF_private.hh b/libqpdf/qpdf/QPDF_private.hh index 895b06f..fdc38c2 100644 --- a/libqpdf/qpdf/QPDF_private.hh +++ b/libqpdf/qpdf/QPDF_private.hh @@ -3,6 +3,7 @@ #include +#include #include #include #include @@ -323,13 +324,39 @@ class QPDF::Doc } protected: + // Type conversion helper methods + template + static qpdf_offset_t + toO(T const& i) + { + return QIntC::to_offset(i); + } + template + static size_t + toS(T const& i) + { + return QIntC::to_size(i); + } + template + static int + toI(T const& i) + { + return QIntC::to_int(i); + } + template + static unsigned long long + toULL(T const& i) + { + return QIntC::to_ulonglong(i); + } + QPDF& qpdf; QPDF::Members* m; qpdf::Doc::Config& cf; QPDF::Doc::Pages& pages; QPDF::Doc::Objects& objects; - }; + }; // class qpdf::Doc::Common Doc() = delete; Doc(Doc const&) = delete;