Commit 0b538ec8779a81d499865a82ffcb4f02f4471743

Authored by Jay Berkenbilt
Committed by GitHub
2 parents 21612165 d784e803

Merge pull request #982 from m-holger/cltidy

Apply various Clang-Tidy rules
Showing 111 changed files with 484 additions and 644 deletions

Too many changes.

To preserve performance only 100 of 111 files are displayed.

examples/pdf-count-strings.cc
... ... @@ -26,17 +26,14 @@ usage()
26 26 class StringCounter: public QPDFObjectHandle::TokenFilter
27 27 {
28 28 public:
29   - StringCounter() :
30   - count(0)
31   - {
32   - }
  29 + StringCounter() = default;
33 30 ~StringCounter() override = default;
34 31 void handleToken(QPDFTokenizer::Token const&) override;
35 32 void handleEOF() override;
36 33 int getCount() const;
37 34  
38 35 private:
39   - int count;
  36 + int count{0};
40 37 };
41 38  
42 39 void
... ...
examples/pdf-create.cc
... ... @@ -31,47 +31,43 @@ class ImageProvider: public QPDFObjectHandle::StreamDataProvider
31 31 size_t getHeight() const;
32 32  
33 33 private:
34   - size_t width;
35   - size_t stripe_height;
  34 + size_t width{400};
  35 + size_t stripe_height{80};
36 36 std::string color_space;
37 37 std::string filter;
38   - size_t n_stripes;
  38 + size_t n_stripes{6};
39 39 std::vector<std::string> stripes;
40   - J_COLOR_SPACE j_color_space;
  40 + J_COLOR_SPACE j_color_space{JCS_UNKNOWN};
41 41 };
42 42  
43 43 ImageProvider::ImageProvider(std::string const& color_space, std::string const& filter) :
44   - width(400),
45   - stripe_height(80),
46 44 color_space(color_space),
47   - filter(filter),
48   - n_stripes(6),
49   - j_color_space(JCS_UNKNOWN)
  45 + filter(filter)
50 46 {
51 47 if (color_space == "/DeviceCMYK") {
52 48 j_color_space = JCS_CMYK;
53   - stripes.push_back(std::string("\xff\x00\x00\x00", 4));
54   - stripes.push_back(std::string("\x00\xff\x00\x00", 4));
55   - stripes.push_back(std::string("\x00\x00\xff\x00", 4));
56   - stripes.push_back(std::string("\xff\x00\xff\x00", 4));
57   - stripes.push_back(std::string("\xff\xff\x00\x00", 4));
58   - stripes.push_back(std::string("\x00\x00\x00\xff", 4));
  49 + stripes.emplace_back("\xff\x00\x00\x00", 4);
  50 + stripes.emplace_back("\x00\xff\x00\x00", 4);
  51 + stripes.emplace_back("\x00\x00\xff\x00", 4);
  52 + stripes.emplace_back("\xff\x00\xff\x00", 4);
  53 + stripes.emplace_back("\xff\xff\x00\x00", 4);
  54 + stripes.emplace_back("\x00\x00\x00\xff", 4);
59 55 } else if (color_space == "/DeviceRGB") {
60 56 j_color_space = JCS_RGB;
61   - stripes.push_back(std::string("\xff\x00\x00", 3));
62   - stripes.push_back(std::string("\x00\xff\x00", 3));
63   - stripes.push_back(std::string("\x00\x00\xff", 3));
64   - stripes.push_back(std::string("\xff\x00\xff", 3));
65   - stripes.push_back(std::string("\xff\xff\x00", 3));
66   - stripes.push_back(std::string("\x00\x00\x00", 3));
  57 + stripes.emplace_back("\xff\x00\x00", 3);
  58 + stripes.emplace_back("\x00\xff\x00", 3);
  59 + stripes.emplace_back("\x00\x00\xff", 3);
  60 + stripes.emplace_back("\xff\x00\xff", 3);
  61 + stripes.emplace_back("\xff\xff\x00", 3);
  62 + stripes.emplace_back("\x00\x00\x00", 3);
67 63 } else if (color_space == "/DeviceGray") {
68 64 j_color_space = JCS_GRAYSCALE;
69   - stripes.push_back(std::string("\xee", 1));
70   - stripes.push_back(std::string("\xcc", 1));
71   - stripes.push_back(std::string("\x99", 1));
72   - stripes.push_back(std::string("\x66", 1));
73   - stripes.push_back(std::string("\x33", 1));
74   - stripes.push_back(std::string("\x00", 1));
  65 + stripes.emplace_back("\xee", 1);
  66 + stripes.emplace_back("\xcc", 1);
  67 + stripes.emplace_back("\x99", 1);
  68 + stripes.emplace_back("\x66", 1);
  69 + stripes.emplace_back("\x33", 1);
  70 + stripes.emplace_back("\x00", 1);
75 71 }
76 72 }
77 73  
... ... @@ -335,13 +331,13 @@ create_pdf(char const* filename)
335 331 ">>"_qpdf);
336 332  
337 333 std::vector<std::string> color_spaces;
338   - color_spaces.push_back("/DeviceCMYK");
339   - color_spaces.push_back("/DeviceRGB");
340   - color_spaces.push_back("/DeviceGray");
  334 + color_spaces.emplace_back("/DeviceCMYK");
  335 + color_spaces.emplace_back("/DeviceRGB");
  336 + color_spaces.emplace_back("/DeviceGray");
341 337 std::vector<std::string> filters;
342   - filters.push_back("null");
343   - filters.push_back("/DCTDecode");
344   - filters.push_back("/RunLengthDecode");
  338 + filters.emplace_back("null");
  339 + filters.emplace_back("/DCTDecode");
  340 + filters.emplace_back("/RunLengthDecode");
345 341 QPDFPageDocumentHelper dh(pdf);
346 342 for (auto const& color_space: color_spaces) {
347 343 for (auto const& filter: filters) {
... ...
include/qpdf/BufferInputSource.hh
... ... @@ -32,21 +32,21 @@ class QPDF_DLL_CLASS BufferInputSource: public InputSource
32 32 QPDF_DLL
33 33 BufferInputSource(std::string const& description, std::string const& contents);
34 34 QPDF_DLL
35   - virtual ~BufferInputSource();
  35 + ~BufferInputSource() override;
36 36 QPDF_DLL
37   - virtual qpdf_offset_t findAndSkipNextEOL();
  37 + qpdf_offset_t findAndSkipNextEOL() override;
38 38 QPDF_DLL
39   - virtual std::string const& getName() const;
  39 + std::string const& getName() const override;
40 40 QPDF_DLL
41   - virtual qpdf_offset_t tell();
  41 + qpdf_offset_t tell() override;
42 42 QPDF_DLL
43   - virtual void seek(qpdf_offset_t offset, int whence);
  43 + void seek(qpdf_offset_t offset, int whence) override;
44 44 QPDF_DLL
45   - virtual void rewind();
  45 + void rewind() override;
46 46 QPDF_DLL
47   - virtual size_t read(char* buffer, size_t length);
  47 + size_t read(char* buffer, size_t length) override;
48 48 QPDF_DLL
49   - virtual void unreadCh(char ch);
  49 + void unreadCh(char ch) override;
50 50  
51 51 private:
52 52 bool own_memory;
... ...
include/qpdf/ClosedFileInputSource.hh
... ... @@ -37,21 +37,21 @@ class QPDF_DLL_CLASS ClosedFileInputSource: public InputSource
37 37 QPDF_DLL
38 38 ClosedFileInputSource(char const* filename);
39 39 QPDF_DLL
40   - virtual ~ClosedFileInputSource();
  40 + ~ClosedFileInputSource() override;
41 41 QPDF_DLL
42   - virtual qpdf_offset_t findAndSkipNextEOL();
  42 + qpdf_offset_t findAndSkipNextEOL() override;
43 43 QPDF_DLL
44   - virtual std::string const& getName() const;
  44 + std::string const& getName() const override;
45 45 QPDF_DLL
46   - virtual qpdf_offset_t tell();
  46 + qpdf_offset_t tell() override;
47 47 QPDF_DLL
48   - virtual void seek(qpdf_offset_t offset, int whence);
  48 + void seek(qpdf_offset_t offset, int whence) override;
49 49 QPDF_DLL
50   - virtual void rewind();
  50 + void rewind() override;
51 51 QPDF_DLL
52   - virtual size_t read(char* buffer, size_t length);
  52 + size_t read(char* buffer, size_t length) override;
53 53 QPDF_DLL
54   - virtual void unreadCh(char ch);
  54 + void unreadCh(char ch) override;
55 55  
56 56 // The file stays open between calls to stayOpen(true) and stayOpen(false). You can use this to
57 57 // surround multiple operations on a single ClosedFileInputSource to reduce the overhead of a
... ...
include/qpdf/FileInputSource.hh
... ... @@ -35,21 +35,21 @@ class QPDF_DLL_CLASS FileInputSource: public InputSource
35 35 QPDF_DLL
36 36 void setFile(char const* description, FILE* filep, bool close_file);
37 37 QPDF_DLL
38   - virtual ~FileInputSource();
  38 + ~FileInputSource() override;
39 39 QPDF_DLL
40   - virtual qpdf_offset_t findAndSkipNextEOL();
  40 + qpdf_offset_t findAndSkipNextEOL() override;
41 41 QPDF_DLL
42   - virtual std::string const& getName() const;
  42 + std::string const& getName() const override;
43 43 QPDF_DLL
44   - virtual qpdf_offset_t tell();
  44 + qpdf_offset_t tell() override;
45 45 QPDF_DLL
46   - virtual void seek(qpdf_offset_t offset, int whence);
  46 + void seek(qpdf_offset_t offset, int whence) override;
47 47 QPDF_DLL
48   - virtual void rewind();
  48 + void rewind() override;
49 49 QPDF_DLL
50   - virtual size_t read(char* buffer, size_t length);
  50 + size_t read(char* buffer, size_t length) override;
51 51 QPDF_DLL
52   - virtual void unreadCh(char ch);
  52 + void unreadCh(char ch) override;
53 53  
54 54 private:
55 55 FileInputSource(FileInputSource const&) = delete;
... ...
include/qpdf/InputSource.hh
... ... @@ -33,8 +33,7 @@ class QPDF_DLL_CLASS InputSource
33 33 {
34 34 public:
35 35 QPDF_DLL
36   - InputSource() :
37   - last_offset(0)
  36 + InputSource()
38 37 {
39 38 }
40 39 QPDF_DLL
... ... @@ -86,7 +85,7 @@ class QPDF_DLL_CLASS InputSource
86 85 inline void loadBuffer();
87 86  
88 87 protected:
89   - qpdf_offset_t last_offset;
  88 + qpdf_offset_t last_offset{0};
90 89  
91 90 private:
92 91 class QPDF_DLL_PRIVATE Members
... ...
include/qpdf/Pl_Concatenate.hh
... ... @@ -32,13 +32,13 @@ class QPDF_DLL_CLASS Pl_Concatenate: public Pipeline
32 32 QPDF_DLL
33 33 Pl_Concatenate(char const* identifier, Pipeline* next);
34 34 QPDF_DLL
35   - virtual ~Pl_Concatenate();
  35 + ~Pl_Concatenate() override;
36 36  
37 37 QPDF_DLL
38   - virtual void write(unsigned char const* data, size_t len);
  38 + void write(unsigned char const* data, size_t len) override;
39 39  
40 40 QPDF_DLL
41   - virtual void finish();
  41 + void finish() override;
42 42  
43 43 // At the very end, call manualFinish to actually finish the rest of the pipeline.
44 44 QPDF_DLL
... ...
include/qpdf/Pl_Count.hh
... ... @@ -30,11 +30,11 @@ class QPDF_DLL_CLASS Pl_Count: public Pipeline
30 30 QPDF_DLL
31 31 Pl_Count(char const* identifier, Pipeline* next);
32 32 QPDF_DLL
33   - virtual ~Pl_Count();
  33 + ~Pl_Count() override;
34 34 QPDF_DLL
35   - virtual void write(unsigned char const*, size_t);
  35 + void write(unsigned char const*, size_t) override;
36 36 QPDF_DLL
37   - virtual void finish();
  37 + void finish() override;
38 38 // Returns the number of bytes written
39 39 QPDF_DLL
40 40 qpdf_offset_t getCount() const;
... ...
include/qpdf/Pl_DCT.hh
... ... @@ -56,12 +56,12 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline
56 56 CompressConfig* config_callback = nullptr);
57 57  
58 58 QPDF_DLL
59   - virtual ~Pl_DCT();
  59 + ~Pl_DCT() override;
60 60  
61 61 QPDF_DLL
62   - virtual void write(unsigned char const* data, size_t len);
  62 + void write(unsigned char const* data, size_t len) override;
63 63 QPDF_DLL
64   - virtual void finish();
  64 + void finish() override;
65 65  
66 66 private:
67 67 QPDF_DLL_PRIVATE
... ...
include/qpdf/Pl_Discard.hh
... ... @@ -31,11 +31,11 @@ class QPDF_DLL_CLASS Pl_Discard: public Pipeline
31 31 QPDF_DLL
32 32 Pl_Discard();
33 33 QPDF_DLL
34   - virtual ~Pl_Discard();
  34 + ~Pl_Discard() override;
35 35 QPDF_DLL
36   - virtual void write(unsigned char const*, size_t);
  36 + void write(unsigned char const*, size_t) override;
37 37 QPDF_DLL
38   - virtual void finish();
  38 + void finish() override;
39 39  
40 40 private:
41 41 class QPDF_DLL_PRIVATE Members
... ...
include/qpdf/Pl_Flate.hh
... ... @@ -40,12 +40,12 @@ class QPDF_DLL_CLASS Pl_Flate: public Pipeline
40 40 action_e action,
41 41 unsigned int out_bufsize = def_bufsize);
42 42 QPDF_DLL
43   - virtual ~Pl_Flate();
  43 + ~Pl_Flate() override;
44 44  
45 45 QPDF_DLL
46   - virtual void write(unsigned char const* data, size_t len);
  46 + void write(unsigned char const* data, size_t len) override;
47 47 QPDF_DLL
48   - virtual void finish();
  48 + void finish() override;
49 49  
50 50 // Globally set compression level from 1 (fastest, least
51 51 // compression) to 9 (slowest, most compression). Use -1 to set
... ...
include/qpdf/Pl_Function.hh
... ... @@ -54,12 +54,12 @@ class QPDF_DLL_CLASS Pl_Function: public Pipeline
54 54 Pl_Function(char const* identifier, Pipeline* next, writer_c_char_t fn, void* udata);
55 55  
56 56 QPDF_DLL
57   - virtual ~Pl_Function();
  57 + ~Pl_Function() override;
58 58  
59 59 QPDF_DLL
60   - virtual void write(unsigned char const* buf, size_t len);
  60 + void write(unsigned char const* buf, size_t len) override;
61 61 QPDF_DLL
62   - virtual void finish();
  62 + void finish() override;
63 63  
64 64 private:
65 65 class QPDF_DLL_PRIVATE Members
... ...
include/qpdf/Pl_OStream.hh
... ... @@ -36,12 +36,12 @@ class QPDF_DLL_CLASS Pl_OStream: public Pipeline
36 36 QPDF_DLL
37 37 Pl_OStream(char const* identifier, std::ostream& os);
38 38 QPDF_DLL
39   - virtual ~Pl_OStream();
  39 + ~Pl_OStream() override;
40 40  
41 41 QPDF_DLL
42   - virtual void write(unsigned char const* buf, size_t len);
  42 + void write(unsigned char const* buf, size_t len) override;
43 43 QPDF_DLL
44   - virtual void finish();
  44 + void finish() override;
45 45  
46 46 private:
47 47 class QPDF_DLL_PRIVATE Members
... ...
include/qpdf/Pl_QPDFTokenizer.hh
... ... @@ -45,11 +45,11 @@ class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline
45 45 Pl_QPDFTokenizer(
46 46 char const* identifier, QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr);
47 47 QPDF_DLL
48   - virtual ~Pl_QPDFTokenizer();
  48 + ~Pl_QPDFTokenizer() override;
49 49 QPDF_DLL
50   - virtual void write(unsigned char const* buf, size_t len);
  50 + void write(unsigned char const* buf, size_t len) override;
51 51 QPDF_DLL
52   - virtual void finish();
  52 + void finish() override;
53 53  
54 54 private:
55 55 class QPDF_DLL_PRIVATE Members
... ...
include/qpdf/Pl_RunLength.hh
... ... @@ -29,12 +29,12 @@ class QPDF_DLL_CLASS Pl_RunLength: public Pipeline
29 29 QPDF_DLL
30 30 Pl_RunLength(char const* identifier, Pipeline* next, action_e action);
31 31 QPDF_DLL
32   - virtual ~Pl_RunLength();
  32 + ~Pl_RunLength() override;
33 33  
34 34 QPDF_DLL
35   - virtual void write(unsigned char const* data, size_t len);
  35 + void write(unsigned char const* data, size_t len) override;
36 36 QPDF_DLL
37   - virtual void finish();
  37 + void finish() override;
38 38  
39 39 private:
40 40 QPDF_DLL_PRIVATE
... ...
include/qpdf/Pl_StdioFile.hh
... ... @@ -36,12 +36,12 @@ class QPDF_DLL_CLASS Pl_StdioFile: public Pipeline
36 36 QPDF_DLL
37 37 Pl_StdioFile(char const* identifier, FILE* f);
38 38 QPDF_DLL
39   - virtual ~Pl_StdioFile();
  39 + ~Pl_StdioFile() override;
40 40  
41 41 QPDF_DLL
42   - virtual void write(unsigned char const* buf, size_t len);
  42 + void write(unsigned char const* buf, size_t len) override;
43 43 QPDF_DLL
44   - virtual void finish();
  44 + void finish() override;
45 45  
46 46 private:
47 47 class QPDF_DLL_PRIVATE Members
... ...
include/qpdf/Pl_String.hh
... ... @@ -41,12 +41,12 @@ class QPDF_DLL_CLASS Pl_String: public Pipeline
41 41 QPDF_DLL
42 42 Pl_String(char const* identifier, Pipeline* next, std::string& s);
43 43 QPDF_DLL
44   - virtual ~Pl_String();
  44 + ~Pl_String() override;
45 45  
46 46 QPDF_DLL
47   - virtual void write(unsigned char const* buf, size_t len);
  47 + void write(unsigned char const* buf, size_t len) override;
48 48 QPDF_DLL
49   - virtual void finish();
  49 + void finish() override;
50 50  
51 51 private:
52 52 class QPDF_DLL_PRIVATE Members
... ...
include/qpdf/QPDF.hh
... ... @@ -942,8 +942,8 @@ class QPDF
942 942 {
943 943 public:
944 944 CopiedStreamDataProvider(QPDF& destination_qpdf);
945   - virtual ~CopiedStreamDataProvider() = default;
946   - virtual bool provideStreamData(
  945 + ~CopiedStreamDataProvider() override = default;
  946 + bool provideStreamData(
947 947 QPDFObjGen const& og,
948 948 Pipeline* pipeline,
949 949 bool suppress_warnings,
... ... @@ -963,8 +963,8 @@ class QPDF
963 963  
964 964 public:
965 965 StringDecrypter(QPDF* qpdf, QPDFObjGen const& og);
966   - virtual ~StringDecrypter() = default;
967   - virtual void decryptString(std::string& val);
  966 + ~StringDecrypter() override = default;
  967 + void decryptString(std::string& val) override;
968 968  
969 969 private:
970 970 QPDF* qpdf;
... ... @@ -1150,58 +1150,32 @@ class QPDF
1150 1150 // PDF 1.4: Table F.4
1151 1151 struct HPageOffsetEntry
1152 1152 {
1153   - HPageOffsetEntry() :
1154   - delta_nobjects(0),
1155   - delta_page_length(0),
1156   - nshared_objects(0),
1157   - delta_content_offset(0),
1158   - delta_content_length(0)
1159   - {
1160   - }
1161   -
1162   - int delta_nobjects; // 1
1163   - qpdf_offset_t delta_page_length; // 2
1164   - int nshared_objects; // 3
  1153 + int delta_nobjects{0}; // 1
  1154 + qpdf_offset_t delta_page_length{0}; // 2
1165 1155 // vectors' sizes = nshared_objects
1166   - std::vector<int> shared_identifiers; // 4
1167   - std::vector<int> shared_numerators; // 5
1168   - qpdf_offset_t delta_content_offset; // 6
1169   - qpdf_offset_t delta_content_length; // 7
  1156 + int nshared_objects{0}; // 3
  1157 + std::vector<int> shared_identifiers; // 4
  1158 + std::vector<int> shared_numerators; // 5
  1159 + qpdf_offset_t delta_content_offset{0}; // 6
  1160 + qpdf_offset_t delta_content_length{0}; // 7
1170 1161 };
1171 1162  
1172 1163 // PDF 1.4: Table F.3
1173 1164 struct HPageOffset
1174 1165 {
1175   - HPageOffset() :
1176   - min_nobjects(0),
1177   - first_page_offset(0),
1178   - nbits_delta_nobjects(0),
1179   - min_page_length(0),
1180   - nbits_delta_page_length(0),
1181   - min_content_offset(0),
1182   - nbits_delta_content_offset(0),
1183   - min_content_length(0),
1184   - nbits_delta_content_length(0),
1185   - nbits_nshared_objects(0),
1186   - nbits_shared_identifier(0),
1187   - nbits_shared_numerator(0),
1188   - shared_denominator(0)
1189   - {
1190   - }
1191   -
1192   - int min_nobjects; // 1
1193   - qpdf_offset_t first_page_offset; // 2
1194   - int nbits_delta_nobjects; // 3
1195   - int min_page_length; // 4
1196   - int nbits_delta_page_length; // 5
1197   - int min_content_offset; // 6
1198   - int nbits_delta_content_offset; // 7
1199   - int min_content_length; // 8
1200   - int nbits_delta_content_length; // 9
1201   - int nbits_nshared_objects; // 10
1202   - int nbits_shared_identifier; // 11
1203   - int nbits_shared_numerator; // 12
1204   - int shared_denominator; // 13
  1166 + int min_nobjects{0}; // 1
  1167 + qpdf_offset_t first_page_offset{0}; // 2
  1168 + int nbits_delta_nobjects{0}; // 3
  1169 + int min_page_length{0}; // 4
  1170 + int nbits_delta_page_length{0}; // 5
  1171 + int min_content_offset{0}; // 6
  1172 + int nbits_delta_content_offset{0}; // 7
  1173 + int min_content_length{0}; // 8
  1174 + int nbits_delta_content_length{0}; // 9
  1175 + int nbits_nshared_objects{0}; // 10
  1176 + int nbits_shared_identifier{0}; // 11
  1177 + int nbits_shared_numerator{0}; // 12
  1178 + int shared_denominator{0}; // 13
1205 1179 // vector size is npages
1206 1180 std::vector<HPageOffsetEntry> entries;
1207 1181 };
... ... @@ -1209,40 +1183,22 @@ class QPDF
1209 1183 // PDF 1.4: Table F.6
1210 1184 struct HSharedObjectEntry
1211 1185 {
1212   - HSharedObjectEntry() :
1213   - delta_group_length(0),
1214   - signature_present(0),
1215   - nobjects_minus_one(0)
1216   - {
1217   - }
1218   -
1219 1186 // Item 3 is a 128-bit signature (unsupported by Acrobat)
1220   - int delta_group_length; // 1
1221   - int signature_present; // 2 -- always 0
1222   - int nobjects_minus_one; // 4 -- always 0
  1187 + int delta_group_length{0}; // 1
  1188 + int signature_present{0}; // 2 -- always 0
  1189 + int nobjects_minus_one{0}; // 4 -- always 0
1223 1190 };
1224 1191  
1225 1192 // PDF 1.4: Table F.5
1226 1193 struct HSharedObject
1227 1194 {
1228   - HSharedObject() :
1229   - first_shared_obj(0),
1230   - first_shared_offset(0),
1231   - nshared_first_page(0),
1232   - nshared_total(0),
1233   - nbits_nobjects(0),
1234   - min_group_length(0),
1235   - nbits_delta_group_length(0)
1236   - {
1237   - }
1238   -
1239   - int first_shared_obj; // 1
1240   - qpdf_offset_t first_shared_offset; // 2
1241   - int nshared_first_page; // 3
1242   - int nshared_total; // 4
1243   - int nbits_nobjects; // 5
1244   - int min_group_length; // 6
1245   - int nbits_delta_group_length; // 7
  1195 + int first_shared_obj{0}; // 1
  1196 + qpdf_offset_t first_shared_offset{0}; // 2
  1197 + int nshared_first_page{0}; // 3
  1198 + int nshared_total{0}; // 4
  1199 + int nbits_nobjects{0}; // 5
  1200 + int min_group_length{0}; // 6
  1201 + int nbits_delta_group_length{0}; // 7
1246 1202 // vector size is nshared_total
1247 1203 std::vector<HSharedObjectEntry> entries;
1248 1204 };
... ... @@ -1250,18 +1206,10 @@ class QPDF
1250 1206 // PDF 1.4: Table F.9
1251 1207 struct HGeneric
1252 1208 {
1253   - HGeneric() :
1254   - first_object(0),
1255   - first_object_offset(0),
1256   - nobjects(0),
1257   - group_length(0)
1258   - {
1259   - }
1260   -
1261   - int first_object; // 1
1262   - qpdf_offset_t first_object_offset; // 2
1263   - int nobjects; // 3
1264   - int group_length; // 4
  1209 + int first_object{0}; // 1
  1210 + qpdf_offset_t first_object_offset{0}; // 2
  1211 + int nobjects{0}; // 3
  1212 + int group_length{0}; // 4
1265 1213 };
1266 1214  
1267 1215 // Other linearization data structures
... ... @@ -1269,26 +1217,14 @@ class QPDF
1269 1217 // Initialized from Linearization Parameter dictionary
1270 1218 struct LinParameters
1271 1219 {
1272   - LinParameters() :
1273   - file_size(0),
1274   - first_page_object(0),
1275   - first_page_end(0),
1276   - npages(0),
1277   - xref_zero_offset(0),
1278   - first_page(0),
1279   - H_offset(0),
1280   - H_length(0)
1281   - {
1282   - }
1283   -
1284   - qpdf_offset_t file_size; // /L
1285   - int first_page_object; // /O
1286   - qpdf_offset_t first_page_end; // /E
1287   - int npages; // /N
1288   - qpdf_offset_t xref_zero_offset; // /T
1289   - int first_page; // /P
1290   - qpdf_offset_t H_offset; // offset of primary hint stream
1291   - qpdf_offset_t H_length; // length of primary hint stream
  1220 + qpdf_offset_t file_size{0}; // /L
  1221 + int first_page_object{0}; // /O
  1222 + qpdf_offset_t first_page_end{0}; // /E
  1223 + int npages{0}; // /N
  1224 + qpdf_offset_t xref_zero_offset{0}; // /T
  1225 + int first_page{0}; // /P
  1226 + qpdf_offset_t H_offset{0}; // offset of primary hint stream
  1227 + qpdf_offset_t H_length{0}; // length of primary hint stream
1292 1228 };
1293 1229  
1294 1230 // Computed hint table value data structures. These tables contain the computed values on which
... ... @@ -1304,14 +1240,8 @@ class QPDF
1304 1240  
1305 1241 struct CHPageOffsetEntry
1306 1242 {
1307   - CHPageOffsetEntry() :
1308   - nobjects(0),
1309   - nshared_objects(0)
1310   - {
1311   - }
1312   -
1313   - int nobjects;
1314   - int nshared_objects;
  1243 + int nobjects{0};
  1244 + int nshared_objects{0};
1315 1245 // vectors' sizes = nshared_objects
1316 1246 std::vector<int> shared_identifiers;
1317 1247 };
... ... @@ -1335,16 +1265,9 @@ class QPDF
1335 1265 // PDF 1.4: Table F.5
1336 1266 struct CHSharedObject
1337 1267 {
1338   - CHSharedObject() :
1339   - first_shared_obj(0),
1340   - nshared_first_page(0),
1341   - nshared_total(0)
1342   - {
1343   - }
1344   -
1345   - int first_shared_obj;
1346   - int nshared_first_page;
1347   - int nshared_total;
  1268 + int first_shared_obj{0};
  1269 + int nshared_first_page{0};
  1270 + int nshared_total{0};
1348 1271 // vector size is nshared_total
1349 1272 std::vector<CHSharedObjectEntry> entries;
1350 1273 };
... ... @@ -1385,9 +1308,9 @@ class QPDF
1385 1308 checker(checker)
1386 1309 {
1387 1310 }
1388   - virtual ~PatternFinder() = default;
1389   - virtual bool
1390   - check()
  1311 + ~PatternFinder() override = default;
  1312 + bool
  1313 + check() override
1391 1314 {
1392 1315 return (this->qpdf.*checker)();
1393 1316 }
... ...
include/qpdf/QPDFAcroFormDocumentHelper.hh
... ... @@ -71,7 +71,7 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
71 71 QPDF_DLL
72 72 QPDFAcroFormDocumentHelper(QPDF&);
73 73 QPDF_DLL
74   - virtual ~QPDFAcroFormDocumentHelper() = default;
  74 + ~QPDFAcroFormDocumentHelper() override = default;
75 75  
76 76 // This class lazily creates an internal cache of the mapping among form fields, annotations,
77 77 // and pages. Methods within this class preserve the validity of this cache. However, if you
... ...
include/qpdf/QPDFAnnotationObjectHelper.hh
... ... @@ -30,7 +30,7 @@ class QPDFAnnotationObjectHelper: public QPDFObjectHelper
30 30 QPDF_DLL
31 31 QPDFAnnotationObjectHelper(QPDFObjectHandle);
32 32 QPDF_DLL
33   - virtual ~QPDFAnnotationObjectHelper() = default;
  33 + ~QPDFAnnotationObjectHelper() override = default;
34 34  
35 35 // This class provides helper methods for annotations. More functionality will likely be added
36 36 // in the future.
... ...
include/qpdf/QPDFEFStreamObjectHelper.hh
... ... @@ -35,7 +35,7 @@ class QPDFEFStreamObjectHelper: public QPDFObjectHelper
35 35 QPDF_DLL
36 36 QPDFEFStreamObjectHelper(QPDFObjectHandle);
37 37 QPDF_DLL
38   - virtual ~QPDFEFStreamObjectHelper() = default;
  38 + ~QPDFEFStreamObjectHelper() override = default;
39 39  
40 40 // Date parameters are strings that conform to the PDF spec for date/time strings, which is
41 41 // "D:yyyymmddhhmmss<z>" where <z> is either "Z" for UTC or "-hh'mm'" or "+hh'mm'" for timezone
... ...
include/qpdf/QPDFEmbeddedFileDocumentHelper.hh
... ... @@ -39,7 +39,7 @@ class QPDFEmbeddedFileDocumentHelper: public QPDFDocumentHelper
39 39 QPDF_DLL
40 40 QPDFEmbeddedFileDocumentHelper(QPDF&);
41 41 QPDF_DLL
42   - virtual ~QPDFEmbeddedFileDocumentHelper() = default;
  42 + ~QPDFEmbeddedFileDocumentHelper() override = default;
43 43  
44 44 QPDF_DLL
45 45 bool hasEmbeddedFiles() const;
... ...
include/qpdf/QPDFExc.hh
... ... @@ -37,7 +37,7 @@ class QPDF_DLL_CLASS QPDFExc: public std::runtime_error
37 37 qpdf_offset_t offset,
38 38 std::string const& message);
39 39 QPDF_DLL
40   - virtual ~QPDFExc() noexcept = default;
  40 + ~QPDFExc() noexcept override = default;
41 41  
42 42 // To get a complete error string, call what(), provided by std::exception. The accessors below
43 43 // return the original values used to create the exception. Only the error code and message are
... ...
include/qpdf/QPDFFileSpecObjectHelper.hh
... ... @@ -35,7 +35,7 @@ class QPDFFileSpecObjectHelper: public QPDFObjectHelper
35 35 QPDF_DLL
36 36 QPDFFileSpecObjectHelper(QPDFObjectHandle);
37 37 QPDF_DLL
38   - virtual ~QPDFFileSpecObjectHelper() = default;
  38 + ~QPDFFileSpecObjectHelper() override = default;
39 39  
40 40 QPDF_DLL
41 41 std::string getDescription();
... ...
include/qpdf/QPDFFormFieldObjectHelper.hh
... ... @@ -37,7 +37,7 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper
37 37 QPDF_DLL
38 38 QPDFFormFieldObjectHelper(QPDFObjectHandle);
39 39 QPDF_DLL
40   - virtual ~QPDFFormFieldObjectHelper() = default;
  40 + ~QPDFFormFieldObjectHelper() override = default;
41 41  
42 42 QPDF_DLL
43 43 bool isNull();
... ...
include/qpdf/QPDFJob.hh
... ... @@ -145,11 +145,6 @@ class QPDFJob
145 145  
146 146 struct AddAttachment
147 147 {
148   - AddAttachment() :
149   - replace(false)
150   - {
151   - }
152   -
153 148 std::string path;
154 149 std::string key;
155 150 std::string filename;
... ... @@ -157,7 +152,7 @@ class QPDFJob
157 152 std::string moddate;
158 153 std::string mimetype;
159 154 std::string description;
160   - bool replace;
  155 + bool replace{false};
161 156 };
162 157  
163 158 struct PageSpec
... ...
include/qpdf/QPDFNameTreeObjectHelper.hh
... ... @@ -50,7 +50,7 @@ class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper
50 50 static QPDFNameTreeObjectHelper newEmpty(QPDF&, bool auto_repair = true);
51 51  
52 52 QPDF_DLL
53   - virtual ~QPDFNameTreeObjectHelper();
  53 + ~QPDFNameTreeObjectHelper() override;
54 54  
55 55 // Return whether the name tree has an explicit entry for this name.
56 56 QPDF_DLL
... ...
include/qpdf/QPDFNumberTreeObjectHelper.hh
... ... @@ -44,7 +44,7 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper
44 44 QPDFNumberTreeObjectHelper(QPDFObjectHandle, QPDF&, bool auto_repair = true);
45 45  
46 46 QPDF_DLL
47   - virtual ~QPDFNumberTreeObjectHelper();
  47 + ~QPDFNumberTreeObjectHelper() override;
48 48  
49 49 // Create an empty number tree
50 50 QPDF_DLL
... ...
include/qpdf/QPDFObjGen.hh
... ... @@ -34,9 +34,7 @@ class QPDFObjGen
34 34 public:
35 35 // ABI: change to default.
36 36 QPDF_DLL
37   - QPDFObjGen() :
38   - obj(0),
39   - gen(0)
  37 + QPDFObjGen()
40 38 {
41 39 }
42 40 QPDF_DLL
... ...
include/qpdf/QPDFOutlineDocumentHelper.hh
... ... @@ -41,7 +41,7 @@ class QPDFOutlineDocumentHelper: public QPDFDocumentHelper
41 41 QPDF_DLL
42 42 QPDFOutlineDocumentHelper(QPDF&);
43 43 QPDF_DLL
44   - virtual ~QPDFOutlineDocumentHelper() = default;
  44 + ~QPDFOutlineDocumentHelper() override = default;
45 45  
46 46 QPDF_DLL
47 47 bool hasOutlines();
... ...
include/qpdf/QPDFOutlineObjectHelper.hh
... ... @@ -34,7 +34,7 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper
34 34 {
35 35 public:
36 36 QPDF_DLL
37   - virtual ~QPDFOutlineObjectHelper()
  37 + ~QPDFOutlineObjectHelper() override
38 38 {
39 39 // This must be cleared explicitly to avoid circular references that prevent cleanup of
40 40 // shared pointers.
... ... @@ -81,7 +81,7 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper
81 81 static QPDFOutlineObjectHelper
82 82 create(QPDFObjectHandle oh, QPDFOutlineDocumentHelper& dh, int depth)
83 83 {
84   - return QPDFOutlineObjectHelper(oh, dh, depth);
  84 + return {oh, dh, depth};
85 85 }
86 86 };
87 87  
... ...
include/qpdf/QPDFPageDocumentHelper.hh
... ... @@ -37,7 +37,7 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper
37 37 QPDF_DLL
38 38 QPDFPageDocumentHelper(QPDF&);
39 39 QPDF_DLL
40   - virtual ~QPDFPageDocumentHelper() = default;
  40 + ~QPDFPageDocumentHelper() override = default;
41 41  
42 42 // Traverse page tree, and return all /Page objects wrapped in QPDFPageObjectHelper objects.
43 43 // Unlike with QPDF::getAllPages, the vector of pages returned by this call is not affected by
... ...
include/qpdf/QPDFPageLabelDocumentHelper.hh
... ... @@ -44,7 +44,7 @@ class QPDFPageLabelDocumentHelper: public QPDFDocumentHelper
44 44 QPDF_DLL
45 45 QPDFPageLabelDocumentHelper(QPDF&);
46 46 QPDF_DLL
47   - virtual ~QPDFPageLabelDocumentHelper() = default;
  47 + ~QPDFPageLabelDocumentHelper() override = default;
48 48  
49 49 QPDF_DLL
50 50 bool hasPageLabels();
... ...
include/qpdf/QPDFPageObjectHelper.hh
... ... @@ -39,7 +39,7 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
39 39 QPDF_DLL
40 40 QPDFPageObjectHelper(QPDFObjectHandle);
41 41 QPDF_DLL
42   - virtual ~QPDFPageObjectHelper() = default;
  42 + ~QPDFPageObjectHelper() override = default;
43 43  
44 44 // PAGE ATTRIBUTES
45 45  
... ...
include/qpdf/QPDFSystemError.hh
... ... @@ -32,7 +32,7 @@ class QPDF_DLL_CLASS QPDFSystemError: public std::runtime_error
32 32 QPDF_DLL
33 33 QPDFSystemError(std::string const& description, int system_errno);
34 34 QPDF_DLL
35   - virtual ~QPDFSystemError() noexcept = default;
  35 + ~QPDFSystemError() noexcept override = default;
36 36  
37 37 // To get a complete error string, call what(), provided by std::exception. The accessors below
38 38 // return the original values used to create the exception.
... ...
include/qpdf/QPDFUsage.hh
... ... @@ -30,7 +30,7 @@ class QPDF_DLL_CLASS QPDFUsage: public std::runtime_error
30 30 QPDF_DLL
31 31 QPDFUsage(std::string const& msg);
32 32 QPDF_DLL
33   - virtual ~QPDFUsage() noexcept = default;
  33 + ~QPDFUsage() noexcept override = default;
34 34 };
35 35  
36 36 #endif // QPDFUSAGE_HH
... ...
include/qpdf/QPDFWriter.hh
... ... @@ -92,7 +92,7 @@ class QPDFWriter
92 92 QPDF_DLL
93 93 FunctionProgressReporter(std::function<void(int)>);
94 94 QPDF_DLL
95   - virtual ~FunctionProgressReporter();
  95 + ~FunctionProgressReporter() override;
96 96 QPDF_DLL
97 97 void reportProgress(int) override;
98 98  
... ...
libqpdf/ClosedFileInputSource.cc
... ... @@ -9,7 +9,7 @@ ClosedFileInputSource::ClosedFileInputSource(char const* filename) :
9 9 {
10 10 }
11 11  
12   -ClosedFileInputSource::~ClosedFileInputSource()
  12 +ClosedFileInputSource::~ClosedFileInputSource() // NOLINT (modernize-use-equals-default)
13 13 {
14 14 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
15 15 }
... ...
libqpdf/InputSource.cc
... ... @@ -37,7 +37,7 @@ InputSource::readLine(size_t max_line_length)
37 37 if (line_length < max_line_length) {
38 38 buf[line_length] = '\0';
39 39 }
40   - return std::string(buf);
  40 + return {buf};
41 41 }
42 42  
43 43 bool
... ...
libqpdf/JSON.cc
... ... @@ -269,7 +269,7 @@ JSON::encode_string(std::string const&amp; str)
269 269 JSON
270 270 JSON::makeDictionary()
271 271 {
272   - return JSON(std::make_unique<JSON_dictionary>());
  272 + return {std::make_unique<JSON_dictionary>()};
273 273 }
274 274  
275 275 JSON
... ... @@ -299,7 +299,7 @@ JSON::checkDictionaryKeySeen(std::string const&amp; key)
299 299 JSON
300 300 JSON::makeArray()
301 301 {
302   - return JSON(std::make_unique<JSON_array>());
  302 + return {std::make_unique<JSON_array>()};
303 303 }
304 304  
305 305 JSON
... ... @@ -320,43 +320,43 @@ JSON::addArrayElement(JSON const&amp; val)
320 320 JSON
321 321 JSON::makeString(std::string const& utf8)
322 322 {
323   - return JSON(std::make_unique<JSON_string>(utf8));
  323 + return {std::make_unique<JSON_string>(utf8)};
324 324 }
325 325  
326 326 JSON
327 327 JSON::makeInt(long long int value)
328 328 {
329   - return JSON(std::make_unique<JSON_number>(value));
  329 + return {std::make_unique<JSON_number>(value)};
330 330 }
331 331  
332 332 JSON
333 333 JSON::makeReal(double value)
334 334 {
335   - return JSON(std::make_unique<JSON_number>(value));
  335 + return {std::make_unique<JSON_number>(value)};
336 336 }
337 337  
338 338 JSON
339 339 JSON::makeNumber(std::string const& encoded)
340 340 {
341   - return JSON(std::make_unique<JSON_number>(encoded));
  341 + return {std::make_unique<JSON_number>(encoded)};
342 342 }
343 343  
344 344 JSON
345 345 JSON::makeBool(bool value)
346 346 {
347   - return JSON(std::make_unique<JSON_bool>(value));
  347 + return {std::make_unique<JSON_bool>(value)};
348 348 }
349 349  
350 350 JSON
351 351 JSON::makeNull()
352 352 {
353   - return JSON(std::make_unique<JSON_null>());
  353 + return {std::make_unique<JSON_null>()};
354 354 }
355 355  
356 356 JSON
357 357 JSON::makeBlob(std::function<void(Pipeline*)> fn)
358 358 {
359   - return JSON(std::make_unique<JSON_blob>(fn));
  359 + return {std::make_unique<JSON_blob>(fn)};
360 360 }
361 361  
362 362 bool
... ... @@ -588,14 +588,7 @@ namespace
588 588 JSONParser(InputSource& is, JSON::Reactor* reactor) :
589 589 is(is),
590 590 reactor(reactor),
591   - lex_state(ls_top),
592   - bytes(0),
593   - p(buf),
594   - u_count(0),
595   - offset(0),
596   - done(false),
597   - parser_state(ps_top),
598   - dict_key_offset(0)
  591 + p(buf)
599 592 {
600 593 }
601 594  
... ... @@ -665,20 +658,20 @@ namespace
665 658  
666 659 InputSource& is;
667 660 JSON::Reactor* reactor;
668   - lex_state_e lex_state;
  661 + lex_state_e lex_state{ls_top};
669 662 char buf[16384];
670   - size_t bytes;
  663 + size_t bytes{0};
671 664 char const* p;
672   - qpdf_offset_t u_count;
  665 + qpdf_offset_t u_count{0};
673 666 unsigned long u_value{0};
674   - qpdf_offset_t offset;
675   - bool done;
  667 + qpdf_offset_t offset{0};
  668 + bool done{false};
676 669 std::string token;
677 670 qpdf_offset_t token_start{0};
678   - parser_state_e parser_state;
  671 + parser_state_e parser_state{ps_top};
679 672 std::vector<StackFrame> stack;
680 673 std::string dict_key;
681   - qpdf_offset_t dict_key_offset;
  674 + qpdf_offset_t dict_key_offset{0};
682 675 };
683 676 } // namespace
684 677  
... ... @@ -1282,7 +1275,7 @@ JSONParser::handleToken()
1282 1275  
1283 1276 case ps_top:
1284 1277 if (!(item.isDictionary() || item.isArray())) {
1285   - stack.push_back({ps_done, item});
  1278 + stack.emplace_back(ps_done, item);
1286 1279 parser_state = ps_done;
1287 1280 return;
1288 1281 }
... ... @@ -1311,7 +1304,7 @@ JSONParser::handleToken()
1311 1304 }
1312 1305  
1313 1306 if (item.isDictionary() || item.isArray()) {
1314   - stack.push_back({parser_state, item});
  1307 + stack.emplace_back(parser_state, item);
1315 1308 // Calling container start method is postponed until after adding the containers to their
1316 1309 // parent containers, if any. This makes it much easier to keep track of the current nesting
1317 1310 // level.
... ...
libqpdf/NNTree.cc
... ... @@ -319,7 +319,7 @@ NNTreeIterator::split(QPDFObjectHandle to_split, std::list&lt;PathElement&gt;::iterato
319 319 auto next = this->path.begin();
320 320 next->node = first_node;
321 321 }
322   - this->path.push_front(PathElement(to_split, 0));
  322 + this->path.emplace_front(to_split, 0);
323 323 parent = this->path.begin();
324 324 to_split = first_node;
325 325 }
... ... @@ -578,7 +578,7 @@ NNTreeIterator::setItemNumber(QPDFObjectHandle const&amp; node, int n)
578 578 void
579 579 NNTreeIterator::addPathElement(QPDFObjectHandle const& node, int kid_number)
580 580 {
581   - this->path.push_back(PathElement(node, kid_number));
  581 + this->path.emplace_back(node, kid_number);
582 582 }
583 583  
584 584 bool
... ... @@ -591,7 +591,7 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
591 591 bool failed = false;
592 592  
593 593 QPDFObjGen::set seen;
594   - for (auto i: this->path) {
  594 + for (auto const& i: this->path) {
595 595 seen.add(i.node);
596 596 }
597 597 while (!failed) {
... ... @@ -689,7 +689,7 @@ NNTreeImpl::begin()
689 689 NNTreeImpl::iterator
690 690 NNTreeImpl::end()
691 691 {
692   - return iterator(*this);
  692 + return {*this};
693 693 }
694 694  
695 695 NNTreeImpl::iterator
... ...
libqpdf/Pl_Buffer.cc
... ... @@ -11,7 +11,7 @@ Pl_Buffer::Pl_Buffer(char const* identifier, Pipeline* next) :
11 11 {
12 12 }
13 13  
14   -Pl_Buffer::~Pl_Buffer()
  14 +Pl_Buffer::~Pl_Buffer() // NOLINT (modernize-use-equals-default)
15 15 {
16 16 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
17 17 }
... ...
libqpdf/Pl_Concatenate.cc
... ... @@ -5,7 +5,7 @@ Pl_Concatenate::Pl_Concatenate(char const* identifier, Pipeline* next) :
5 5 {
6 6 }
7 7  
8   -Pl_Concatenate::~Pl_Concatenate()
  8 +Pl_Concatenate::~Pl_Concatenate() // NOLINT (modernize-use-equals-default)
9 9 {
10 10 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
11 11 }
... ...
libqpdf/Pl_Count.cc
... ... @@ -14,7 +14,7 @@ Pl_Count::Pl_Count(char const* identifier, Pipeline* next) :
14 14 {
15 15 }
16 16  
17   -Pl_Count::~Pl_Count()
  17 +Pl_Count::~Pl_Count() // NOLINT (modernize-use-equals-default)
18 18 {
19 19 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
20 20 }
... ...
libqpdf/Pl_DCT.cc
... ... @@ -75,7 +75,7 @@ Pl_DCT::Pl_DCT(
75 75 {
76 76 }
77 77  
78   -Pl_DCT::~Pl_DCT()
  78 +Pl_DCT::~Pl_DCT() // NOLINT (modernize-use-equals-default)
79 79 {
80 80 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
81 81 }
... ...
libqpdf/Pl_Discard.cc
... ... @@ -7,7 +7,7 @@ Pl_Discard::Pl_Discard() :
7 7 {
8 8 }
9 9  
10   -Pl_Discard::~Pl_Discard()
  10 +Pl_Discard::~Pl_Discard() // NOLINT (modernize-use-equals-default)
11 11 {
12 12 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
13 13 }
... ...
libqpdf/Pl_Flate.cc
... ... @@ -58,7 +58,7 @@ Pl_Flate::Pl_Flate(
58 58 {
59 59 }
60 60  
61   -Pl_Flate::~Pl_Flate()
  61 +Pl_Flate::~Pl_Flate() // NOLINT (modernize-use-equals-default)
62 62 {
63 63 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
64 64 }
... ...
libqpdf/Pl_Function.cc
... ... @@ -39,7 +39,7 @@ Pl_Function::Pl_Function(char const* identifier, Pipeline* next, writer_c_char_t
39 39 };
40 40 }
41 41  
42   -Pl_Function::~Pl_Function()
  42 +Pl_Function::~Pl_Function() // NOLINT (modernize-use-equals-default)
43 43 {
44 44 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
45 45 }
... ...
libqpdf/Pl_OStream.cc
... ... @@ -13,7 +13,7 @@ Pl_OStream::Pl_OStream(char const* identifier, std::ostream&amp; os) :
13 13 {
14 14 }
15 15  
16   -Pl_OStream::~Pl_OStream()
  16 +Pl_OStream::~Pl_OStream() // NOLINT (modernize-use-equals-default)
17 17 {
18 18 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
19 19 }
... ...
libqpdf/Pl_QPDFTokenizer.cc
... ... @@ -21,7 +21,7 @@ Pl_QPDFTokenizer::Pl_QPDFTokenizer(
21 21 m->tokenizer.includeIgnorable();
22 22 }
23 23  
24   -Pl_QPDFTokenizer::~Pl_QPDFTokenizer()
  24 +Pl_QPDFTokenizer::~Pl_QPDFTokenizer() // NOLINT (modernize-use-equals-default)
25 25 {
26 26 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
27 27 }
... ...
libqpdf/Pl_RunLength.cc
... ... @@ -16,7 +16,7 @@ Pl_RunLength::Pl_RunLength(char const* identifier, Pipeline* next, action_e acti
16 16 {
17 17 }
18 18  
19   -Pl_RunLength::~Pl_RunLength()
  19 +Pl_RunLength::~Pl_RunLength() // NOLINT (modernize-use-equals-default)
20 20 {
21 21 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
22 22 }
... ...
libqpdf/Pl_StdioFile.cc
... ... @@ -17,7 +17,7 @@ Pl_StdioFile::Pl_StdioFile(char const* identifier, FILE* f) :
17 17 {
18 18 }
19 19  
20   -Pl_StdioFile::~Pl_StdioFile()
  20 +Pl_StdioFile::~Pl_StdioFile() // NOLINT (modernize-use-equals-default)
21 21 {
22 22 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
23 23 }
... ...
libqpdf/Pl_String.cc
... ... @@ -13,7 +13,7 @@ Pl_String::Pl_String(char const* identifier, Pipeline* next, std::string&amp; s) :
13 13 {
14 14 }
15 15  
16   -Pl_String::~Pl_String()
  16 +Pl_String::~Pl_String() // NOLINT (modernize-use-equals-default)
17 17 {
18 18 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
19 19 }
... ...
libqpdf/QPDF.cc
... ... @@ -840,7 +840,7 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset)
840 840 }
841 841 if (type == 'f') {
842 842 // Save deleted items until after we've checked the XRefStm, if any.
843   - deleted_items.push_back(QPDFObjGen(toI(i), f2));
  843 + deleted_items.emplace_back(toI(i), f2);
844 844 } else {
845 845 insertXrefEntry(toI(i), 1, f1, f2);
846 846 }
... ... @@ -2207,7 +2207,7 @@ QPDF::getVersionAsPDFVersion()
2207 2207 minor = QUtil::string_to_int(match[2].str().c_str());
2208 2208 }
2209 2209  
2210   - return PDFVersion(major, minor, extension_level);
  2210 + return {major, minor, extension_level};
2211 2211 }
2212 2212  
2213 2213 std::string
... ... @@ -2478,7 +2478,7 @@ QPDF::damagedPDF(
2478 2478 qpdf_offset_t offset,
2479 2479 std::string const& message)
2480 2480 {
2481   - return QPDFExc(qpdf_e_damaged_pdf, input->getName(), object, offset, message);
  2481 + return {qpdf_e_damaged_pdf, input->getName(), object, offset, message};
2482 2482 }
2483 2483  
2484 2484 // Return an exception of type qpdf_e_damaged_pdf. The object is taken from
... ... @@ -2494,7 +2494,7 @@ QPDF::damagedPDF(
2494 2494 QPDFExc
2495 2495 QPDF::damagedPDF(std::string const& object, qpdf_offset_t offset, std::string const& message)
2496 2496 {
2497   - return QPDFExc(qpdf_e_damaged_pdf, m->file->getName(), object, offset, message);
  2497 + return {qpdf_e_damaged_pdf, m->file->getName(), object, offset, message};
2498 2498 }
2499 2499  
2500 2500 // Return an exception of type qpdf_e_damaged_pdf. The filename is taken from m->file and the
... ...
libqpdf/QPDFAcroFormDocumentHelper.cc
... ... @@ -70,7 +70,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(std::vector&lt;QPDFObjectHandle&gt;
70 70 if (seen.add(obj)) {
71 71 auto kids = obj.getKey("/Kids");
72 72 if (kids.isArray()) {
73   - for (auto kid: kids.aitems()) {
  73 + for (auto const& kid: kids.aitems()) {
74 74 queue.push_back(kid);
75 75 }
76 76 }
... ... @@ -104,7 +104,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(std::vector&lt;QPDFObjectHandle&gt;
104 104 }
105 105 }
106 106  
107   - for (auto i: fields) {
  107 + for (auto const& i: fields) {
108 108 addFormField(i);
109 109 }
110 110 }
... ... @@ -165,7 +165,7 @@ QPDFAcroFormDocumentHelper::getFormFields()
165 165 analyze();
166 166 std::vector<QPDFFormFieldObjectHelper> result;
167 167 for (auto const& iter: m->field_to_annotations) {
168   - result.push_back(this->qpdf.getObject(iter.first));
  168 + result.emplace_back(this->qpdf.getObject(iter.first));
169 169 }
170 170 return result;
171 171 }
... ... @@ -279,7 +279,7 @@ QPDFAcroFormDocumentHelper::analyze()
279 279 annot.warnIfPossible("this widget annotation is not"
280 280 " reachable from /AcroForm in the document catalog");
281 281 m->annotation_to_field[og] = QPDFFormFieldObjectHelper(annot);
282   - m->field_to_annotations[og].push_back(QPDFAnnotationObjectHelper(annot));
  282 + m->field_to_annotations[og].emplace_back(annot);
283 283 }
284 284 }
285 285 }
... ... @@ -342,7 +342,7 @@ QPDFAcroFormDocumentHelper::traverseField(
342 342  
343 343 if (is_annotation) {
344 344 QPDFObjectHandle our_field = (is_field ? field : parent);
345   - m->field_to_annotations[our_field.getObjGen()].push_back(QPDFAnnotationObjectHelper(field));
  345 + m->field_to_annotations[our_field.getObjGen()].emplace_back(field);
346 346 m->annotation_to_field[og] = QPDFFormFieldObjectHelper(our_field);
347 347 }
348 348  
... ... @@ -469,19 +469,18 @@ namespace
469 469 ResourceReplacer(
470 470 std::map<std::string, std::map<std::string, std::string>> const& dr_map,
471 471 std::map<std::string, std::map<std::string, std::set<size_t>>> const& rnames);
472   - virtual ~ResourceReplacer() = default;
473   - virtual void handleToken(QPDFTokenizer::Token const&) override;
  472 + ~ResourceReplacer() override = default;
  473 + void handleToken(QPDFTokenizer::Token const&) override;
474 474  
475 475 private:
476   - size_t offset;
  476 + size_t offset{0};
477 477 std::map<std::string, std::map<size_t, std::string>> to_replace;
478 478 };
479 479 } // namespace
480 480  
481 481 ResourceReplacer::ResourceReplacer(
482 482 std::map<std::string, std::map<std::string, std::string>> const& dr_map,
483   - std::map<std::string, std::map<std::string, std::set<size_t>>> const& rnames) :
484   - offset(0)
  483 + std::map<std::string, std::map<std::string, std::set<size_t>>> const& rnames)
485 484 {
486 485 // We have:
487 486 // * dr_map[resource_type][key] == new_key
... ... @@ -1019,7 +1018,7 @@ QPDFAcroFormDocumentHelper::fixCopiedAnnotations(
1019 1018 to_page.replaceKey("/Annots", QPDFObjectHandle::newArray(new_annots));
1020 1019 addAndRenameFormFields(new_fields);
1021 1020 if (added_fields) {
1022   - for (auto f: new_fields) {
  1021 + for (auto const& f: new_fields) {
1023 1022 added_fields->insert(f.getObjGen());
1024 1023 }
1025 1024 }
... ...
libqpdf/QPDFCrypto_openssl.cc
... ... @@ -194,7 +194,7 @@ QPDFCrypto_openssl::MD5_digest(MD5_Digest d)
194 194 std::string
195 195 QPDFCrypto_openssl::SHA2_digest()
196 196 {
197   - return std::string(reinterpret_cast<char*>(md_out), sha2_bits / 8);
  197 + return {reinterpret_cast<char*>(md_out), sha2_bits / 8};
198 198 }
199 199  
200 200 void
... ...
libqpdf/QPDFDocumentHelper.cc
1 1 #include <qpdf/QPDFDocumentHelper.hh>
2 2  
3   -QPDFDocumentHelper::~QPDFDocumentHelper()
  3 +QPDFDocumentHelper::~QPDFDocumentHelper() // NOLINT (modernize-use-equals-default)
4 4 {
5 5 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
6 6 }
... ...
libqpdf/QPDFFormFieldObjectHelper.cc
... ... @@ -481,8 +481,8 @@ namespace
481 481 std::vector<std::string> opt;
482 482 double tf;
483 483 QPDFObjectHandle::Rectangle bbox;
484   - enum { st_top, st_bmc, st_emc, st_end } state;
485   - bool replaced;
  484 + enum { st_top, st_bmc, st_emc, st_end } state{st_top};
  485 + bool replaced{false};
486 486 };
487 487 } // namespace
488 488  
... ... @@ -496,9 +496,7 @@ ValueSetter::ValueSetter(
496 496 V(V),
497 497 opt(opt),
498 498 tf(tf),
499   - bbox(bbox),
500   - state(st_top),
501   - replaced(false)
  499 + bbox(bbox)
502 500 {
503 501 }
504 502  
... ... @@ -649,34 +647,24 @@ namespace
649 647 class TfFinder: public QPDFObjectHandle::TokenFilter
650 648 {
651 649 public:
652   - TfFinder();
653   - ~TfFinder() override
654   - {
655   - }
  650 + TfFinder() = default;
  651 + ~TfFinder() override = default;
656 652 void handleToken(QPDFTokenizer::Token const&) override;
657 653 double getTf();
658 654 std::string getFontName();
659 655 std::string getDA();
660 656  
661 657 private:
662   - double tf;
663   - int tf_idx;
  658 + double tf{11.0};
  659 + int tf_idx{-1};
664 660 std::string font_name;
665   - double last_num;
666   - int last_num_idx;
  661 + double last_num{0.0};
  662 + int last_num_idx{-1};
667 663 std::string last_name;
668 664 std::vector<std::string> DA;
669 665 };
670 666 } // namespace
671 667  
672   -TfFinder::TfFinder() :
673   - tf(11.0),
674   - tf_idx(-1),
675   - last_num(0.0),
676   - last_num_idx(-1)
677   -{
678   -}
679   -
680 668 void
681 669 TfFinder::handleToken(QPDFTokenizer::Token const& token)
682 670 {
... ...
libqpdf/QPDFJob.cc
... ... @@ -428,7 +428,7 @@ QPDFJob::parseNumrange(char const* range, int max)
428 428 } catch (std::runtime_error& e) {
429 429 usage(e.what());
430 430 }
431   - return std::vector<int>();
  431 + return {};
432 432 }
433 433  
434 434 std::unique_ptr<QPDF>
... ... @@ -894,7 +894,7 @@ QPDFJob::doListAttachments(QPDF&amp; pdf)
894 894 v << " " << i2.first << " -> " << i2.second << "\n";
895 895 }
896 896 v << " all data streams:\n";
897   - for (auto i2: efoh->getEmbeddedFileStreams().ditems()) {
  897 + for (auto const& i2: efoh->getEmbeddedFileStreams().ditems()) {
898 898 auto efs = QPDFEFStreamObjectHelper(i2.second);
899 899 v << " " << i2.first << " -> "
900 900 << efs.getObjectHandle().getObjGen().unparse(',') << "\n";
... ... @@ -1329,7 +1329,7 @@ QPDFJob::doJSONAttachments(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1329 1329 j_names.addDictionaryMember(i2.first, JSON::makeString(i2.second));
1330 1330 }
1331 1331 auto j_streams = j_details.addDictionaryMember("streams", JSON::makeDictionary());
1332   - for (auto i2: fsoh->getEmbeddedFileStreams().ditems()) {
  1332 + for (auto const& i2: fsoh->getEmbeddedFileStreams().ditems()) {
1333 1333 auto efs = QPDFEFStreamObjectHelper(i2.second);
1334 1334 auto j_stream = j_streams.addDictionaryMember(i2.first, JSON::makeDictionary());
1335 1335 j_stream.addDictionaryMember(
... ... @@ -2376,9 +2376,8 @@ QPDFJob::handlePageSpecs(QPDF&amp; pdf, std::vector&lt;std::unique_ptr&lt;QPDF&gt;&gt;&amp; page_hea
2376 2376  
2377 2377 // Read original pages from the PDF, and parse the page range associated with this
2378 2378 // occurrence of the file.
2379   - parsed_specs.push_back(
2380   - // line-break
2381   - QPDFPageData(page_spec.filename, page_spec_qpdfs[page_spec.filename], page_spec.range));
  2379 + parsed_specs.emplace_back(
  2380 + page_spec.filename, page_spec_qpdfs[page_spec.filename], page_spec.range);
2382 2381 }
2383 2382  
2384 2383 std::map<unsigned long long, bool> remove_unreferenced;
... ... @@ -2427,9 +2426,8 @@ QPDFJob::handlePageSpecs(QPDF&amp; pdf, std::vector&lt;std::unique_ptr&lt;QPDF&gt;&gt;&amp; page_hea
2427 2426 for (size_t j = 0; j < m->collate; ++j) {
2428 2427 if (cur_page + j < page_data.selected_pages.size()) {
2429 2428 got_pages = true;
2430   - new_parsed_specs.push_back(
2431   - // line-break
2432   - QPDFPageData(page_data, page_data.selected_pages.at(cur_page + j)));
  2429 + new_parsed_specs.emplace_back(
  2430 + page_data, page_data.selected_pages.at(cur_page + j));
2433 2431 }
2434 2432 }
2435 2433 }
... ...
libqpdf/QPDFJob_argv.cc
... ... @@ -40,18 +40,15 @@ namespace
40 40 std::shared_ptr<QPDFJob::UOConfig> c_uo;
41 41 std::shared_ptr<QPDFJob::EncConfig> c_enc;
42 42 std::vector<std::string> accumulated_args;
43   - std::shared_ptr<char> pages_password;
44   - bool gave_input;
45   - bool gave_output;
  43 + std::shared_ptr<char> pages_password{nullptr};
  44 + bool gave_input{false};
  45 + bool gave_output{false};
46 46 };
47 47 } // namespace
48 48  
49 49 ArgParser::ArgParser(QPDFArgParser& ap, std::shared_ptr<QPDFJob::Config> c_main) :
50 50 ap(ap),
51   - c_main(c_main),
52   - pages_password(nullptr),
53   - gave_input(false),
54   - gave_output(false)
  51 + c_main(c_main)
55 52 {
56 53 initOptionTables();
57 54 }
... ...
libqpdf/QPDFJob_config.cc
... ... @@ -942,7 +942,7 @@ QPDFJob::PagesConfig*
942 942 QPDFJob::PagesConfig::pageSpec(
943 943 std::string const& filename, std::string const& range, char const* password)
944 944 {
945   - this->config->o.m->page_specs.push_back(QPDFJob::PageSpec(filename, password, range));
  945 + this->config->o.m->page_specs.emplace_back(filename, password, range);
946 946 return this;
947 947 }
948 948  
... ...
libqpdf/QPDFJob_json.cc
... ... @@ -59,7 +59,7 @@ namespace
59 59  
60 60 std::list<std::shared_ptr<JSONHandler>> json_handlers;
61 61 bool partial;
62   - JSONHandler* jh; // points to last of json_handlers
  62 + JSONHandler* jh{nullptr}; // points to last of json_handlers
63 63 std::shared_ptr<QPDFJob::Config> c_main;
64 64 std::shared_ptr<QPDFJob::CopyAttConfig> c_copy_att;
65 65 std::shared_ptr<QPDFJob::AttConfig> c_att;
... ... @@ -71,7 +71,6 @@ namespace
71 71  
72 72 Handlers::Handlers(bool partial, std::shared_ptr<QPDFJob::Config> c_main) :
73 73 partial(partial),
74   - jh(nullptr),
75 74 c_main(c_main)
76 75 {
77 76 initHandlers();
... ...
libqpdf/QPDFLogger.cc
... ... @@ -12,8 +12,7 @@ namespace
12 12 {
13 13 public:
14 14 Pl_Track(char const* identifier, Pipeline* next) :
15   - Pipeline(identifier, next),
16   - used(false)
  15 + Pipeline(identifier, next)
17 16 {
18 17 }
19 18  
... ... @@ -37,7 +36,7 @@ namespace
37 36 }
38 37  
39 38 private:
40   - bool used;
  39 + bool used{false};
41 40 };
42 41 }; // namespace
43 42  
... ...
libqpdf/QPDFMatrix.cc
... ... @@ -57,7 +57,7 @@ QPDFMatrix::unparse() const
57 57 QPDFObjectHandle::Matrix
58 58 QPDFMatrix::getAsMatrix() const
59 59 {
60   - return QPDFObjectHandle::Matrix(a, b, c, d, e, f);
  60 + return {a, b, c, d, e, f};
61 61 }
62 62  
63 63 void
... ... @@ -124,11 +124,11 @@ QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r) const
124 124 transform(r.llx, r.ury, tx.at(1), ty.at(1));
125 125 transform(r.urx, r.lly, tx.at(2), ty.at(2));
126 126 transform(r.urx, r.ury, tx.at(3), ty.at(3));
127   - return QPDFObjectHandle::Rectangle(
  127 + return {
128 128 *std::min_element(tx.begin(), tx.end()),
129 129 *std::min_element(ty.begin(), ty.end()),
130 130 *std::max_element(tx.begin(), tx.end()),
131   - *std::max_element(ty.begin(), ty.end()));
  131 + *std::max_element(ty.begin(), ty.end())};
132 132 }
133 133  
134 134 bool
... ...
libqpdf/QPDFNameTreeObjectHelper.cc
... ... @@ -34,7 +34,7 @@ namespace
34 34  
35 35 static NameTreeDetails name_tree_details;
36 36  
37   -QPDFNameTreeObjectHelper::~QPDFNameTreeObjectHelper()
  37 +QPDFNameTreeObjectHelper::~QPDFNameTreeObjectHelper() // NOLINT (modernize-use-equals-default)
38 38 {
39 39 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer. For this specific
40 40 // class, see github issue #745.
... ... @@ -54,8 +54,7 @@ QPDFNameTreeObjectHelper::QPDFNameTreeObjectHelper(QPDFObjectHandle oh, QPDF&amp; q,
54 54 QPDFNameTreeObjectHelper
55 55 QPDFNameTreeObjectHelper::newEmpty(QPDF& qpdf, bool auto_repair)
56 56 {
57   - return QPDFNameTreeObjectHelper(
58   - qpdf.makeIndirectObject("<< /Names [] >>"_qpdf), qpdf, auto_repair);
  57 + return {qpdf.makeIndirectObject("<< /Names [] >>"_qpdf), qpdf, auto_repair};
59 58 }
60 59  
61 60 QPDFNameTreeObjectHelper::iterator::iterator(std::shared_ptr<NNTreeIterator> const& i) :
... ... @@ -135,33 +134,33 @@ QPDFNameTreeObjectHelper::iterator::remove()
135 134 QPDFNameTreeObjectHelper::iterator
136 135 QPDFNameTreeObjectHelper::begin() const
137 136 {
138   - return iterator(std::make_shared<NNTreeIterator>(m->impl->begin()));
  137 + return {std::make_shared<NNTreeIterator>(m->impl->begin())};
139 138 }
140 139  
141 140 QPDFNameTreeObjectHelper::iterator
142 141 QPDFNameTreeObjectHelper::end() const
143 142 {
144   - return iterator(std::make_shared<NNTreeIterator>(m->impl->end()));
  143 + return {std::make_shared<NNTreeIterator>(m->impl->end())};
145 144 }
146 145  
147 146 QPDFNameTreeObjectHelper::iterator
148 147 QPDFNameTreeObjectHelper::last() const
149 148 {
150   - return iterator(std::make_shared<NNTreeIterator>(m->impl->last()));
  149 + return {std::make_shared<NNTreeIterator>(m->impl->last())};
151 150 }
152 151  
153 152 QPDFNameTreeObjectHelper::iterator
154 153 QPDFNameTreeObjectHelper::find(std::string const& key, bool return_prev_if_not_found)
155 154 {
156 155 auto i = m->impl->find(QPDFObjectHandle::newUnicodeString(key), return_prev_if_not_found);
157   - return iterator(std::make_shared<NNTreeIterator>(i));
  156 + return {std::make_shared<NNTreeIterator>(i)};
158 157 }
159 158  
160 159 QPDFNameTreeObjectHelper::iterator
161 160 QPDFNameTreeObjectHelper::insert(std::string const& key, QPDFObjectHandle value)
162 161 {
163 162 auto i = m->impl->insert(QPDFObjectHandle::newUnicodeString(key), value);
164   - return iterator(std::make_shared<NNTreeIterator>(i));
  163 + return {std::make_shared<NNTreeIterator>(i)};
165 164 }
166 165  
167 166 bool
... ...
libqpdf/QPDFNumberTreeObjectHelper.cc
... ... @@ -35,7 +35,7 @@ namespace
35 35  
36 36 static NumberTreeDetails number_tree_details;
37 37  
38   -QPDFNumberTreeObjectHelper::~QPDFNumberTreeObjectHelper()
  38 +QPDFNumberTreeObjectHelper::~QPDFNumberTreeObjectHelper() // NOLINT (modernize-use-equals-default)
39 39 {
40 40 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer. For this specific
41 41 // class, see github issue #745.
... ... @@ -56,8 +56,7 @@ QPDFNumberTreeObjectHelper::QPDFNumberTreeObjectHelper(
56 56 QPDFNumberTreeObjectHelper
57 57 QPDFNumberTreeObjectHelper::newEmpty(QPDF& qpdf, bool auto_repair)
58 58 {
59   - return QPDFNumberTreeObjectHelper(
60   - qpdf.makeIndirectObject("<< /Nums [] >>"_qpdf), qpdf, auto_repair);
  59 + return {qpdf.makeIndirectObject("<< /Nums [] >>"_qpdf), qpdf, auto_repair};
61 60 }
62 61  
63 62 QPDFNumberTreeObjectHelper::iterator::iterator(std::shared_ptr<NNTreeIterator> const& i) :
... ... @@ -137,33 +136,33 @@ QPDFNumberTreeObjectHelper::iterator::remove()
137 136 QPDFNumberTreeObjectHelper::iterator
138 137 QPDFNumberTreeObjectHelper::begin() const
139 138 {
140   - return iterator(std::make_shared<NNTreeIterator>(m->impl->begin()));
  139 + return {std::make_shared<NNTreeIterator>(m->impl->begin())};
141 140 }
142 141  
143 142 QPDFNumberTreeObjectHelper::iterator
144 143 QPDFNumberTreeObjectHelper::end() const
145 144 {
146   - return iterator(std::make_shared<NNTreeIterator>(m->impl->end()));
  145 + return {std::make_shared<NNTreeIterator>(m->impl->end())};
147 146 }
148 147  
149 148 QPDFNumberTreeObjectHelper::iterator
150 149 QPDFNumberTreeObjectHelper::last() const
151 150 {
152   - return iterator(std::make_shared<NNTreeIterator>(m->impl->last()));
  151 + return {std::make_shared<NNTreeIterator>(m->impl->last())};
153 152 }
154 153  
155 154 QPDFNumberTreeObjectHelper::iterator
156 155 QPDFNumberTreeObjectHelper::find(numtree_number key, bool return_prev_if_not_found)
157 156 {
158 157 auto i = m->impl->find(QPDFObjectHandle::newInteger(key), return_prev_if_not_found);
159   - return iterator(std::make_shared<NNTreeIterator>(i));
  158 + return {std::make_shared<NNTreeIterator>(i)};
160 159 }
161 160  
162 161 QPDFNumberTreeObjectHelper::iterator
163 162 QPDFNumberTreeObjectHelper::insert(numtree_number key, QPDFObjectHandle value)
164 163 {
165 164 auto i = m->impl->insert(QPDFObjectHandle::newInteger(key), value);
166   - return iterator(std::make_shared<NNTreeIterator>(i));
  165 + return {std::make_shared<NNTreeIterator>(i)};
167 166 }
168 167  
169 168 bool
... ...
libqpdf/QPDFObjectHandle.cc
... ... @@ -49,7 +49,7 @@ QPDFObjectHandle::StreamDataProvider::StreamDataProvider(bool supports_retry) :
49 49 {
50 50 }
51 51  
52   -QPDFObjectHandle::StreamDataProvider::~StreamDataProvider()
  52 +QPDFObjectHandle::StreamDataProvider::~StreamDataProvider() // NOLINT (modernize-use-equals-default)
53 53 {
54 54 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
55 55 }
... ... @@ -189,13 +189,12 @@ namespace
189 189 unsigned char getLastChar();
190 190  
191 191 private:
192   - unsigned char last_char;
  192 + unsigned char last_char{0};
193 193 };
194 194 } // namespace
195 195  
196 196 LastChar::LastChar(Pipeline* next) :
197   - Pipeline("lastchar", next),
198   - last_char(0)
  197 + Pipeline("lastchar", next)
199 198 {
200 199 }
201 200  
... ... @@ -752,7 +751,7 @@ QPDFObjectHandle::getValueAsInlineImage(std::string&amp; value)
752 751 QPDFObjectHandle::QPDFArrayItems
753 752 QPDFObjectHandle::aitems()
754 753 {
755   - return QPDFArrayItems(*this);
  754 + return *this;
756 755 }
757 756  
758 757 int
... ... @@ -826,11 +825,11 @@ QPDFObjectHandle::getArrayAsRectangle()
826 825 return {};
827 826 }
828 827 }
829   - return Rectangle(
  828 + return {
830 829 std::min(items[0], items[2]),
831 830 std::min(items[1], items[3]),
832 831 std::max(items[0], items[2]),
833   - std::max(items[1], items[3]));
  832 + std::max(items[1], items[3])};
834 833 }
835 834 return {};
836 835 }
... ... @@ -848,7 +847,7 @@ QPDFObjectHandle::getArrayAsMatrix()
848 847 return {};
849 848 }
850 849 }
851   - return Matrix(items[0], items[1], items[2], items[3], items[4], items[5]);
  850 + return {items[0], items[1], items[2], items[3], items[4], items[5]};
852 851 }
853 852 return {};
854 853 }
... ... @@ -959,7 +958,7 @@ QPDFObjectHandle::eraseItemAndGetOld(int at)
959 958 QPDFObjectHandle::QPDFDictItems
960 959 QPDFObjectHandle::ditems()
961 960 {
962   - return QPDFDictItems(*this);
  961 + return {*this};
963 962 }
964 963  
965 964 bool
... ... @@ -1049,7 +1048,7 @@ QPDFObjectHandle::makeResourcesIndirect(QPDF&amp; owning_qpdf)
1049 1048 if (!sub.isDictionary()) {
1050 1049 continue;
1051 1050 }
1052   - for (auto i2: sub.ditems()) {
  1051 + for (auto const& i2: sub.ditems()) {
1053 1052 std::string const& key = i2.first;
1054 1053 QPDFObjectHandle val = i2.second;
1055 1054 if (!val.isIndirect()) {
... ... @@ -1070,7 +1069,7 @@ QPDFObjectHandle::mergeResources(
1070 1069  
1071 1070 auto make_og_to_name = [](QPDFObjectHandle& dict,
1072 1071 std::map<QPDFObjGen, std::string>& og_to_name) {
1073   - for (auto i: dict.ditems()) {
  1072 + for (auto const& i: dict.ditems()) {
1074 1073 if (i.second.isIndirect()) {
1075 1074 og_to_name[i.second.getObjGen()] = i.first;
1076 1075 }
... ... @@ -1079,7 +1078,7 @@ QPDFObjectHandle::mergeResources(
1079 1078  
1080 1079 // This algorithm is described in comments in QPDFObjectHandle.hh
1081 1080 // above the declaration of mergeResources.
1082   - for (auto o_top: other.ditems()) {
  1081 + for (auto const& o_top: other.ditems()) {
1083 1082 std::string const& rtype = o_top.first;
1084 1083 QPDFObjectHandle other_val = o_top.second;
1085 1084 if (hasKey(rtype)) {
... ... @@ -1096,7 +1095,7 @@ QPDFObjectHandle::mergeResources(
1096 1095 std::set<std::string> rnames;
1097 1096 int min_suffix = 1;
1098 1097 bool initialized_maps = false;
1099   - for (auto ov_iter: other_val.ditems()) {
  1098 + for (auto const& ov_iter: other_val.ditems()) {
1100 1099 std::string const& key = ov_iter.first;
1101 1100 QPDFObjectHandle rval = ov_iter.second;
1102 1101 if (!this_val.hasKey(key)) {
... ... @@ -1862,61 +1861,61 @@ QPDFObjectHandle::getParsedOffset()
1862 1861 QPDFObjectHandle
1863 1862 QPDFObjectHandle::newBool(bool value)
1864 1863 {
1865   - return QPDFObjectHandle(QPDF_Bool::create(value));
  1864 + return {QPDF_Bool::create(value)};
1866 1865 }
1867 1866  
1868 1867 QPDFObjectHandle
1869 1868 QPDFObjectHandle::newNull()
1870 1869 {
1871   - return QPDFObjectHandle(QPDF_Null::create());
  1870 + return {QPDF_Null::create()};
1872 1871 }
1873 1872  
1874 1873 QPDFObjectHandle
1875 1874 QPDFObjectHandle::newInteger(long long value)
1876 1875 {
1877   - return QPDFObjectHandle(QPDF_Integer::create(value));
  1876 + return {QPDF_Integer::create(value)};
1878 1877 }
1879 1878  
1880 1879 QPDFObjectHandle
1881 1880 QPDFObjectHandle::newReal(std::string const& value)
1882 1881 {
1883   - return QPDFObjectHandle(QPDF_Real::create(value));
  1882 + return {QPDF_Real::create(value)};
1884 1883 }
1885 1884  
1886 1885 QPDFObjectHandle
1887 1886 QPDFObjectHandle::newReal(double value, int decimal_places, bool trim_trailing_zeroes)
1888 1887 {
1889   - return QPDFObjectHandle(QPDF_Real::create(value, decimal_places, trim_trailing_zeroes));
  1888 + return {QPDF_Real::create(value, decimal_places, trim_trailing_zeroes)};
1890 1889 }
1891 1890  
1892 1891 QPDFObjectHandle
1893 1892 QPDFObjectHandle::newName(std::string const& name)
1894 1893 {
1895   - return QPDFObjectHandle(QPDF_Name::create(name));
  1894 + return {QPDF_Name::create(name)};
1896 1895 }
1897 1896  
1898 1897 QPDFObjectHandle
1899 1898 QPDFObjectHandle::newString(std::string const& str)
1900 1899 {
1901   - return QPDFObjectHandle(QPDF_String::create(str));
  1900 + return {QPDF_String::create(str)};
1902 1901 }
1903 1902  
1904 1903 QPDFObjectHandle
1905 1904 QPDFObjectHandle::newUnicodeString(std::string const& utf8_str)
1906 1905 {
1907   - return QPDFObjectHandle(QPDF_String::create_utf16(utf8_str));
  1906 + return {QPDF_String::create_utf16(utf8_str)};
1908 1907 }
1909 1908  
1910 1909 QPDFObjectHandle
1911 1910 QPDFObjectHandle::newOperator(std::string const& value)
1912 1911 {
1913   - return QPDFObjectHandle(QPDF_Operator::create(value));
  1912 + return {QPDF_Operator::create(value)};
1914 1913 }
1915 1914  
1916 1915 QPDFObjectHandle
1917 1916 QPDFObjectHandle::newInlineImage(std::string const& value)
1918 1917 {
1919   - return QPDFObjectHandle(QPDF_InlineImage::create(value));
  1918 + return {QPDF_InlineImage::create(value)};
1920 1919 }
1921 1920  
1922 1921 QPDFObjectHandle
... ... @@ -1928,44 +1927,37 @@ QPDFObjectHandle::newArray()
1928 1927 QPDFObjectHandle
1929 1928 QPDFObjectHandle::newArray(std::vector<QPDFObjectHandle> const& items)
1930 1929 {
1931   - return QPDFObjectHandle(QPDF_Array::create(items));
  1930 + return {QPDF_Array::create(items)};
1932 1931 }
1933 1932  
1934 1933 QPDFObjectHandle
1935 1934 QPDFObjectHandle::newArray(Rectangle const& rect)
1936 1935 {
1937   - std::vector<QPDFObjectHandle> items;
1938   - items.push_back(newReal(rect.llx));
1939   - items.push_back(newReal(rect.lly));
1940   - items.push_back(newReal(rect.urx));
1941   - items.push_back(newReal(rect.ury));
1942   - return newArray(items);
  1936 + return newArray({newReal(rect.llx), newReal(rect.lly), newReal(rect.urx), newReal(rect.ury)});
1943 1937 }
1944 1938  
1945 1939 QPDFObjectHandle
1946 1940 QPDFObjectHandle::newArray(Matrix const& matrix)
1947 1941 {
1948   - std::vector<QPDFObjectHandle> items;
1949   - items.push_back(newReal(matrix.a));
1950   - items.push_back(newReal(matrix.b));
1951   - items.push_back(newReal(matrix.c));
1952   - items.push_back(newReal(matrix.d));
1953   - items.push_back(newReal(matrix.e));
1954   - items.push_back(newReal(matrix.f));
1955   - return newArray(items);
  1942 + return newArray(
  1943 + {newReal(matrix.a),
  1944 + newReal(matrix.b),
  1945 + newReal(matrix.c),
  1946 + newReal(matrix.d),
  1947 + newReal(matrix.e),
  1948 + newReal(matrix.f)});
1956 1949 }
1957 1950  
1958 1951 QPDFObjectHandle
1959 1952 QPDFObjectHandle::newArray(QPDFMatrix const& matrix)
1960 1953 {
1961   - std::vector<QPDFObjectHandle> items;
1962   - items.push_back(newReal(matrix.a));
1963   - items.push_back(newReal(matrix.b));
1964   - items.push_back(newReal(matrix.c));
1965   - items.push_back(newReal(matrix.d));
1966   - items.push_back(newReal(matrix.e));
1967   - items.push_back(newReal(matrix.f));
1968   - return newArray(items);
  1954 + return newArray(
  1955 + {newReal(matrix.a),
  1956 + newReal(matrix.b),
  1957 + newReal(matrix.c),
  1958 + newReal(matrix.d),
  1959 + newReal(matrix.e),
  1960 + newReal(matrix.f)});
1969 1961 }
1970 1962  
1971 1963 QPDFObjectHandle
... ... @@ -1995,7 +1987,7 @@ QPDFObjectHandle::newDictionary()
1995 1987 QPDFObjectHandle
1996 1988 QPDFObjectHandle::newDictionary(std::map<std::string, QPDFObjectHandle> const& items)
1997 1989 {
1998   - return QPDFObjectHandle(QPDF_Dictionary::create(items));
  1990 + return {QPDF_Dictionary::create(items)};
1999 1991 }
2000 1992  
2001 1993 QPDFObjectHandle
... ... @@ -2060,7 +2052,7 @@ QPDFObjectHandle::shallowCopy()
2060 2052 if (!dereference()) {
2061 2053 throw std::logic_error("operation attempted on uninitialized QPDFObjectHandle");
2062 2054 }
2063   - return QPDFObjectHandle(obj->copy());
  2055 + return {obj->copy()};
2064 2056 }
2065 2057  
2066 2058 QPDFObjectHandle
... ... @@ -2069,7 +2061,7 @@ QPDFObjectHandle::unsafeShallowCopy()
2069 2061 if (!dereference()) {
2070 2062 throw std::logic_error("operation attempted on uninitialized QPDFObjectHandle");
2071 2063 }
2072   - return QPDFObjectHandle(obj->copy(true));
  2064 + return {obj->copy(true)};
2073 2065 }
2074 2066  
2075 2067 void
... ... @@ -2471,13 +2463,13 @@ QPDFObjectHandle::QPDFDictItems::iterator::Members::Members(QPDFObjectHandle&amp; oh
2471 2463 QPDFObjectHandle::QPDFDictItems::iterator
2472 2464 QPDFObjectHandle::QPDFDictItems::begin()
2473 2465 {
2474   - return iterator(oh, true);
  2466 + return {oh, true};
2475 2467 }
2476 2468  
2477 2469 QPDFObjectHandle::QPDFDictItems::iterator
2478 2470 QPDFObjectHandle::QPDFDictItems::end()
2479 2471 {
2480   - return iterator(oh, false);
  2472 + return {oh, false};
2481 2473 }
2482 2474  
2483 2475 QPDFObjectHandle::QPDFArrayItems::QPDFArrayItems(QPDFObjectHandle const& oh) :
... ... @@ -2551,13 +2543,13 @@ QPDFObjectHandle::QPDFArrayItems::iterator::Members::Members(QPDFObjectHandle&amp; o
2551 2543 QPDFObjectHandle::QPDFArrayItems::iterator
2552 2544 QPDFObjectHandle::QPDFArrayItems::begin()
2553 2545 {
2554   - return iterator(oh, true);
  2546 + return {oh, true};
2555 2547 }
2556 2548  
2557 2549 QPDFObjectHandle::QPDFArrayItems::iterator
2558 2550 QPDFObjectHandle::QPDFArrayItems::end()
2559 2551 {
2560   - return iterator(oh, false);
  2552 + return {oh, false};
2561 2553 }
2562 2554  
2563 2555 QPDFObjGen
... ...
libqpdf/QPDFObjectHelper.cc
1 1 #include <qpdf/QPDFObjectHelper.hh>
2 2  
3   -QPDFObjectHelper::~QPDFObjectHelper()
  3 +QPDFObjectHelper::~QPDFObjectHelper() // NOLINT (modernize-use-equals-default)
4 4 {
5 5 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
6 6 }
... ...
libqpdf/QPDFPageDocumentHelper.cc
... ... @@ -14,7 +14,7 @@ QPDFPageDocumentHelper::getAllPages()
14 14 {
15 15 std::vector<QPDFPageObjectHelper> pages;
16 16 for (auto const& iter: this->qpdf.getAllPages()) {
17   - pages.push_back(QPDFPageObjectHelper(iter));
  17 + pages.emplace_back(iter);
18 18 }
19 19 return pages;
20 20 }
... ...
libqpdf/QPDFPageObjectHelper.cc
... ... @@ -20,8 +20,8 @@ namespace
20 20 from_page(from_page)
21 21 {
22 22 }
23   - virtual ~ContentProvider() = default;
24   - virtual void provideStreamData(QPDFObjGen const&, Pipeline* pipeline);
  23 + ~ContentProvider() override = default;
  24 + void provideStreamData(QPDFObjGen const&, Pipeline* pipeline) override;
25 25  
26 26 private:
27 27 QPDFObjectHandle from_page;
... ... @@ -44,8 +44,8 @@ namespace
44 44 {
45 45 public:
46 46 InlineImageTracker(QPDF*, size_t min_size, QPDFObjectHandle resources);
47   - virtual ~InlineImageTracker() = default;
48   - virtual void handleToken(QPDFTokenizer::Token const&);
  47 + ~InlineImageTracker() override = default;
  48 + void handleToken(QPDFTokenizer::Token const&) override;
49 49 QPDFObjectHandle convertIIDict(QPDFObjectHandle odict);
50 50  
51 51 QPDF* qpdf;
... ... @@ -53,19 +53,16 @@ namespace
53 53 QPDFObjectHandle resources;
54 54 std::string dict_str;
55 55 std::string bi_str;
56   - int min_suffix;
57   - bool any_images;
58   - enum { st_top, st_bi } state;
  56 + int min_suffix{1};
  57 + bool any_images{false};
  58 + enum { st_top, st_bi } state{st_top};
59 59 };
60 60 } // namespace
61 61  
62 62 InlineImageTracker::InlineImageTracker(QPDF* qpdf, size_t min_size, QPDFObjectHandle resources) :
63 63 qpdf(qpdf),
64 64 min_size(min_size),
65   - resources(resources),
66   - min_suffix(1),
67   - any_images(false),
68   - state(st_top)
  65 + resources(resources)
69 66 {
70 67 }
71 68  
... ... @@ -451,7 +448,7 @@ QPDFPageObjectHelper::getAnnotations(std::string const&amp; only_subtype)
451 448 for (int i = 0; i < nannots; ++i) {
452 449 QPDFObjectHandle annot = annots.getArrayItem(i);
453 450 if (annot.isDictionaryOfType("", only_subtype)) {
454   - result.push_back(QPDFAnnotationObjectHelper(annot));
  451 + result.emplace_back(annot);
455 452 }
456 453 }
457 454 }
... ... @@ -662,7 +659,7 @@ QPDFPageObjectHelper::shallowCopyPage()
662 659 QPDF& qpdf =
663 660 this->oh.getQPDF("QPDFPageObjectHelper::shallowCopyPage called with a direct object");
664 661 QPDFObjectHandle new_page = this->oh.shallowCopy();
665   - return QPDFPageObjectHelper(qpdf.makeIndirectObject(new_page));
  662 + return {qpdf.makeIndirectObject(new_page)};
666 663 }
667 664  
668 665 QPDFObjectHandle::Matrix
... ... @@ -758,7 +755,7 @@ QPDFPageObjectHelper::getMatrixForFormXObjectPlacement(
758 755 QPDFObjectHandle fdict = fo.getDict();
759 756 QPDFObjectHandle bbox_obj = fdict.getKey("/BBox");
760 757 if (!bbox_obj.isRectangle()) {
761   - return QPDFMatrix();
  758 + return {};
762 759 }
763 760  
764 761 QPDFMatrix wmatrix; // work matrix
... ... @@ -793,7 +790,7 @@ QPDFPageObjectHelper::getMatrixForFormXObjectPlacement(
793 790 // Calculate a scale factor, if needed. Shrink or expand if needed and allowed.
794 791 if ((T.urx == T.llx) || (T.ury == T.lly)) {
795 792 // avoid division by zero
796   - return QPDFMatrix();
  793 + return {};
797 794 }
798 795 double rect_w = rect.urx - rect.llx;
799 796 double rect_h = rect.ury - rect.lly;
... ...
libqpdf/QPDFParser.cc
... ... @@ -55,7 +55,7 @@ QPDFParser::parse(bool&amp; empty, bool content_stream)
55 55 bool set_offset = false;
56 56  
57 57 std::vector<StackFrame> stack;
58   - stack.push_back(StackFrame(input));
  58 + stack.emplace_back(input);
59 59 std::vector<parser_state_e> state_stack;
60 60 state_stack.push_back(st_top);
61 61 qpdf_offset_t offset;
... ... @@ -141,7 +141,7 @@ QPDFParser::parse(bool&amp; empty, bool content_stream)
141 141 (tokenizer.getType() == QPDFTokenizer::tt_array_open) ? st_array
142 142 : st_dictionary);
143 143 b_contents = false;
144   - stack.push_back(StackFrame(input));
  144 + stack.emplace_back(input);
145 145 }
146 146 break;
147 147  
... ...
libqpdf/QPDFWriter.cc
... ... @@ -26,7 +26,7 @@
26 26 #include <cstdlib>
27 27 #include <stdexcept>
28 28  
29   -QPDFWriter::ProgressReporter::~ProgressReporter()
  29 +QPDFWriter::ProgressReporter::~ProgressReporter() // NOLINT (modernize-use-equals-default)
30 30 {
31 31 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
32 32 }
... ... @@ -36,7 +36,8 @@ QPDFWriter::FunctionProgressReporter::FunctionProgressReporter(std::function&lt;voi
36 36 {
37 37 }
38 38  
39   -QPDFWriter::FunctionProgressReporter::~FunctionProgressReporter()
  39 +QPDFWriter::FunctionProgressReporter::~FunctionProgressReporter() // NOLINT
  40 + // (modernize-use-equals-default)
40 41 {
41 42 // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
42 43 }
... ...
libqpdf/QPDFXRefEntry.cc
... ... @@ -3,7 +3,7 @@
3 3 #include <qpdf/QIntC.hh>
4 4 #include <qpdf/QPDFExc.hh>
5 5  
6   -QPDFXRefEntry::QPDFXRefEntry()
  6 +QPDFXRefEntry::QPDFXRefEntry() // NOLINT (modernize-use-equals-default)
7 7 {
8 8 }
9 9  
... ...
libqpdf/QPDF_Array.cc
... ... @@ -201,7 +201,7 @@ QPDF_Array::getAsVector() const
201 201 v.reserve(size_t(size()));
202 202 for (auto const& item: sp_elements) {
203 203 v.resize(size_t(item.first), null_oh);
204   - v.push_back(item.second);
  204 + v.emplace_back(item.second);
205 205 }
206 206 v.resize(size_t(size()), null_oh);
207 207 return v;
... ...
libqpdf/QPDF_encryption.cc
... ... @@ -164,7 +164,7 @@ pad_or_truncate_password_V4(std::string const&amp; password)
164 164 {
165 165 char k1[key_bytes];
166 166 pad_or_truncate_password_V4(password, k1);
167   - return std::string(k1, key_bytes);
  167 + return {k1, key_bytes};
168 168 }
169 169  
170 170 static std::string
... ... @@ -235,7 +235,7 @@ process_with_aes(
235 235 } else {
236 236 outlength = std::min(outlength, bufp->getSize());
237 237 }
238   - return std::string(reinterpret_cast<char*>(bufp->getBuffer()), outlength);
  238 + return {reinterpret_cast<char*>(bufp->getBuffer()), outlength};
239 239 }
240 240  
241 241 static std::string
... ... @@ -355,7 +355,7 @@ QPDF::compute_data_key(
355 355 md5.encodeDataIncrementally(result.c_str(), result.length());
356 356 MD5::Digest digest;
357 357 md5.digest(digest);
358   - return std::string(reinterpret_cast<char*>(digest), std::min(result.length(), toS(16)));
  358 + return {reinterpret_cast<char*>(digest), std::min(result.length(), toS(16))};
359 359 }
360 360  
361 361 std::string
... ... @@ -401,7 +401,7 @@ QPDF::compute_encryption_key_from_password(std::string const&amp; password, Encrypti
401 401 MD5::Digest digest;
402 402 int key_len = std::min(toI(sizeof(digest)), data.getLengthBytes());
403 403 iterate_md5_digest(md5, digest, ((data.getR() >= 3) ? 50 : 0), key_len);
404   - return std::string(reinterpret_cast<char*>(digest), toS(key_len));
  404 + return {reinterpret_cast<char*>(digest), toS(key_len)};
405 405 }
406 406  
407 407 static void
... ... @@ -448,7 +448,7 @@ compute_O_value(
448 448 data.getLengthBytes(),
449 449 (data.getR() >= 3) ? 20 : 1,
450 450 false);
451   - return std::string(upass, key_bytes);
  451 + return {upass, key_bytes};
452 452 }
453 453  
454 454 static std::string
... ... @@ -467,7 +467,7 @@ compute_U_value_R2(std::string const&amp; user_password, QPDF::EncryptionData const&amp;
467 467 data.getLengthBytes(),
468 468 1,
469 469 false);
470   - return std::string(udata, key_bytes);
  470 + return {udata, key_bytes};
471 471 }
472 472  
473 473 static std::string
... ... @@ -496,7 +496,7 @@ compute_U_value_R3(std::string const&amp; user_password, QPDF::EncryptionData const&amp;
496 496 for (unsigned int i = sizeof(MD5::Digest); i < key_bytes; ++i) {
497 497 result[i] = static_cast<char>((i * i) % 0xff);
498 498 }
499   - return std::string(result, key_bytes);
  499 + return {result, key_bytes};
500 500 }
501 501  
502 502 static std::string
... ...
libqpdf/QPDF_json.cc
... ... @@ -238,7 +238,7 @@ class QPDF::JSONReactor: public JSON::Reactor
238 238 }
239 239 }
240 240 }
241   - virtual ~JSONReactor() = default;
  241 + ~JSONReactor() override = default;
242 242 void dictionaryStart() override;
243 243 void arrayStart() override;
244 244 void containerEnd(JSON const& value) override;
... ...
libqpdf/QPDF_linearization.cc
... ... @@ -1367,7 +1367,7 @@ QPDF::calculateLinearizationData(std::map&lt;int, int&gt; const&amp; object_stream_data)
1367 1367 for (auto& oh: m->part6) {
1368 1368 int obj = oh.getObjectID();
1369 1369 obj_to_index[obj] = toI(shared.size());
1370   - shared.push_back(CHSharedObjectEntry(obj));
  1370 + shared.emplace_back(obj);
1371 1371 }
1372 1372 QTC::TC("qpdf", "QPDF lin part 8 empty", m->part8.empty() ? 1 : 0);
1373 1373 if (!m->part8.empty()) {
... ... @@ -1375,7 +1375,7 @@ QPDF::calculateLinearizationData(std::map&lt;int, int&gt; const&amp; object_stream_data)
1375 1375 for (auto& oh: m->part8) {
1376 1376 int obj = oh.getObjectID();
1377 1377 obj_to_index[obj] = toI(shared.size());
1378   - shared.push_back(CHSharedObjectEntry(obj));
  1378 + shared.emplace_back(obj);
1379 1379 }
1380 1380 }
1381 1381 if (static_cast<size_t>(m->c_shared_object_data.nshared_total) !=
... ... @@ -1585,7 +1585,7 @@ QPDF::calculateHSharedObject(
1585 1585 int length = outputLengthNextN(csoe.at(i).object, 1, lengths, obj_renumber);
1586 1586 min_length = std::min(min_length, length);
1587 1587 max_length = std::max(max_length, length);
1588   - soe.push_back(HSharedObjectEntry());
  1588 + soe.emplace_back();
1589 1589 soe.at(i).delta_group_length = length;
1590 1590 }
1591 1591 if (soe.size() != toS(cso.nshared_total)) {
... ...
libqpdf/QUtil.cc
... ... @@ -903,14 +903,14 @@ QUtil::get_current_qpdf_time()
903 903 // Don't know how to get timezone on this platform
904 904 int tzoff = 0;
905 905 # endif
906   - return QPDFTime(
  906 + return {
907 907 static_cast<int>(ltime.tm_year + 1900),
908 908 static_cast<int>(ltime.tm_mon + 1),
909 909 static_cast<int>(ltime.tm_mday),
910 910 static_cast<int>(ltime.tm_hour),
911 911 static_cast<int>(ltime.tm_min),
912 912 static_cast<int>(ltime.tm_sec),
913   - tzoff);
  913 + tzoff};
914 914 #endif
915 915 }
916 916  
... ... @@ -1082,13 +1082,12 @@ namespace
1082 1082  
1083 1083 private:
1084 1084 RandomDataProvider* default_provider;
1085   - RandomDataProvider* current_provider;
  1085 + RandomDataProvider* current_provider{nullptr};
1086 1086 };
1087 1087 } // namespace
1088 1088  
1089 1089 RandomDataProviderProvider::RandomDataProviderProvider() :
1090   - default_provider(CryptoRandomDataProvider::getInstance()),
1091   - current_provider(nullptr)
  1090 + default_provider(CryptoRandomDataProvider::getInstance())
1092 1091 {
1093 1092 this->current_provider = default_provider;
1094 1093 }
... ... @@ -1246,7 +1245,7 @@ QUtil::read_lines_from_file(
1246 1245 char c;
1247 1246 while (next_char(c)) {
1248 1247 if (buf == nullptr) {
1249   - lines.push_back("");
  1248 + lines.emplace_back("");
1250 1249 buf = &(lines.back());
1251 1250 buf->reserve(80);
1252 1251 }
... ...
libqpdf/qpdf-c.cc
... ... @@ -813,13 +813,13 @@ trap_oh_errors(qpdf_data qpdf, std::function&lt;RET()&gt; fallback, std::function&lt;RET(
813 813 if (!qpdf->silence_errors) {
814 814 QTC::TC("qpdf", "qpdf-c warn about oh error", qpdf->oh_error_occurred ? 0 : 1);
815 815 if (!qpdf->oh_error_occurred) {
816   - qpdf->warnings.push_back(QPDFExc(
  816 + qpdf->warnings.emplace_back(
817 817 qpdf_e_internal,
818 818 qpdf->qpdf->getFilename(),
819 819 "",
820 820 0,
821 821 "C API function caught an exception that it isn't returning; please point the "
822   - "application developer to ERROR HANDLING in qpdf-c.h"));
  822 + "application developer to ERROR HANDLING in qpdf-c.h");
823 823 qpdf->oh_error_occurred = true;
824 824 }
825 825 *QPDFLogger::defaultLogger()->getError() << qpdf->error->what() << "\n";
... ...
libqpdf/qpdf/Pl_LZWDecoder.hh
... ... @@ -10,9 +10,9 @@ class Pl_LZWDecoder: public Pipeline
10 10 {
11 11 public:
12 12 Pl_LZWDecoder(char const* identifier, Pipeline* next, bool early_code_change);
13   - virtual ~Pl_LZWDecoder() = default;
14   - virtual void write(unsigned char const* buf, size_t len);
15   - virtual void finish();
  13 + ~Pl_LZWDecoder() override = default;
  14 + void write(unsigned char const* buf, size_t len) override;
  15 + void finish() override;
16 16  
17 17 private:
18 18 void sendNextCode();
... ...
libqpdf/qpdf/Pl_MD5.hh
... ... @@ -14,9 +14,9 @@ class Pl_MD5: public Pipeline
14 14 {
15 15 public:
16 16 Pl_MD5(char const* identifier, Pipeline* next);
17   - virtual ~Pl_MD5() = default;
18   - virtual void write(unsigned char const*, size_t);
19   - virtual void finish();
  17 + ~Pl_MD5() override = default;
  18 + void write(unsigned char const*, size_t) override;
  19 + void finish() override;
20 20 std::string getHexDigest();
21 21 // Enable/disable. Disabling the pipeline causes it to become a pass-through. This makes it
22 22 // possible to stick an MD5 pipeline in a pipeline when it may or may not be required. Disabling
... ...
libqpdf/qpdf/QPDFArgParser.hh
... ... @@ -145,19 +145,12 @@ class QPDFArgParser
145 145 private:
146 146 struct OptionEntry
147 147 {
148   - OptionEntry() :
149   - parameter_needed(false),
150   - bare_arg_handler(nullptr),
151   - param_arg_handler(nullptr),
152   - invalid_choice_handler(nullptr)
153   - {
154   - }
155   - bool parameter_needed;
  148 + bool parameter_needed{false};
156 149 std::string parameter_name;
157 150 std::set<std::string> choices;
158   - bare_arg_handler_t bare_arg_handler;
159   - param_arg_handler_t param_arg_handler;
160   - param_arg_handler_t invalid_choice_handler;
  151 + bare_arg_handler_t bare_arg_handler{nullptr};
  152 + param_arg_handler_t param_arg_handler{nullptr};
  153 + param_arg_handler_t invalid_choice_handler{nullptr};
161 154 };
162 155 typedef std::map<std::string, OptionEntry> option_table_t;
163 156  
... ...
libqpdf/qpdf/QPDF_Array.hh
... ... @@ -9,14 +9,14 @@
9 9 class QPDF_Array: public QPDFValue
10 10 {
11 11 public:
12   - virtual ~QPDF_Array() = default;
  12 + ~QPDF_Array() override = default;
13 13 static std::shared_ptr<QPDFObject> create(std::vector<QPDFObjectHandle> const& items);
14 14 static std::shared_ptr<QPDFObject>
15 15 create(std::vector<std::shared_ptr<QPDFObject>>&& items, bool sparse);
16   - virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
17   - virtual std::string unparse();
18   - virtual JSON getJSON(int json_version);
19   - virtual void disconnect();
  16 + std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
  17 + std::string unparse() override;
  18 + JSON getJSON(int json_version) override;
  19 + void disconnect() override;
20 20  
21 21 int
22 22 size() const noexcept
... ...
libqpdf/qpdf/QPDF_Bool.hh
... ... @@ -6,11 +6,11 @@
6 6 class QPDF_Bool: public QPDFValue
7 7 {
8 8 public:
9   - virtual ~QPDF_Bool() = default;
  9 + ~QPDF_Bool() override = default;
10 10 static std::shared_ptr<QPDFObject> create(bool val);
11   - virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
12   - virtual std::string unparse();
13   - virtual JSON getJSON(int json_version);
  11 + std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
  12 + std::string unparse() override;
  13 + JSON getJSON(int json_version) override;
14 14 bool getVal() const;
15 15  
16 16 private:
... ...
libqpdf/qpdf/QPDF_Destroyed.hh
... ... @@ -6,10 +6,10 @@
6 6 class QPDF_Destroyed: public QPDFValue
7 7 {
8 8 public:
9   - virtual ~QPDF_Destroyed() = default;
10   - virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
11   - virtual std::string unparse();
12   - virtual JSON getJSON(int json_version);
  9 + ~QPDF_Destroyed() override = default;
  10 + std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
  11 + std::string unparse() override;
  12 + JSON getJSON(int json_version) override;
13 13 static std::shared_ptr<QPDFValue> getInstance();
14 14  
15 15 private:
... ...
libqpdf/qpdf/QPDF_Dictionary.hh
... ... @@ -11,13 +11,13 @@
11 11 class QPDF_Dictionary: public QPDFValue
12 12 {
13 13 public:
14   - virtual ~QPDF_Dictionary() = default;
  14 + ~QPDF_Dictionary() override = default;
15 15 static std::shared_ptr<QPDFObject> create(std::map<std::string, QPDFObjectHandle> const& items);
16 16 static std::shared_ptr<QPDFObject> create(std::map<std::string, QPDFObjectHandle>&& items);
17   - virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
18   - virtual std::string unparse();
19   - virtual JSON getJSON(int json_version);
20   - virtual void disconnect();
  17 + std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
  18 + std::string unparse() override;
  19 + JSON getJSON(int json_version) override;
  20 + void disconnect() override;
21 21  
22 22 // hasKey() and getKeys() treat keys with null values as if they aren't there. getKey() returns
23 23 // null for the value of a non-existent key. This is as per the PDF spec.
... ...
libqpdf/qpdf/QPDF_InlineImage.hh
... ... @@ -6,13 +6,13 @@
6 6 class QPDF_InlineImage: public QPDFValue
7 7 {
8 8 public:
9   - virtual ~QPDF_InlineImage() = default;
  9 + ~QPDF_InlineImage() override = default;
10 10 static std::shared_ptr<QPDFObject> create(std::string const& val);
11   - virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
12   - virtual std::string unparse();
13   - virtual JSON getJSON(int json_version);
14   - virtual std::string
15   - getStringValue() const
  11 + std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
  12 + std::string unparse() override;
  13 + JSON getJSON(int json_version) override;
  14 + std::string
  15 + getStringValue() const override
16 16 {
17 17 return val;
18 18 }
... ...
libqpdf/qpdf/QPDF_Integer.hh
... ... @@ -6,11 +6,11 @@
6 6 class QPDF_Integer: public QPDFValue
7 7 {
8 8 public:
9   - virtual ~QPDF_Integer() = default;
  9 + ~QPDF_Integer() override = default;
10 10 static std::shared_ptr<QPDFObject> create(long long value);
11   - virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
12   - virtual std::string unparse();
13   - virtual JSON getJSON(int json_version);
  11 + std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
  12 + std::string unparse() override;
  13 + JSON getJSON(int json_version) override;
14 14 long long getVal() const;
15 15  
16 16 private:
... ...
libqpdf/qpdf/QPDF_Name.hh
... ... @@ -6,16 +6,16 @@
6 6 class QPDF_Name: public QPDFValue
7 7 {
8 8 public:
9   - virtual ~QPDF_Name() = default;
  9 + ~QPDF_Name() override = default;
10 10 static std::shared_ptr<QPDFObject> create(std::string const& name);
11   - virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
12   - virtual std::string unparse();
13   - virtual JSON getJSON(int json_version);
  11 + std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
  12 + std::string unparse() override;
  13 + JSON getJSON(int json_version) override;
14 14  
15 15 // Put # into strings with characters unsuitable for name token
16 16 static std::string normalizeName(std::string const& name);
17   - virtual std::string
18   - getStringValue() const
  17 + std::string
  18 + getStringValue() const override
19 19 {
20 20 return name;
21 21 }
... ...
libqpdf/qpdf/QPDF_Null.hh
... ... @@ -6,7 +6,7 @@
6 6 class QPDF_Null: public QPDFValue
7 7 {
8 8 public:
9   - virtual ~QPDF_Null() = default;
  9 + ~QPDF_Null() override = default;
10 10 static std::shared_ptr<QPDFObject> create();
11 11 static std::shared_ptr<QPDFObject> create(
12 12 std::shared_ptr<QPDFObject> parent,
... ... @@ -16,9 +16,9 @@ class QPDF_Null: public QPDFValue
16 16 std::shared_ptr<QPDFValue> parent,
17 17 std::string_view const& static_descr,
18 18 std::string var_descr);
19   - virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
20   - virtual std::string unparse();
21   - virtual JSON getJSON(int json_version);
  19 + std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
  20 + std::string unparse() override;
  21 + JSON getJSON(int json_version) override;
22 22  
23 23 private:
24 24 QPDF_Null();
... ...
libqpdf/qpdf/QPDF_Operator.hh
... ... @@ -6,13 +6,13 @@
6 6 class QPDF_Operator: public QPDFValue
7 7 {
8 8 public:
9   - virtual ~QPDF_Operator() = default;
  9 + ~QPDF_Operator() override = default;
10 10 static std::shared_ptr<QPDFObject> create(std::string const& val);
11   - virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
12   - virtual std::string unparse();
13   - virtual JSON getJSON(int json_version);
14   - virtual std::string
15   - getStringValue() const
  11 + std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
  12 + std::string unparse() override;
  13 + JSON getJSON(int json_version) override;
  14 + std::string
  15 + getStringValue() const override
16 16 {
17 17 return val;
18 18 }
... ...
libqpdf/qpdf/QPDF_Real.hh
... ... @@ -6,15 +6,15 @@
6 6 class QPDF_Real: public QPDFValue
7 7 {
8 8 public:
9   - virtual ~QPDF_Real() = default;
  9 + ~QPDF_Real() override = default;
10 10 static std::shared_ptr<QPDFObject> create(std::string const& val);
11 11 static std::shared_ptr<QPDFObject>
12 12 create(double value, int decimal_places, bool trim_trailing_zeroes);
13   - virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
14   - virtual std::string unparse();
15   - virtual JSON getJSON(int json_version);
16   - virtual std::string
17   - getStringValue() const
  13 + std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
  14 + std::string unparse() override;
  15 + JSON getJSON(int json_version) override;
  16 + std::string
  17 + getStringValue() const override
18 18 {
19 19 return val;
20 20 }
... ...
libqpdf/qpdf/QPDF_Reserved.hh
... ... @@ -6,11 +6,11 @@
6 6 class QPDF_Reserved: public QPDFValue
7 7 {
8 8 public:
9   - virtual ~QPDF_Reserved() = default;
  9 + ~QPDF_Reserved() override = default;
10 10 static std::shared_ptr<QPDFObject> create();
11   - virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
12   - virtual std::string unparse();
13   - virtual JSON getJSON(int json_version);
  11 + std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
  12 + std::string unparse() override;
  13 + JSON getJSON(int json_version) override;
14 14  
15 15 private:
16 16 QPDF_Reserved();
... ...
libqpdf/qpdf/QPDF_Stream.hh
... ... @@ -16,19 +16,19 @@ class QPDF;
16 16 class QPDF_Stream: public QPDFValue
17 17 {
18 18 public:
19   - virtual ~QPDF_Stream() = default;
  19 + ~QPDF_Stream() override = default;
20 20 static std::shared_ptr<QPDFObject> create(
21 21 QPDF*,
22 22 QPDFObjGen const& og,
23 23 QPDFObjectHandle stream_dict,
24 24 qpdf_offset_t offset,
25 25 size_t length);
26   - virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
27   - virtual std::string unparse();
28   - virtual JSON getJSON(int json_version);
29   - virtual void setDescription(
30   - QPDF*, std::shared_ptr<QPDFValue::Description>& description, qpdf_offset_t offset);
31   - virtual void disconnect();
  26 + std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
  27 + std::string unparse() override;
  28 + JSON getJSON(int json_version) override;
  29 + void setDescription(
  30 + QPDF*, std::shared_ptr<QPDFValue::Description>& description, qpdf_offset_t offset) override;
  31 + void disconnect() override;
32 32 QPDFObjectHandle getDict() const;
33 33 bool isDataModified() const;
34 34 void setFilterOnWrite(bool);
... ...
libqpdf/qpdf/QPDF_String.hh
... ... @@ -10,16 +10,16 @@ class QPDF_String: public QPDFValue
10 10 friend class QPDFWriter;
11 11  
12 12 public:
13   - virtual ~QPDF_String() = default;
  13 + ~QPDF_String() override = default;
14 14 static std::shared_ptr<QPDFObject> create(std::string const& val);
15 15 static std::shared_ptr<QPDFObject> create_utf16(std::string const& utf8_val);
16   - virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
17   - virtual std::string unparse();
  16 + std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
  17 + std::string unparse() override;
18 18 std::string unparse(bool force_binary);
19   - virtual JSON getJSON(int json_version);
  19 + JSON getJSON(int json_version) override;
20 20 std::string getUTF8Val() const;
21   - virtual std::string
22   - getStringValue() const
  21 + std::string
  22 + getStringValue() const override
23 23 {
24 24 return val;
25 25 }
... ...
libqpdf/qpdf/QPDF_Unresolved.hh
... ... @@ -6,11 +6,11 @@
6 6 class QPDF_Unresolved: public QPDFValue
7 7 {
8 8 public:
9   - virtual ~QPDF_Unresolved() = default;
  9 + ~QPDF_Unresolved() override = default;
10 10 static std::shared_ptr<QPDFObject> create(QPDF* qpdf, QPDFObjGen const& og);
11   - virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
12   - virtual std::string unparse();
13   - virtual JSON getJSON(int json_version);
  11 + std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
  12 + std::string unparse() override;
  13 + JSON getJSON(int json_version) override;
14 14  
15 15 private:
16 16 QPDF_Unresolved(QPDF* qpdf, QPDFObjGen const& og);
... ...
libqpdf/qpdf/ResourceFinder.hh
... ... @@ -7,7 +7,7 @@ class ResourceFinder: public QPDFObjectHandle::ParserCallbacks
7 7 {
8 8 public:
9 9 ResourceFinder();
10   - virtual ~ResourceFinder() = default;
  10 + ~ResourceFinder() override = default;
11 11 void handleObject(QPDFObjectHandle, size_t, size_t) override;
12 12 void handleEOF() override;
13 13 std::set<std::string> const& getNames() const;
... ...
libqpdf/qpdf/SF_ASCII85Decode.hh
... ... @@ -9,7 +9,7 @@ class SF_ASCII85Decode: public QPDFStreamFilter
9 9 {
10 10 public:
11 11 SF_ASCII85Decode() = default;
12   - virtual ~SF_ASCII85Decode() = default;
  12 + ~SF_ASCII85Decode() override = default;
13 13  
14 14 Pipeline*
15 15 getDecodePipeline(Pipeline* next) override
... ...
libqpdf/qpdf/SF_ASCIIHexDecode.hh
... ... @@ -9,7 +9,7 @@ class SF_ASCIIHexDecode: public QPDFStreamFilter
9 9 {
10 10 public:
11 11 SF_ASCIIHexDecode() = default;
12   - virtual ~SF_ASCIIHexDecode() = default;
  12 + ~SF_ASCIIHexDecode() override = default;
13 13  
14 14 Pipeline*
15 15 getDecodePipeline(Pipeline* next) override
... ...
libqpdf/qpdf/SF_DCTDecode.hh
... ... @@ -9,7 +9,7 @@ class SF_DCTDecode: public QPDFStreamFilter
9 9 {
10 10 public:
11 11 SF_DCTDecode() = default;
12   - virtual ~SF_DCTDecode() = default;
  12 + ~SF_DCTDecode() override = default;
13 13  
14 14 Pipeline*
15 15 getDecodePipeline(Pipeline* next) override
... ...