diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 3d9d55b..074d544 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -168,12 +168,6 @@ QPDF::StringDecrypter::StringDecrypter(QPDF* qpdf, QPDFObjGen og) : { } -void -QPDF::StringDecrypter::decryptString(std::string& val) -{ - qpdf->decryptString(val, og); -} - std::string const& QPDF::QPDFVersion() { @@ -181,20 +175,6 @@ QPDF::QPDFVersion() return QPDF::qpdf_version; } -QPDF::EncryptionParameters::EncryptionParameters() : - encrypted(false), - encryption_initialized(false), - encryption_V(0), - encryption_R(0), - encrypt_metadata(true), - cf_stream(e_none), - cf_string(e_none), - cf_file(e_none), - user_password_matched(false), - owner_password_matched(false) -{ -} - QPDF::Members::Members() : log(QPDFLogger::defaultLogger()), file(new InvalidInputSource()), diff --git a/libqpdf/QPDF_optimization.cc b/libqpdf/QPDF_optimization.cc index 094c855..2c8ec7e 100644 --- a/libqpdf/QPDF_optimization.cc +++ b/libqpdf/QPDF_optimization.cc @@ -9,15 +9,8 @@ #include #include -QPDF::ObjUser::ObjUser() : - ou_type(ou_bad), - pageno(0) -{ -} - QPDF::ObjUser::ObjUser(user_e type) : - ou_type(type), - pageno(0) + ou_type(type) { qpdf_assert_debug(type == ou_root); } @@ -31,7 +24,6 @@ QPDF::ObjUser::ObjUser(user_e type, int pageno) : QPDF::ObjUser::ObjUser(user_e type, std::string const& key) : ou_type(type), - pageno(0), key(key) { qpdf_assert_debug((type == ou_trailer_key) || (type == ou_root_key)); diff --git a/libqpdf/qpdf/QPDF_private.hh b/libqpdf/qpdf/QPDF_private.hh index 5e7dc76..07d6cba 100644 --- a/libqpdf/qpdf/QPDF_private.hh +++ b/libqpdf/qpdf/QPDF_private.hh @@ -15,7 +15,7 @@ class QPDF::Writer QPDFWriter::ObjTable const& obj, std::function skip_stream_parameters) { - return qpdf.optimize(obj, skip_stream_parameters); + qpdf.optimize(obj, skip_stream_parameters); } static void @@ -41,7 +41,7 @@ class QPDF::Writer int& O, bool compressed) { - return qpdf.generateHintStream(new_obj, obj, hint_stream, S, O, compressed); + qpdf.generateHintStream(new_obj, obj, hint_stream, S, O, compressed); } static std::vector @@ -152,24 +152,20 @@ class QPDF::Pipe class QPDF::ObjCache { public: - ObjCache() : - end_before_space(0), - end_after_space(0) - { - } + ObjCache() = default; ObjCache( std::shared_ptr object, qpdf_offset_t end_before_space = 0, qpdf_offset_t end_after_space = 0) : - object(object), + object(std::move(object)), end_before_space(end_before_space), end_after_space(end_after_space) { } std::shared_ptr object; - qpdf_offset_t end_before_space; - qpdf_offset_t end_after_space; + qpdf_offset_t end_before_space{0}; + qpdf_offset_t end_after_space{0}; }; class QPDF::ObjCopier @@ -185,25 +181,25 @@ class QPDF::EncryptionParameters friend class QPDF; public: - EncryptionParameters(); + EncryptionParameters() = default; private: - bool encrypted; - bool encryption_initialized; - int encryption_V; - int encryption_R; - bool encrypt_metadata; + bool encrypted{false}; + bool encryption_initialized{false}; + int encryption_V{0}; + int encryption_R{0}; + bool encrypt_metadata{true}; std::map crypt_filters; - encryption_method_e cf_stream; - encryption_method_e cf_string; - encryption_method_e cf_file; + encryption_method_e cf_stream{e_none}; + encryption_method_e cf_string{e_none}; + encryption_method_e cf_file{e_none}; std::string provided_password; std::string user_password; std::string encryption_key; std::string cached_object_encryption_key; - QPDFObjGen cached_key_og; - bool user_password_matched; - bool owner_password_matched; + QPDFObjGen cached_key_og{}; + bool user_password_matched{false}; + bool owner_password_matched{false}; }; class QPDF::ForeignStreamData @@ -244,14 +240,18 @@ class QPDF::CopiedStreamDataProvider: public QPDFObjectHandle::StreamDataProvide std::map> foreign_stream_data; }; -class QPDF::StringDecrypter: public QPDFObjectHandle::StringDecrypter +class QPDF::StringDecrypter final: public QPDFObjectHandle::StringDecrypter { friend class QPDF; public: StringDecrypter(QPDF* qpdf, QPDFObjGen og); - ~StringDecrypter() override = default; - void decryptString(std::string& val) override; + ~StringDecrypter() final = default; + void + decryptString(std::string& val) final + { + qpdf->decryptString(val, og); + } private: QPDF* qpdf; @@ -392,8 +392,7 @@ class QPDF::ObjUser public: enum user_e { ou_bad, ou_page, ou_thumb, ou_trailer_key, ou_root_key, ou_root }; - // type is set to ou_bad - ObjUser(); + ObjUser() = default; // type must be ou_root ObjUser(user_e type); @@ -406,8 +405,8 @@ class QPDF::ObjUser bool operator<(ObjUser const&) const; - user_e ou_type; - int pageno; // if ou_page; + user_e ou_type{ou_bad}; + int pageno{0}; // if ou_page; std::string key; // if ou_trailer_key or ou_root_key }; @@ -420,7 +419,7 @@ struct QPDF::UpdateObjectMapsFrame bool top; }; -class QPDF::PatternFinder: public InputSource::Finder +class QPDF::PatternFinder final: public InputSource::Finder { public: PatternFinder(QPDF& qpdf, bool (QPDF::*checker)()) : @@ -428,9 +427,9 @@ class QPDF::PatternFinder: public InputSource::Finder checker(checker) { } - ~PatternFinder() override = default; + ~PatternFinder() final = default; bool - check() override + check() final { return (this->qpdf.*checker)(); }