Commit cff95bffbd069a7098a02a5ef8635cc5002621eb

Authored by m-holger
1 parent 5c866633

Tidy QPDF_private.hh

Modernise constructors, make classes final, etc.
libqpdf/QPDF.cc
... ... @@ -168,12 +168,6 @@ QPDF::StringDecrypter::StringDecrypter(QPDF* qpdf, QPDFObjGen og) :
168 168 {
169 169 }
170 170  
171   -void
172   -QPDF::StringDecrypter::decryptString(std::string& val)
173   -{
174   - qpdf->decryptString(val, og);
175   -}
176   -
177 171 std::string const&
178 172 QPDF::QPDFVersion()
179 173 {
... ... @@ -181,20 +175,6 @@ QPDF::QPDFVersion()
181 175 return QPDF::qpdf_version;
182 176 }
183 177  
184   -QPDF::EncryptionParameters::EncryptionParameters() :
185   - encrypted(false),
186   - encryption_initialized(false),
187   - encryption_V(0),
188   - encryption_R(0),
189   - encrypt_metadata(true),
190   - cf_stream(e_none),
191   - cf_string(e_none),
192   - cf_file(e_none),
193   - user_password_matched(false),
194   - owner_password_matched(false)
195   -{
196   -}
197   -
198 178 QPDF::Members::Members() :
199 179 log(QPDFLogger::defaultLogger()),
200 180 file(new InvalidInputSource()),
... ...
libqpdf/QPDF_optimization.cc
... ... @@ -9,15 +9,8 @@
9 9 #include <qpdf/QPDFWriter_private.hh>
10 10 #include <qpdf/QTC.hh>
11 11  
12   -QPDF::ObjUser::ObjUser() :
13   - ou_type(ou_bad),
14   - pageno(0)
15   -{
16   -}
17   -
18 12 QPDF::ObjUser::ObjUser(user_e type) :
19   - ou_type(type),
20   - pageno(0)
  13 + ou_type(type)
21 14 {
22 15 qpdf_assert_debug(type == ou_root);
23 16 }
... ... @@ -31,7 +24,6 @@ QPDF::ObjUser::ObjUser(user_e type, int pageno) :
31 24  
32 25 QPDF::ObjUser::ObjUser(user_e type, std::string const& key) :
33 26 ou_type(type),
34   - pageno(0),
35 27 key(key)
36 28 {
37 29 qpdf_assert_debug((type == ou_trailer_key) || (type == ou_root_key));
... ...
libqpdf/qpdf/QPDF_private.hh
... ... @@ -15,7 +15,7 @@ class QPDF::Writer
15 15 QPDFWriter::ObjTable const& obj,
16 16 std::function<int(QPDFObjectHandle&)> skip_stream_parameters)
17 17 {
18   - return qpdf.optimize(obj, skip_stream_parameters);
  18 + qpdf.optimize(obj, skip_stream_parameters);
19 19 }
20 20  
21 21 static void
... ... @@ -41,7 +41,7 @@ class QPDF::Writer
41 41 int& O,
42 42 bool compressed)
43 43 {
44   - return qpdf.generateHintStream(new_obj, obj, hint_stream, S, O, compressed);
  44 + qpdf.generateHintStream(new_obj, obj, hint_stream, S, O, compressed);
45 45 }
46 46  
47 47 static std::vector<QPDFObjGen>
... ... @@ -152,24 +152,20 @@ class QPDF::Pipe
152 152 class QPDF::ObjCache
153 153 {
154 154 public:
155   - ObjCache() :
156   - end_before_space(0),
157   - end_after_space(0)
158   - {
159   - }
  155 + ObjCache() = default;
160 156 ObjCache(
161 157 std::shared_ptr<QPDFObject> object,
162 158 qpdf_offset_t end_before_space = 0,
163 159 qpdf_offset_t end_after_space = 0) :
164   - object(object),
  160 + object(std::move(object)),
165 161 end_before_space(end_before_space),
166 162 end_after_space(end_after_space)
167 163 {
168 164 }
169 165  
170 166 std::shared_ptr<QPDFObject> object;
171   - qpdf_offset_t end_before_space;
172   - qpdf_offset_t end_after_space;
  167 + qpdf_offset_t end_before_space{0};
  168 + qpdf_offset_t end_after_space{0};
173 169 };
174 170  
175 171 class QPDF::ObjCopier
... ... @@ -185,25 +181,25 @@ class QPDF::EncryptionParameters
185 181 friend class QPDF;
186 182  
187 183 public:
188   - EncryptionParameters();
  184 + EncryptionParameters() = default;
189 185  
190 186 private:
191   - bool encrypted;
192   - bool encryption_initialized;
193   - int encryption_V;
194   - int encryption_R;
195   - bool encrypt_metadata;
  187 + bool encrypted{false};
  188 + bool encryption_initialized{false};
  189 + int encryption_V{0};
  190 + int encryption_R{0};
  191 + bool encrypt_metadata{true};
196 192 std::map<std::string, encryption_method_e> crypt_filters;
197   - encryption_method_e cf_stream;
198   - encryption_method_e cf_string;
199   - encryption_method_e cf_file;
  193 + encryption_method_e cf_stream{e_none};
  194 + encryption_method_e cf_string{e_none};
  195 + encryption_method_e cf_file{e_none};
200 196 std::string provided_password;
201 197 std::string user_password;
202 198 std::string encryption_key;
203 199 std::string cached_object_encryption_key;
204   - QPDFObjGen cached_key_og;
205   - bool user_password_matched;
206   - bool owner_password_matched;
  200 + QPDFObjGen cached_key_og{};
  201 + bool user_password_matched{false};
  202 + bool owner_password_matched{false};
207 203 };
208 204  
209 205 class QPDF::ForeignStreamData
... ... @@ -244,14 +240,18 @@ class QPDF::CopiedStreamDataProvider: public QPDFObjectHandle::StreamDataProvide
244 240 std::map<QPDFObjGen, std::shared_ptr<ForeignStreamData>> foreign_stream_data;
245 241 };
246 242  
247   -class QPDF::StringDecrypter: public QPDFObjectHandle::StringDecrypter
  243 +class QPDF::StringDecrypter final: public QPDFObjectHandle::StringDecrypter
248 244 {
249 245 friend class QPDF;
250 246  
251 247 public:
252 248 StringDecrypter(QPDF* qpdf, QPDFObjGen og);
253   - ~StringDecrypter() override = default;
254   - void decryptString(std::string& val) override;
  249 + ~StringDecrypter() final = default;
  250 + void
  251 + decryptString(std::string& val) final
  252 + {
  253 + qpdf->decryptString(val, og);
  254 + }
255 255  
256 256 private:
257 257 QPDF* qpdf;
... ... @@ -392,8 +392,7 @@ class QPDF::ObjUser
392 392 public:
393 393 enum user_e { ou_bad, ou_page, ou_thumb, ou_trailer_key, ou_root_key, ou_root };
394 394  
395   - // type is set to ou_bad
396   - ObjUser();
  395 + ObjUser() = default;
397 396  
398 397 // type must be ou_root
399 398 ObjUser(user_e type);
... ... @@ -406,8 +405,8 @@ class QPDF::ObjUser
406 405  
407 406 bool operator<(ObjUser const&) const;
408 407  
409   - user_e ou_type;
410   - int pageno; // if ou_page;
  408 + user_e ou_type{ou_bad};
  409 + int pageno{0}; // if ou_page;
411 410 std::string key; // if ou_trailer_key or ou_root_key
412 411 };
413 412  
... ... @@ -420,7 +419,7 @@ struct QPDF::UpdateObjectMapsFrame
420 419 bool top;
421 420 };
422 421  
423   -class QPDF::PatternFinder: public InputSource::Finder
  422 +class QPDF::PatternFinder final: public InputSource::Finder
424 423 {
425 424 public:
426 425 PatternFinder(QPDF& qpdf, bool (QPDF::*checker)()) :
... ... @@ -428,9 +427,9 @@ class QPDF::PatternFinder: public InputSource::Finder
428 427 checker(checker)
429 428 {
430 429 }
431   - ~PatternFinder() override = default;
  430 + ~PatternFinder() final = default;
432 431 bool
433   - check() override
  432 + check() final
434 433 {
435 434 return (this->qpdf.*checker)();
436 435 }
... ...