Commit a4b7907e7eb94f5d88f0d1e7b3ddd4069244727f

Authored by m-holger
Committed by GitHub
2 parents 6a5cd991 67edbfd9

Merge pull request #1377 from m-holger/dll

Tidy public header files
Showing 77 changed files with 532 additions and 661 deletions
README-maintainer.md
@@ -886,7 +886,7 @@ still things that could potentially break ABI, such as @@ -886,7 +886,7 @@ still things that could potentially break ABI, such as
886 * Changes to the types of public or protected data members without 886 * Changes to the types of public or protected data members without
887 changing the size 887 changing the size
888 888
889 -* Changes to the meanings of parameters with changing the signature 889 +* Changes to the meanings of parameters without changing the signature
890 890
891 Not breaking ABI/API still requires care. 891 Not breaking ABI/API still requires care.
892 892
include/qpdf/Buffer.hh
@@ -46,6 +46,9 @@ class Buffer @@ -46,6 +46,9 @@ class Buffer
46 QPDF_DLL 46 QPDF_DLL
47 Buffer(std::string& content); 47 Buffer(std::string& content);
48 48
  49 + Buffer(Buffer const&) = delete;
  50 + Buffer& operator=(Buffer const&) = delete;
  51 +
49 QPDF_DLL 52 QPDF_DLL
50 Buffer(Buffer&&) noexcept; 53 Buffer(Buffer&&) noexcept;
51 QPDF_DLL 54 QPDF_DLL
include/qpdf/ClosedFileInputSource.hh
@@ -20,22 +20,25 @@ @@ -20,22 +20,25 @@
20 #ifndef QPDF_CLOSEDFILEINPUTSOURCE_HH 20 #ifndef QPDF_CLOSEDFILEINPUTSOURCE_HH
21 #define QPDF_CLOSEDFILEINPUTSOURCE_HH 21 #define QPDF_CLOSEDFILEINPUTSOURCE_HH
22 22
23 -// This is an input source that reads from files, like FileInputSource, except that it opens and  
24 -// closes the file surrounding every operation. This decreases efficiency, but it allows many more  
25 -// of these to exist at once than the maximum number of open file descriptors. This is used for  
26 -// merging large numbers of files.  
27 -  
28 #include <qpdf/InputSource.hh> 23 #include <qpdf/InputSource.hh>
29 24
30 #include <memory> 25 #include <memory>
31 26
32 class FileInputSource; 27 class FileInputSource;
33 28
  29 +// This is an input source that reads from files, like FileInputSource, except that it opens and
  30 +// closes the file surrounding every operation. This decreases efficiency, but it allows many more
  31 +// of these to exist at once than the maximum number of open file descriptors. This is used for
  32 +// merging large numbers of files.
34 class QPDF_DLL_CLASS ClosedFileInputSource: public InputSource 33 class QPDF_DLL_CLASS ClosedFileInputSource: public InputSource
35 { 34 {
36 public: 35 public:
37 QPDF_DLL 36 QPDF_DLL
38 ClosedFileInputSource(char const* filename); 37 ClosedFileInputSource(char const* filename);
  38 +
  39 + ClosedFileInputSource(ClosedFileInputSource const&) = delete;
  40 + ClosedFileInputSource& operator=(ClosedFileInputSource const&) = delete;
  41 +
39 QPDF_DLL 42 QPDF_DLL
40 ~ClosedFileInputSource() override; 43 ~ClosedFileInputSource() override;
41 QPDF_DLL 44 QPDF_DLL
@@ -60,9 +63,6 @@ class QPDF_DLL_CLASS ClosedFileInputSource: public InputSource @@ -60,9 +63,6 @@ class QPDF_DLL_CLASS ClosedFileInputSource: public InputSource
60 void stayOpen(bool); 63 void stayOpen(bool);
61 64
62 private: 65 private:
63 - ClosedFileInputSource(ClosedFileInputSource const&) = delete;  
64 - ClosedFileInputSource& operator=(ClosedFileInputSource const&) = delete;  
65 -  
66 QPDF_DLL_PRIVATE 66 QPDF_DLL_PRIVATE
67 void before(); 67 void before();
68 QPDF_DLL_PRIVATE 68 QPDF_DLL_PRIVATE
include/qpdf/FileInputSource.hh
@@ -25,8 +25,7 @@ @@ -25,8 +25,7 @@
25 class QPDF_DLL_CLASS FileInputSource: public InputSource 25 class QPDF_DLL_CLASS FileInputSource: public InputSource
26 { 26 {
27 public: 27 public:
28 - QPDF_DLL  
29 - FileInputSource(); 28 + FileInputSource() = default;
30 QPDF_DLL 29 QPDF_DLL
31 FileInputSource(char const* filename); 30 FileInputSource(char const* filename);
32 QPDF_DLL 31 QPDF_DLL
@@ -35,6 +34,10 @@ class QPDF_DLL_CLASS FileInputSource: public InputSource @@ -35,6 +34,10 @@ class QPDF_DLL_CLASS FileInputSource: public InputSource
35 void setFilename(char const* filename); 34 void setFilename(char const* filename);
36 QPDF_DLL 35 QPDF_DLL
37 void setFile(char const* description, FILE* filep, bool close_file); 36 void setFile(char const* description, FILE* filep, bool close_file);
  37 +
  38 + FileInputSource(FileInputSource const&) = delete;
  39 + FileInputSource& operator=(FileInputSource const&) = delete;
  40 +
38 QPDF_DLL 41 QPDF_DLL
39 ~FileInputSource() override; 42 ~FileInputSource() override;
40 QPDF_DLL 43 QPDF_DLL
@@ -53,12 +56,9 @@ class QPDF_DLL_CLASS FileInputSource: public InputSource @@ -53,12 +56,9 @@ class QPDF_DLL_CLASS FileInputSource: public InputSource
53 void unreadCh(char ch) override; 56 void unreadCh(char ch) override;
54 57
55 private: 58 private:
56 - FileInputSource(FileInputSource const&) = delete;  
57 - FileInputSource& operator=(FileInputSource const&) = delete;  
58 -  
59 - bool close_file; 59 + bool close_file{false};
60 std::string filename; 60 std::string filename;
61 - FILE* file; 61 + FILE* file{nullptr};
62 }; 62 };
63 63
64 #endif // QPDF_FILEINPUTSOURCE_HH 64 #endif // QPDF_FILEINPUTSOURCE_HH
include/qpdf/InputSource.hh
@@ -32,11 +32,8 @@ @@ -32,11 +32,8 @@
32 class QPDF_DLL_CLASS InputSource 32 class QPDF_DLL_CLASS InputSource
33 { 33 {
34 public: 34 public:
35 - QPDF_DLL  
36 - InputSource()  
37 - {  
38 - }  
39 - QPDF_DLL 35 + InputSource() = default;
  36 +
40 virtual ~InputSource() = default; 37 virtual ~InputSource() = default;
41 38
42 class QPDF_DLL_CLASS Finder 39 class QPDF_DLL_CLASS Finder
include/qpdf/JSON.hh
@@ -20,15 +20,6 @@ @@ -20,15 +20,6 @@
20 #ifndef JSON_HH 20 #ifndef JSON_HH
21 #define JSON_HH 21 #define JSON_HH
22 22
23 -// This is a simple JSON serializer and parser, primarily designed for serializing QPDF Objects as  
24 -// JSON. While it may work as a general-purpose JSON parser/serializer, there are better options.  
25 -// JSON objects contain their data as smart pointers. When one JSON object is added to another, this  
26 -// pointer is copied. This means you can create temporary JSON objects on the stack, add them to  
27 -// other objects, and let them go out of scope safely. It also means that if a JSON object is added  
28 -// in more than one place, all copies share the underlying data. This makes them similar in  
29 -// structure and behavior to QPDFObjectHandle and may feel natural within the QPDF codebase, but it  
30 -// is also a good reason not to use this as a general-purpose JSON package.  
31 -  
32 #include <qpdf/DLL.h> 23 #include <qpdf/DLL.h>
33 #include <qpdf/Types.h> 24 #include <qpdf/Types.h>
34 25
@@ -43,12 +34,19 @@ @@ -43,12 +34,19 @@
43 class Pipeline; 34 class Pipeline;
44 class InputSource; 35 class InputSource;
45 36
  37 +// This is a simple JSON serializer and parser, primarily designed for serializing QPDF Objects as
  38 +// JSON. While it may work as a general-purpose JSON parser/serializer, there are better options.
  39 +// JSON objects contain their data as smart pointers. When one JSON object is added to another, this
  40 +// pointer is copied. This means you can create temporary JSON objects on the stack, add them to
  41 +// other objects, and let them go out of scope safely. It also means that if a JSON object is added
  42 +// in more than one place, all copies share the underlying data. This makes them similar in
  43 +// structure and behavior to QPDFObjectHandle and may feel natural within the QPDF codebase, but it
  44 +// is also a good reason not to use this as a general-purpose JSON package.
46 class JSON 45 class JSON
47 { 46 {
48 public: 47 public:
49 static int constexpr LATEST = 2; 48 static int constexpr LATEST = 2;
50 49
51 - QPDF_DLL  
52 JSON() = default; 50 JSON() = default;
53 51
54 QPDF_DLL 52 QPDF_DLL
@@ -147,6 +145,7 @@ class JSON @@ -147,6 +145,7 @@ class JSON
147 // 145 //
148 // - If argument is wrong type, including null, return false 146 // - If argument is wrong type, including null, return false
149 // - If argument is right type, return true and initialize the value 147 // - If argument is right type, return true and initialize the value
  148 +
150 QPDF_DLL 149 QPDF_DLL
151 bool getString(std::string& utf8) const; 150 bool getString(std::string& utf8) const;
152 QPDF_DLL 151 QPDF_DLL
@@ -210,7 +209,6 @@ class JSON @@ -210,7 +209,6 @@ class JSON
210 class QPDF_DLL_CLASS Reactor 209 class QPDF_DLL_CLASS Reactor
211 { 210 {
212 public: 211 public:
213 - QPDF_DLL  
214 virtual ~Reactor() = default; 212 virtual ~Reactor() = default;
215 213
216 // The start/end methods are called when parsing of a dictionary or array is started or 214 // The start/end methods are called when parsing of a dictionary or array is started or
@@ -377,7 +375,6 @@ class JSON @@ -377,7 +375,6 @@ class JSON
377 friend class JSON; 375 friend class JSON;
378 376
379 public: 377 public:
380 - QPDF_DLL  
381 ~Members() = default; 378 ~Members() = default;
382 379
383 private: 380 private:
include/qpdf/PDFVersion.hh
@@ -23,18 +23,16 @@ @@ -23,18 +23,16 @@
23 #include <qpdf/DLL.h> 23 #include <qpdf/DLL.h>
24 #include <string> 24 #include <string>
25 25
  26 +// Represent a PDF version. PDF versions are typically major.minor, but PDF 1.7 has several
  27 +// extension levels as the ISO 32000 spec was in progress. This class helps with comparison of
  28 +// versions.
26 class PDFVersion 29 class PDFVersion
27 { 30 {
28 public: 31 public:
29 - // Represent a PDF version. PDF versions are typically major.minor, but PDF 1.7 has several  
30 - // extension levels as the ISO 32000 spec was in progress. This class helps with comparison of  
31 - // versions.  
32 - QPDF_DLL  
33 - PDFVersion();  
34 - QPDF_DLL 32 + PDFVersion() = default;
35 PDFVersion(PDFVersion const&) = default; 33 PDFVersion(PDFVersion const&) = default;
36 - QPDF_DLL  
37 PDFVersion& operator=(PDFVersion const&) = default; 34 PDFVersion& operator=(PDFVersion const&) = default;
  35 +
38 QPDF_DLL 36 QPDF_DLL
39 PDFVersion(int major, int minor, int extension = 0); 37 PDFVersion(int major, int minor, int extension = 0);
40 QPDF_DLL 38 QPDF_DLL
@@ -59,9 +57,9 @@ class PDFVersion @@ -59,9 +57,9 @@ class PDFVersion
59 int getExtensionLevel() const; 57 int getExtensionLevel() const;
60 58
61 private: 59 private:
62 - int major_version;  
63 - int minor_version;  
64 - int extension_level; 60 + int major_version{0};
  61 + int minor_version{0};
  62 + int extension_level{0};
65 }; 63 };
66 64
67 #endif // PDFVERSION_HH 65 #endif // PDFVERSION_HH
include/qpdf/Pipeline.hh
@@ -17,6 +17,14 @@ @@ -17,6 +17,14 @@
17 // License. At your option, you may continue to consider qpdf to be licensed under those terms. 17 // License. At your option, you may continue to consider qpdf to be licensed under those terms.
18 // Please see the manual for additional information. 18 // Please see the manual for additional information.
19 19
  20 +#ifndef PIPELINE_HH
  21 +#define PIPELINE_HH
  22 +
  23 +#include <qpdf/DLL.h>
  24 +
  25 +#include <memory>
  26 +#include <string>
  27 +
20 // Generalized Pipeline interface. By convention, subclasses of Pipeline are called Pl_Something. 28 // Generalized Pipeline interface. By convention, subclasses of Pipeline are called Pl_Something.
21 // 29 //
22 // When an instance of Pipeline is created with a pointer to a next pipeline, that pipeline writes 30 // When an instance of Pipeline is created with a pointer to a next pipeline, that pipeline writes
@@ -32,15 +40,7 @@ @@ -32,15 +40,7 @@
32 // Some pipelines are reusable (i.e., you can call write() after calling finish() and can call 40 // Some pipelines are reusable (i.e., you can call write() after calling finish() and can call
33 // finish() multiple times) while others are not. It is up to the caller to use a pipeline 41 // finish() multiple times) while others are not. It is up to the caller to use a pipeline
34 // according to its own restrictions. 42 // according to its own restrictions.
35 -  
36 -#ifndef PIPELINE_HH  
37 -#define PIPELINE_HH  
38 -  
39 -#include <qpdf/DLL.h>  
40 -  
41 -#include <memory>  
42 -#include <string>  
43 - 43 +//
44 // Remember to use QPDF_DLL_CLASS on anything derived from Pipeline so it will work with 44 // Remember to use QPDF_DLL_CLASS on anything derived from Pipeline so it will work with
45 // dynamic_cast across the shared object boundary. 45 // dynamic_cast across the shared object boundary.
46 class QPDF_DLL_CLASS Pipeline 46 class QPDF_DLL_CLASS Pipeline
@@ -49,7 +49,6 @@ class QPDF_DLL_CLASS Pipeline @@ -49,7 +49,6 @@ class QPDF_DLL_CLASS Pipeline
49 QPDF_DLL 49 QPDF_DLL
50 Pipeline(char const* identifier, Pipeline* next); 50 Pipeline(char const* identifier, Pipeline* next);
51 51
52 - QPDF_DLL  
53 virtual ~Pipeline() = default; 52 virtual ~Pipeline() = default;
54 53
55 // Subclasses should implement write and finish to do their jobs and then, if they are not 54 // Subclasses should implement write and finish to do their jobs and then, if they are not
@@ -98,7 +97,7 @@ class QPDF_DLL_CLASS Pipeline @@ -98,7 +97,7 @@ class QPDF_DLL_CLASS Pipeline
98 protected: 97 protected:
99 QPDF_DLL 98 QPDF_DLL
100 Pipeline* getNext(bool allow_null = false); 99 Pipeline* getNext(bool allow_null = false);
101 - QPDF_DLL 100 +
102 Pipeline* 101 Pipeline*
103 next() const noexcept 102 next() const noexcept
104 { 103 {
include/qpdf/Pl_Buffer.hh
@@ -20,6 +20,12 @@ @@ -20,6 +20,12 @@
20 #ifndef PL_BUFFER_HH 20 #ifndef PL_BUFFER_HH
21 #define PL_BUFFER_HH 21 #define PL_BUFFER_HH
22 22
  23 +#include <qpdf/Buffer.hh>
  24 +#include <qpdf/Pipeline.hh>
  25 +
  26 +#include <memory>
  27 +#include <string>
  28 +
23 // This pipeline accumulates the data passed to it into a memory buffer. Each subsequent use of 29 // This pipeline accumulates the data passed to it into a memory buffer. Each subsequent use of
24 // this buffer appends to the data accumulated so far. getBuffer() may be called only after calling 30 // this buffer appends to the data accumulated so far. getBuffer() may be called only after calling
25 // finish() and before calling any subsequent write(). At that point, a dynamically allocated 31 // finish() and before calling any subsequent write(). At that point, a dynamically allocated
@@ -28,13 +34,6 @@ @@ -28,13 +34,6 @@
28 // 34 //
29 // For this pipeline, "next" may be null. If a next pointer is provided, this pipeline will also 35 // For this pipeline, "next" may be null. If a next pointer is provided, this pipeline will also
30 // pass the data through to it. 36 // pass the data through to it.
31 -  
32 -#include <qpdf/Buffer.hh>  
33 -#include <qpdf/Pipeline.hh>  
34 -  
35 -#include <memory>  
36 -#include <string>  
37 -  
38 class QPDF_DLL_CLASS Pl_Buffer: public Pipeline 37 class QPDF_DLL_CLASS Pl_Buffer: public Pipeline
39 { 38 {
40 public: 39 public:
@@ -69,23 +68,9 @@ class QPDF_DLL_CLASS Pl_Buffer: public Pipeline @@ -69,23 +68,9 @@ class QPDF_DLL_CLASS Pl_Buffer: public Pipeline
69 std::string getString(); 68 std::string getString();
70 69
71 private: 70 private:
72 - class QPDF_DLL_PRIVATE Members  
73 - {  
74 - friend class Pl_Buffer;  
75 -  
76 - public:  
77 - QPDF_DLL  
78 - ~Members() = default;  
79 -  
80 - private:  
81 - Members() = default;  
82 - Members(Members const&) = delete;  
83 -  
84 - bool ready{true};  
85 - std::string data;  
86 - }; 71 + class Members;
87 72
88 - std::shared_ptr<Members> m; 73 + std::unique_ptr<Members> m;
89 }; 74 };
90 75
91 #endif // PL_BUFFER_HH 76 #endif // PL_BUFFER_HH
include/qpdf/Pl_Concatenate.hh
@@ -20,18 +20,18 @@ @@ -20,18 +20,18 @@
20 #ifndef PL_CONCATENATE_HH 20 #ifndef PL_CONCATENATE_HH
21 #define PL_CONCATENATE_HH 21 #define PL_CONCATENATE_HH
22 22
  23 +#include <qpdf/Pipeline.hh>
  24 +
23 // This pipeline will drop all regular finish calls rather than passing them onto next. To finish 25 // This pipeline will drop all regular finish calls rather than passing them onto next. To finish
24 // downstream streams, call manualFinish. This makes it possible to pipe multiple streams (e.g. 26 // downstream streams, call manualFinish. This makes it possible to pipe multiple streams (e.g.
25 // with QPDFObjectHandle::pipeStreamData) to a downstream like Pl_Flate that can't handle multiple 27 // with QPDFObjectHandle::pipeStreamData) to a downstream like Pl_Flate that can't handle multiple
26 // calls to finish(). 28 // calls to finish().
27 -  
28 -#include <qpdf/Pipeline.hh>  
29 -  
30 class QPDF_DLL_CLASS Pl_Concatenate: public Pipeline 29 class QPDF_DLL_CLASS Pl_Concatenate: public Pipeline
31 { 30 {
32 public: 31 public:
33 QPDF_DLL 32 QPDF_DLL
34 Pl_Concatenate(char const* identifier, Pipeline* next); 33 Pl_Concatenate(char const* identifier, Pipeline* next);
  34 +
35 QPDF_DLL 35 QPDF_DLL
36 ~Pl_Concatenate() override; 36 ~Pl_Concatenate() override;
37 37
@@ -51,7 +51,6 @@ class QPDF_DLL_CLASS Pl_Concatenate: public Pipeline @@ -51,7 +51,6 @@ class QPDF_DLL_CLASS Pl_Concatenate: public Pipeline
51 friend class Pl_Concatenate; 51 friend class Pl_Concatenate;
52 52
53 public: 53 public:
54 - QPDF_DLL  
55 ~Members() = default; 54 ~Members() = default;
56 55
57 private: 56 private:
@@ -59,7 +58,7 @@ class QPDF_DLL_CLASS Pl_Concatenate: public Pipeline @@ -59,7 +58,7 @@ class QPDF_DLL_CLASS Pl_Concatenate: public Pipeline
59 Members(Members const&) = delete; 58 Members(Members const&) = delete;
60 }; 59 };
61 60
62 - std::shared_ptr<Members> m; 61 + std::unique_ptr<Members> m{nullptr};
63 }; 62 };
64 63
65 #endif // PL_CONCATENATE_HH 64 #endif // PL_CONCATENATE_HH
include/qpdf/Pl_Count.hh
@@ -20,11 +20,10 @@ @@ -20,11 +20,10 @@
20 #ifndef PL_COUNT_HH 20 #ifndef PL_COUNT_HH
21 #define PL_COUNT_HH 21 #define PL_COUNT_HH
22 22
23 -// This pipeline is reusable; i.e., it is safe to call write() after calling finish().  
24 -  
25 #include <qpdf/Pipeline.hh> 23 #include <qpdf/Pipeline.hh>
26 #include <qpdf/Types.h> 24 #include <qpdf/Types.h>
27 25
  26 +// This pipeline is reusable; i.e., it is safe to call write() after calling finish().
28 class QPDF_DLL_CLASS Pl_Count: public Pipeline 27 class QPDF_DLL_CLASS Pl_Count: public Pipeline
29 { 28 {
30 public: 29 public:
@@ -45,24 +44,9 @@ class QPDF_DLL_CLASS Pl_Count: public Pipeline @@ -45,24 +44,9 @@ class QPDF_DLL_CLASS Pl_Count: public Pipeline
45 unsigned char getLastChar() const; 44 unsigned char getLastChar() const;
46 45
47 private: 46 private:
48 - class QPDF_DLL_PRIVATE Members  
49 - {  
50 - friend class Pl_Count;  
51 -  
52 - public:  
53 - QPDF_DLL  
54 - ~Members() = default;  
55 -  
56 - private:  
57 - Members();  
58 - Members(Members const&) = delete;  
59 -  
60 - // Must be qpdf_offset_t, not size_t, to handle writing more than size_t can handle.  
61 - qpdf_offset_t count{0};  
62 - unsigned char last_char{'\0'};  
63 - }; 47 + class Members;
64 48
65 - std::shared_ptr<Members> m; 49 + std::unique_ptr<Members> m;
66 }; 50 };
67 51
68 #endif // PL_COUNT_HH 52 #endif // PL_COUNT_HH
include/qpdf/Pl_DCT.hh
@@ -89,39 +89,9 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline @@ -89,39 +89,9 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline
89 89
90 enum action_e { a_compress, a_decompress }; 90 enum action_e { a_compress, a_decompress };
91 91
92 - class QPDF_DLL_PRIVATE Members  
93 - {  
94 - friend class Pl_DCT;  
95 -  
96 - public:  
97 - QPDF_DLL  
98 - ~Members() = default;  
99 - Members(Members const&) = delete;  
100 -  
101 - private:  
102 - // For compression  
103 - Members(  
104 - JDIMENSION image_width,  
105 - JDIMENSION image_height,  
106 - int components,  
107 - J_COLOR_SPACE color_space,  
108 - CompressConfig* config_callback);  
109 - // For decompression  
110 - Members();  
111 -  
112 - action_e action;  
113 - Pl_Buffer buf;  
114 -  
115 - // Used for compression  
116 - JDIMENSION image_width{0};  
117 - JDIMENSION image_height{0};  
118 - int components{1};  
119 - J_COLOR_SPACE color_space{JCS_GRAYSCALE};  
120 -  
121 - CompressConfig* config_callback{nullptr};  
122 - }; 92 + class Members;
123 93
124 - std::shared_ptr<Members> m; 94 + std::unique_ptr<Members> m;
125 }; 95 };
126 96
127 #endif // PL_DCT_HH 97 #endif // PL_DCT_HH
include/qpdf/Pl_Discard.hh
@@ -20,12 +20,11 @@ @@ -20,12 +20,11 @@
20 #ifndef PL_DISCARD_HH 20 #ifndef PL_DISCARD_HH
21 #define PL_DISCARD_HH 21 #define PL_DISCARD_HH
22 22
23 -// This pipeline discards its output. It is an end-of-line pipeline (with no next).  
24 -  
25 -// This pipeline is reusable; i.e., it is safe to call write() after calling finish().  
26 -  
27 #include <qpdf/Pipeline.hh> 23 #include <qpdf/Pipeline.hh>
28 24
  25 +// This pipeline discards its output. It is an end-of-line pipeline (with no next).
  26 +//
  27 +// This pipeline is reusable; i.e., it is safe to call write() after calling finish().
29 class QPDF_DLL_CLASS Pl_Discard: public Pipeline 28 class QPDF_DLL_CLASS Pl_Discard: public Pipeline
30 { 29 {
31 public: 30 public:
@@ -37,22 +36,6 @@ class QPDF_DLL_CLASS Pl_Discard: public Pipeline @@ -37,22 +36,6 @@ class QPDF_DLL_CLASS Pl_Discard: public Pipeline
37 void write(unsigned char const*, size_t) override; 36 void write(unsigned char const*, size_t) override;
38 QPDF_DLL 37 QPDF_DLL
39 void finish() override; 38 void finish() override;
40 -  
41 - private:  
42 - class QPDF_DLL_PRIVATE Members  
43 - {  
44 - friend class Pl_Discard;  
45 -  
46 - public:  
47 - QPDF_DLL  
48 - ~Members() = default;  
49 -  
50 - private:  
51 - Members() = default;  
52 - Members(Members const&) = delete;  
53 - };  
54 -  
55 - std::shared_ptr<Members> m;  
56 }; 39 };
57 40
58 #endif // PL_DISCARD_HH 41 #endif // PL_DISCARD_HH
include/qpdf/Pl_Flate.hh
@@ -104,11 +104,10 @@ class QPDF_DLL_CLASS Pl_Flate: public Pipeline @@ -104,11 +104,10 @@ class QPDF_DLL_CLASS Pl_Flate: public Pipeline
104 friend class Pl_Flate; 104 friend class Pl_Flate;
105 105
106 public: 106 public:
107 - QPDF_DLL 107 + Members(size_t out_bufsize, action_e action);
108 ~Members(); 108 ~Members();
109 109
110 private: 110 private:
111 - Members(size_t out_bufsize, action_e action);  
112 Members(Members const&) = delete; 111 Members(Members const&) = delete;
113 112
114 std::shared_ptr<unsigned char> outbuf; 113 std::shared_ptr<unsigned char> outbuf;
@@ -121,7 +120,7 @@ class QPDF_DLL_CLASS Pl_Flate: public Pipeline @@ -121,7 +120,7 @@ class QPDF_DLL_CLASS Pl_Flate: public Pipeline
121 std::unique_ptr<std::string> zopfli_buf; 120 std::unique_ptr<std::string> zopfli_buf;
122 }; 121 };
123 122
124 - std::shared_ptr<Members> m; 123 + std::unique_ptr<Members> m;
125 }; 124 };
126 125
127 #endif // PL_FLATE_HH 126 #endif // PL_FLATE_HH
include/qpdf/Pl_Function.hh
@@ -62,22 +62,9 @@ class QPDF_DLL_CLASS Pl_Function: public Pipeline @@ -62,22 +62,9 @@ class QPDF_DLL_CLASS Pl_Function: public Pipeline
62 void finish() override; 62 void finish() override;
63 63
64 private: 64 private:
65 - class QPDF_DLL_PRIVATE Members  
66 - {  
67 - friend class Pl_Function; 65 + class Members;
68 66
69 - public:  
70 - QPDF_DLL  
71 - ~Members() = default;  
72 -  
73 - private:  
74 - Members(writer_t);  
75 - Members(Members const&) = delete;  
76 -  
77 - writer_t fn;  
78 - };  
79 -  
80 - std::shared_ptr<Members> m; 67 + std::unique_ptr<Members> m;
81 }; 68 };
82 69
83 #endif // PL_FUNCTION_HH 70 #endif // PL_FUNCTION_HH
include/qpdf/Pl_OStream.hh
@@ -17,8 +17,6 @@ @@ -17,8 +17,6 @@
17 // License. At your option, you may continue to consider qpdf to be licensed under those terms. 17 // License. At your option, you may continue to consider qpdf to be licensed under those terms.
18 // Please see the manual for additional information. 18 // Please see the manual for additional information.
19 19
20 -// End-of-line pipeline that simply writes its data to a stdio FILE* object.  
21 -  
22 #ifndef PL_OSTREAM_HH 20 #ifndef PL_OSTREAM_HH
23 #define PL_OSTREAM_HH 21 #define PL_OSTREAM_HH
24 22
@@ -26,10 +24,9 @@ @@ -26,10 +24,9 @@
26 24
27 #include <iostream> 25 #include <iostream>
28 26
  27 +// End-of-line pipeline that simply writes its data to a stdio FILE* object.
29 // 28 //
30 // This pipeline is reusable. 29 // This pipeline is reusable.
31 -//  
32 -  
33 class QPDF_DLL_CLASS Pl_OStream: public Pipeline 30 class QPDF_DLL_CLASS Pl_OStream: public Pipeline
34 { 31 {
35 public: 32 public:
@@ -45,22 +42,9 @@ class QPDF_DLL_CLASS Pl_OStream: public Pipeline @@ -45,22 +42,9 @@ class QPDF_DLL_CLASS Pl_OStream: public Pipeline
45 void finish() override; 42 void finish() override;
46 43
47 private: 44 private:
48 - class QPDF_DLL_PRIVATE Members  
49 - {  
50 - friend class Pl_OStream;  
51 -  
52 - public:  
53 - QPDF_DLL  
54 - ~Members() = default;  
55 -  
56 - private:  
57 - Members(std::ostream&);  
58 - Members(Members const&) = delete;  
59 -  
60 - std::ostream& os;  
61 - }; 45 + class Members;
62 46
63 - std::shared_ptr<Members> m; 47 + std::unique_ptr<Members> m;
64 }; 48 };
65 49
66 #endif // PL_OSTREAM_HH 50 #endif // PL_OSTREAM_HH
include/qpdf/Pl_QPDFTokenizer.hh
@@ -31,11 +31,10 @@ @@ -31,11 +31,10 @@
31 // Tokenize the incoming text using QPDFTokenizer and pass the tokens in turn to a 31 // Tokenize the incoming text using QPDFTokenizer and pass the tokens in turn to a
32 // QPDFObjectHandle::TokenFilter object. All bytes of incoming content will be included in exactly 32 // QPDFObjectHandle::TokenFilter object. All bytes of incoming content will be included in exactly
33 // one token and passed downstream. 33 // one token and passed downstream.
34 - 34 +//
35 // This is a very low-level interface for working with token filters. Most code will want to use 35 // This is a very low-level interface for working with token filters. Most code will want to use
36 // QPDFObjectHandle::filterPageContents or QPDFObjectHandle::addTokenFilter. See QPDFObjectHandle.hh 36 // QPDFObjectHandle::filterPageContents or QPDFObjectHandle::addTokenFilter. See QPDFObjectHandle.hh
37 // for details. 37 // for details.
38 -  
39 class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline 38 class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline
40 { 39 {
41 public: 40 public:
@@ -52,23 +51,9 @@ class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline @@ -52,23 +51,9 @@ class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline
52 void finish() override; 51 void finish() override;
53 52
54 private: 53 private:
55 - class QPDF_DLL_PRIVATE Members  
56 - {  
57 - friend class Pl_QPDFTokenizer;  
58 -  
59 - public:  
60 - QPDF_DLL  
61 - ~Members() = default;  
62 -  
63 - private:  
64 - Members();  
65 - Members(Members const&) = delete; 54 + class Members;
66 55
67 - QPDFObjectHandle::TokenFilter* filter{nullptr};  
68 - QPDFTokenizer tokenizer;  
69 - Pl_Buffer buf;  
70 - };  
71 - std::shared_ptr<Members> m; 56 + std::unique_ptr<Members> m;
72 }; 57 };
73 58
74 #endif // PL_QPDFTOKENIZER_HH 59 #endif // PL_QPDFTOKENIZER_HH
include/qpdf/Pl_RunLength.hh
@@ -52,26 +52,9 @@ class QPDF_DLL_CLASS Pl_RunLength: public Pipeline @@ -52,26 +52,9 @@ class QPDF_DLL_CLASS Pl_RunLength: public Pipeline
52 52
53 enum state_e { st_top, st_copying, st_run }; 53 enum state_e { st_top, st_copying, st_run };
54 54
55 - class QPDF_DLL_PRIVATE Members  
56 - {  
57 - friend class Pl_RunLength; 55 + class Members;
58 56
59 - public:  
60 - QPDF_DLL  
61 - ~Members() = default;  
62 -  
63 - private:  
64 - Members(action_e);  
65 - Members(Members const&) = delete;  
66 -  
67 - action_e action;  
68 - state_e state{st_top};  
69 - unsigned char buf[128];  
70 - unsigned int length{0};  
71 - std::string out;  
72 - };  
73 -  
74 - std::shared_ptr<Members> m; 57 + std::unique_ptr<Members> m;
75 }; 58 };
76 59
77 #endif // PL_RUNLENGTH_HH 60 #endif // PL_RUNLENGTH_HH
include/qpdf/Pl_StdioFile.hh
@@ -29,7 +29,6 @@ @@ -29,7 +29,6 @@
29 // 29 //
30 // This pipeline is reusable. 30 // This pipeline is reusable.
31 // 31 //
32 -  
33 class QPDF_DLL_CLASS Pl_StdioFile: public Pipeline 32 class QPDF_DLL_CLASS Pl_StdioFile: public Pipeline
34 { 33 {
35 public: 34 public:
@@ -45,22 +44,10 @@ class QPDF_DLL_CLASS Pl_StdioFile: public Pipeline @@ -45,22 +44,10 @@ class QPDF_DLL_CLASS Pl_StdioFile: public Pipeline
45 void finish() override; 44 void finish() override;
46 45
47 private: 46 private:
48 - class QPDF_DLL_PRIVATE Members  
49 - {  
50 - friend class Pl_StdioFile;  
51 -  
52 - public:  
53 - QPDF_DLL  
54 - ~Members() = default;  
55 -  
56 - private:  
57 - Members(FILE*);  
58 - Members(Members const&) = delete;  
59 -  
60 - FILE* file;  
61 - }; 47 + class Members;
  48 + ;
62 49
63 - std::shared_ptr<Members> m; 50 + std::unique_ptr<Members> m;
64 }; 51 };
65 52
66 #endif // PL_STDIOFILE_HH 53 #endif // PL_STDIOFILE_HH
include/qpdf/Pl_String.hh
@@ -20,6 +20,10 @@ @@ -20,6 +20,10 @@
20 #ifndef PL_STRING_HH 20 #ifndef PL_STRING_HH
21 #define PL_STRING_HH 21 #define PL_STRING_HH
22 22
  23 +#include <qpdf/Pipeline.hh>
  24 +
  25 +#include <string>
  26 +
23 // This pipeline accumulates the data passed to it into a std::string, a reference to which is 27 // This pipeline accumulates the data passed to it into a std::string, a reference to which is
24 // passed in at construction. Each subsequent use of this pipeline appends to the data accumulated 28 // passed in at construction. Each subsequent use of this pipeline appends to the data accumulated
25 // so far. 29 // so far.
@@ -31,11 +35,6 @@ @@ -31,11 +35,6 @@
31 // this in front of another pipeline to capture data that is written to the other pipeline without 35 // this in front of another pipeline to capture data that is written to the other pipeline without
32 // interfering with when finish is called on the other pipeline and without having to put a 36 // interfering with when finish is called on the other pipeline and without having to put a
33 // Pl_Concatenate after it. 37 // Pl_Concatenate after it.
34 -  
35 -#include <qpdf/Pipeline.hh>  
36 -  
37 -#include <string>  
38 -  
39 class QPDF_DLL_CLASS Pl_String: public Pipeline 38 class QPDF_DLL_CLASS Pl_String: public Pipeline
40 { 39 {
41 public: 40 public:
@@ -50,22 +49,9 @@ class QPDF_DLL_CLASS Pl_String: public Pipeline @@ -50,22 +49,9 @@ class QPDF_DLL_CLASS Pl_String: public Pipeline
50 void finish() override; 49 void finish() override;
51 50
52 private: 51 private:
53 - class QPDF_DLL_PRIVATE Members  
54 - {  
55 - friend class Pl_String;  
56 -  
57 - public:  
58 - QPDF_DLL  
59 - ~Members() = default;  
60 -  
61 - private:  
62 - Members(std::string&);  
63 - Members(Members const&) = delete;  
64 -  
65 - std::string& s;  
66 - }; 52 + class Members;
67 53
68 - std::shared_ptr<Members> m; 54 + std::unique_ptr<Members> m;
69 }; 55 };
70 56
71 #endif // PL_STRING_HH 57 #endif // PL_STRING_HH
include/qpdf/QPDF.hh
@@ -1496,13 +1496,11 @@ class QPDF @@ -1496,13 +1496,11 @@ class QPDF
1496 friend class ResolveRecorder; 1496 friend class ResolveRecorder;
1497 1497
1498 public: 1498 public:
1499 - QPDF_DLL  
1500 - ~Members() = default;  
1501 -  
1502 - private:  
1503 Members(); 1499 Members();
1504 Members(Members const&) = delete; 1500 Members(Members const&) = delete;
  1501 + ~Members() = default;
1505 1502
  1503 + private:
1506 std::shared_ptr<QPDFLogger> log; 1504 std::shared_ptr<QPDFLogger> log;
1507 unsigned long long unique_id{0}; 1505 unsigned long long unique_id{0};
1508 QPDFTokenizer tokenizer; 1506 QPDFTokenizer tokenizer;
@@ -1577,7 +1575,7 @@ class QPDF @@ -1577,7 +1575,7 @@ class QPDF
1577 1575
1578 // Keep all member variables inside the Members object, which we dynamically allocate. This 1576 // Keep all member variables inside the Members object, which we dynamically allocate. This
1579 // makes it possible to add new private members without breaking binary compatibility. 1577 // makes it possible to add new private members without breaking binary compatibility.
1580 - std::shared_ptr<Members> m; 1578 + std::unique_ptr<Members> m;
1581 }; 1579 };
1582 1580
1583 #endif // QPDF_HH 1581 #endif // QPDF_HH
include/qpdf/QPDFAcroFormDocumentHelper.hh
@@ -20,6 +20,18 @@ @@ -20,6 +20,18 @@
20 #ifndef QPDFACROFORMDOCUMENTHELPER_HH 20 #ifndef QPDFACROFORMDOCUMENTHELPER_HH
21 #define QPDFACROFORMDOCUMENTHELPER_HH 21 #define QPDFACROFORMDOCUMENTHELPER_HH
22 22
  23 +#include <qpdf/QPDFDocumentHelper.hh>
  24 +
  25 +#include <qpdf/DLL.h>
  26 +
  27 +#include <qpdf/QPDFAnnotationObjectHelper.hh>
  28 +#include <qpdf/QPDFFormFieldObjectHelper.hh>
  29 +#include <qpdf/QPDFPageObjectHelper.hh>
  30 +
  31 +#include <map>
  32 +#include <set>
  33 +#include <vector>
  34 +
23 // This document helper is intended to help with operations on interactive forms. Here are the key 35 // This document helper is intended to help with operations on interactive forms. Here are the key
24 // things to know: 36 // things to know:
25 37
@@ -53,25 +65,12 @@ @@ -53,25 +65,12 @@
53 // under "/Fields" in the "/AcroForm" dictionary. In a more complex case, you may have to trace 65 // under "/Fields" in the "/AcroForm" dictionary. In a more complex case, you may have to trace
54 // through various "/Kids" elements in the "/AcroForm" field entry until you find the annotation 66 // through various "/Kids" elements in the "/AcroForm" field entry until you find the annotation
55 // dictionary. 67 // dictionary.
56 -  
57 -#include <qpdf/QPDFDocumentHelper.hh>  
58 -  
59 -#include <qpdf/DLL.h>  
60 -  
61 -#include <qpdf/QPDFAnnotationObjectHelper.hh>  
62 -#include <qpdf/QPDFFormFieldObjectHelper.hh>  
63 -#include <qpdf/QPDFPageObjectHelper.hh>  
64 -  
65 -#include <map>  
66 -#include <set>  
67 -#include <vector>  
68 -  
69 class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper 68 class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
70 { 69 {
71 public: 70 public:
72 QPDF_DLL 71 QPDF_DLL
73 QPDFAcroFormDocumentHelper(QPDF&); 72 QPDFAcroFormDocumentHelper(QPDF&);
74 - QPDF_DLL 73 +
75 ~QPDFAcroFormDocumentHelper() override = default; 74 ~QPDFAcroFormDocumentHelper() override = default;
76 75
77 // This class lazily creates an internal cache of the mapping among form fields, annotations, 76 // This class lazily creates an internal cache of the mapping among form fields, annotations,
@@ -232,7 +231,6 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper @@ -232,7 +231,6 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
232 friend class QPDFAcroFormDocumentHelper; 231 friend class QPDFAcroFormDocumentHelper;
233 232
234 public: 233 public:
235 - QPDF_DLL  
236 ~Members() = default; 234 ~Members() = default;
237 235
238 private: 236 private:
include/qpdf/QPDFAnnotationObjectHelper.hh
@@ -30,7 +30,7 @@ class QPDFAnnotationObjectHelper: public QPDFObjectHelper @@ -30,7 +30,7 @@ class QPDFAnnotationObjectHelper: public QPDFObjectHelper
30 public: 30 public:
31 QPDF_DLL 31 QPDF_DLL
32 QPDFAnnotationObjectHelper(QPDFObjectHandle); 32 QPDFAnnotationObjectHelper(QPDFObjectHandle);
33 - QPDF_DLL 33 +
34 ~QPDFAnnotationObjectHelper() override = default; 34 ~QPDFAnnotationObjectHelper() override = default;
35 35
36 // This class provides helper methods for annotations. More functionality will likely be added 36 // This class provides helper methods for annotations. More functionality will likely be added
@@ -92,7 +92,6 @@ class QPDFAnnotationObjectHelper: public QPDFObjectHelper @@ -92,7 +92,6 @@ class QPDFAnnotationObjectHelper: public QPDFObjectHelper
92 friend class QPDFAnnotationObjectHelper; 92 friend class QPDFAnnotationObjectHelper;
93 93
94 public: 94 public:
95 - QPDF_DLL  
96 ~Members() = default; 95 ~Members() = default;
97 96
98 private: 97 private:
include/qpdf/QPDFCryptoImpl.hh
@@ -32,40 +32,28 @@ @@ -32,40 +32,28 @@
32 // so, provide an implementation of QPDFCryptoImpl, ensure that you 32 // so, provide an implementation of QPDFCryptoImpl, ensure that you
33 // register it by calling QPDFCryptoProvider::registerImpl, and make 33 // register it by calling QPDFCryptoProvider::registerImpl, and make
34 // it the default by calling QPDFCryptoProvider::setDefaultProvider. 34 // it the default by calling QPDFCryptoProvider::setDefaultProvider.
35 -  
36 class QPDF_DLL_CLASS QPDFCryptoImpl 35 class QPDF_DLL_CLASS QPDFCryptoImpl
37 { 36 {
38 public: 37 public:
39 - QPDF_DLL  
40 QPDFCryptoImpl() = default; 38 QPDFCryptoImpl() = default;
41 39
42 - QPDF_DLL  
43 virtual ~QPDFCryptoImpl() = default; 40 virtual ~QPDFCryptoImpl() = default;
44 41
45 // Random Number Generation 42 // Random Number Generation
46 43
47 - QPDF_DLL  
48 virtual void provideRandomData(unsigned char* data, size_t len) = 0; 44 virtual void provideRandomData(unsigned char* data, size_t len) = 0;
49 45
50 // Hashing 46 // Hashing
51 47
52 typedef unsigned char MD5_Digest[16]; 48 typedef unsigned char MD5_Digest[16];
53 - QPDF_DLL  
54 virtual void MD5_init() = 0; 49 virtual void MD5_init() = 0;
55 - QPDF_DLL  
56 virtual void MD5_update(unsigned char const* data, size_t len) = 0; 50 virtual void MD5_update(unsigned char const* data, size_t len) = 0;
57 - QPDF_DLL  
58 virtual void MD5_finalize() = 0; 51 virtual void MD5_finalize() = 0;
59 - QPDF_DLL  
60 virtual void MD5_digest(MD5_Digest) = 0; 52 virtual void MD5_digest(MD5_Digest) = 0;
61 53
62 - QPDF_DLL  
63 virtual void SHA2_init(int bits) = 0; 54 virtual void SHA2_init(int bits) = 0;
64 - QPDF_DLL  
65 virtual void SHA2_update(unsigned char const* data, size_t len) = 0; 55 virtual void SHA2_update(unsigned char const* data, size_t len) = 0;
66 - QPDF_DLL  
67 virtual void SHA2_finalize() = 0; 56 virtual void SHA2_finalize() = 0;
68 - QPDF_DLL  
69 virtual std::string SHA2_digest() = 0; 57 virtual std::string SHA2_digest() = 0;
70 58
71 // Encryption/Decryption 59 // Encryption/Decryption
@@ -74,26 +62,20 @@ class QPDF_DLL_CLASS QPDFCryptoImpl @@ -74,26 +62,20 @@ class QPDF_DLL_CLASS QPDFCryptoImpl
74 // and readers. Search for RC4 in README.md 62 // and readers. Search for RC4 in README.md
75 63
76 // key_len of -1 means treat key_data as a null-terminated string 64 // key_len of -1 means treat key_data as a null-terminated string
77 - QPDF_DLL  
78 virtual void RC4_init(unsigned char const* key_data, int key_len = -1) = 0; 65 virtual void RC4_init(unsigned char const* key_data, int key_len = -1) = 0;
79 // out_data = 0 means to encrypt/decrypt in place 66 // out_data = 0 means to encrypt/decrypt in place
80 - QPDF_DLL  
81 virtual void 67 virtual void
82 RC4_process(unsigned char const* in_data, size_t len, unsigned char* out_data = nullptr) = 0; 68 RC4_process(unsigned char const* in_data, size_t len, unsigned char* out_data = nullptr) = 0;
83 - QPDF_DLL  
84 virtual void RC4_finalize() = 0; 69 virtual void RC4_finalize() = 0;
85 70
86 static size_t constexpr rijndael_buf_size = 16; 71 static size_t constexpr rijndael_buf_size = 16;
87 - QPDF_DLL  
88 virtual void rijndael_init( 72 virtual void rijndael_init(
89 bool encrypt, 73 bool encrypt,
90 unsigned char const* key_data, 74 unsigned char const* key_data,
91 size_t key_len, 75 size_t key_len,
92 bool cbc_mode, 76 bool cbc_mode,
93 unsigned char* cbc_block) = 0; 77 unsigned char* cbc_block) = 0;
94 - QPDF_DLL  
95 virtual void rijndael_process(unsigned char* in_data, unsigned char* out_data) = 0; 78 virtual void rijndael_process(unsigned char* in_data, unsigned char* out_data) = 0;
96 - QPDF_DLL  
97 virtual void rijndael_finalize() = 0; 79 virtual void rijndael_finalize() = 0;
98 }; 80 };
99 81
include/qpdf/QPDFCryptoProvider.hh
@@ -31,7 +31,6 @@ @@ -31,7 +31,6 @@
31 // This class is part of qpdf's pluggable crypto provider support. Most users won't need to know or 31 // This class is part of qpdf's pluggable crypto provider support. Most users won't need to know or
32 // care about this class, but you can use it if you want to supply your own crypto implementation. 32 // care about this class, but you can use it if you want to supply your own crypto implementation.
33 // See also comments in QPDFCryptoImpl.hh. 33 // See also comments in QPDFCryptoImpl.hh.
34 -  
35 class QPDFCryptoProvider 34 class QPDFCryptoProvider
36 { 35 {
37 public: 36 public:
@@ -92,7 +91,6 @@ class QPDFCryptoProvider @@ -92,7 +91,6 @@ class QPDFCryptoProvider
92 91
93 public: 92 public:
94 Members() = default; 93 Members() = default;
95 - QPDF_DLL  
96 ~Members() = default; 94 ~Members() = default;
97 95
98 private: 96 private:
include/qpdf/QPDFDocumentHelper.hh
@@ -30,28 +30,24 @@ @@ -30,28 +30,24 @@
30 // the underlying QPDF object unless there is a specific comment in a specific helper method that 30 // the underlying QPDF object unless there is a specific comment in a specific helper method that
31 // says otherwise. The pattern of using helper objects was introduced to allow creation of higher 31 // says otherwise. The pattern of using helper objects was introduced to allow creation of higher
32 // level helper functions without polluting the public interface of QPDF. 32 // level helper functions without polluting the public interface of QPDF.
33 -  
34 class QPDF_DLL_CLASS QPDFDocumentHelper 33 class QPDF_DLL_CLASS QPDFDocumentHelper
35 { 34 {
36 public: 35 public:
37 - QPDF_DLL  
38 QPDFDocumentHelper(QPDF& qpdf) : 36 QPDFDocumentHelper(QPDF& qpdf) :
39 qpdf(qpdf) 37 qpdf(qpdf)
40 { 38 {
41 } 39 }
42 QPDF_DLL 40 QPDF_DLL
43 virtual ~QPDFDocumentHelper(); 41 virtual ~QPDFDocumentHelper();
44 - QPDF_DLL  
45 QPDF& 42 QPDF&
46 getQPDF() 43 getQPDF()
47 { 44 {
48 - return this->qpdf; 45 + return qpdf;
49 } 46 }
50 - QPDF_DLL  
51 QPDF const& 47 QPDF const&
52 getQPDF() const 48 getQPDF() const
53 { 49 {
54 - return this->qpdf; 50 + return qpdf;
55 } 51 }
56 52
57 protected: 53 protected:
include/qpdf/QPDFEFStreamObjectHelper.hh
@@ -29,13 +29,12 @@ @@ -29,13 +29,12 @@
29 29
30 // This class provides a higher level interface around Embedded File Streams, which are discussed in 30 // This class provides a higher level interface around Embedded File Streams, which are discussed in
31 // section 7.11.4 of the ISO-32000 PDF specification. 31 // section 7.11.4 of the ISO-32000 PDF specification.
32 -  
33 class QPDFEFStreamObjectHelper: public QPDFObjectHelper 32 class QPDFEFStreamObjectHelper: public QPDFObjectHelper
34 { 33 {
35 public: 34 public:
36 QPDF_DLL 35 QPDF_DLL
37 QPDFEFStreamObjectHelper(QPDFObjectHandle); 36 QPDFEFStreamObjectHelper(QPDFObjectHandle);
38 - QPDF_DLL 37 +
39 ~QPDFEFStreamObjectHelper() override = default; 38 ~QPDFEFStreamObjectHelper() override = default;
40 39
41 // Date parameters are strings that conform to the PDF spec for date/time strings, which is 40 // Date parameters are strings that conform to the PDF spec for date/time strings, which is
@@ -98,7 +97,6 @@ class QPDFEFStreamObjectHelper: public QPDFObjectHelper @@ -98,7 +97,6 @@ class QPDFEFStreamObjectHelper: public QPDFObjectHelper
98 friend class QPDFEFStreamObjectHelper; 97 friend class QPDFEFStreamObjectHelper;
99 98
100 public: 99 public:
101 - QPDF_DLL  
102 ~Members() = default; 100 ~Members() = default;
103 101
104 private: 102 private:
include/qpdf/QPDFEmbeddedFileDocumentHelper.hh
@@ -33,13 +33,12 @@ @@ -33,13 +33,12 @@
33 // This class provides a higher level interface around document-level file attachments, also known 33 // This class provides a higher level interface around document-level file attachments, also known
34 // as embedded files. These are discussed in sections 7.7.4 and 7.11 of the ISO-32000 PDF 34 // as embedded files. These are discussed in sections 7.7.4 and 7.11 of the ISO-32000 PDF
35 // specification. 35 // specification.
36 -  
37 class QPDFEmbeddedFileDocumentHelper: public QPDFDocumentHelper 36 class QPDFEmbeddedFileDocumentHelper: public QPDFDocumentHelper
38 { 37 {
39 public: 38 public:
40 QPDF_DLL 39 QPDF_DLL
41 QPDFEmbeddedFileDocumentHelper(QPDF&); 40 QPDFEmbeddedFileDocumentHelper(QPDF&);
42 - QPDF_DLL 41 +
43 ~QPDFEmbeddedFileDocumentHelper() override = default; 42 ~QPDFEmbeddedFileDocumentHelper() override = default;
44 43
45 QPDF_DLL 44 QPDF_DLL
@@ -73,7 +72,6 @@ class QPDFEmbeddedFileDocumentHelper: public QPDFDocumentHelper @@ -73,7 +72,6 @@ class QPDFEmbeddedFileDocumentHelper: public QPDFDocumentHelper
73 friend class QPDFEmbeddedFileDocumentHelper; 72 friend class QPDFEmbeddedFileDocumentHelper;
74 73
75 public: 74 public:
76 - QPDF_DLL  
77 ~Members() = default; 75 ~Members() = default;
78 76
79 private: 77 private:
include/qpdf/QPDFExc.hh
@@ -37,7 +37,7 @@ class QPDF_DLL_CLASS QPDFExc: public std::runtime_error @@ -37,7 +37,7 @@ class QPDF_DLL_CLASS QPDFExc: public std::runtime_error
37 std::string const& object, 37 std::string const& object,
38 qpdf_offset_t offset, 38 qpdf_offset_t offset,
39 std::string const& message); 39 std::string const& message);
40 - QPDF_DLL 40 +
41 ~QPDFExc() noexcept override = default; 41 ~QPDFExc() noexcept override = default;
42 42
43 // To get a complete error string, call what(), provided by std::exception. The accessors below 43 // To get a complete error string, call what(), provided by std::exception. The accessors below
include/qpdf/QPDFFileSpecObjectHelper.hh
@@ -29,13 +29,12 @@ @@ -29,13 +29,12 @@
29 29
30 // This class provides a higher level interface around File Specification dictionaries, which are 30 // This class provides a higher level interface around File Specification dictionaries, which are
31 // discussed in section 7.11 of the ISO-32000 PDF specification. 31 // discussed in section 7.11 of the ISO-32000 PDF specification.
32 -  
33 class QPDFFileSpecObjectHelper: public QPDFObjectHelper 32 class QPDFFileSpecObjectHelper: public QPDFObjectHelper
34 { 33 {
35 public: 34 public:
36 QPDF_DLL 35 QPDF_DLL
37 QPDFFileSpecObjectHelper(QPDFObjectHandle); 36 QPDFFileSpecObjectHelper(QPDFObjectHandle);
38 - QPDF_DLL 37 +
39 ~QPDFFileSpecObjectHelper() override = default; 38 ~QPDFFileSpecObjectHelper() override = default;
40 39
41 QPDF_DLL 40 QPDF_DLL
@@ -93,7 +92,6 @@ class QPDFFileSpecObjectHelper: public QPDFObjectHelper @@ -93,7 +92,6 @@ class QPDFFileSpecObjectHelper: public QPDFObjectHelper
93 friend class QPDFFileSpecObjectHelper; 92 friend class QPDFFileSpecObjectHelper;
94 93
95 public: 94 public:
96 - QPDF_DLL  
97 ~Members() = default; 95 ~Members() = default;
98 96
99 private: 97 private:
include/qpdf/QPDFFormFieldObjectHelper.hh
@@ -20,9 +20,6 @@ @@ -20,9 +20,6 @@
20 #ifndef QPDFFORMFIELDOBJECTHELPER_HH 20 #ifndef QPDFFORMFIELDOBJECTHELPER_HH
21 #define QPDFFORMFIELDOBJECTHELPER_HH 21 #define QPDFFORMFIELDOBJECTHELPER_HH
22 22
23 -// This object helper helps with form fields for interactive forms. Please see comments in  
24 -// QPDFAcroFormDocumentHelper.hh for additional details.  
25 -  
26 #include <qpdf/QPDFObjectHelper.hh> 23 #include <qpdf/QPDFObjectHelper.hh>
27 24
28 #include <qpdf/DLL.h> 25 #include <qpdf/DLL.h>
@@ -30,6 +27,8 @@ @@ -30,6 +27,8 @@
30 27
31 class QPDFAnnotationObjectHelper; 28 class QPDFAnnotationObjectHelper;
32 29
  30 +// This object helper helps with form fields for interactive forms. Please see comments in
  31 +// QPDFAcroFormDocumentHelper.hh for additional details.
33 class QPDFFormFieldObjectHelper: public QPDFObjectHelper 32 class QPDFFormFieldObjectHelper: public QPDFObjectHelper
34 { 33 {
35 public: 34 public:
@@ -37,7 +36,7 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper @@ -37,7 +36,7 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper
37 QPDFFormFieldObjectHelper(); 36 QPDFFormFieldObjectHelper();
38 QPDF_DLL 37 QPDF_DLL
39 QPDFFormFieldObjectHelper(QPDFObjectHandle); 38 QPDFFormFieldObjectHelper(QPDFObjectHandle);
40 - QPDF_DLL 39 +
41 ~QPDFFormFieldObjectHelper() override = default; 40 ~QPDFFormFieldObjectHelper() override = default;
42 41
43 QPDF_DLL 42 QPDF_DLL
@@ -199,7 +198,6 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper @@ -199,7 +198,6 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper
199 friend class QPDFFormFieldObjectHelper; 198 friend class QPDFFormFieldObjectHelper;
200 199
201 public: 200 public:
202 - QPDF_DLL  
203 ~Members() = default; 201 ~Members() = default;
204 202
205 private: 203 private:
include/qpdf/QPDFLogger.hh
@@ -143,7 +143,6 @@ class QPDFLogger @@ -143,7 +143,6 @@ class QPDFLogger
143 friend class QPDFLogger; 143 friend class QPDFLogger;
144 144
145 public: 145 public:
146 - QPDF_DLL  
147 ~Members(); 146 ~Members();
148 147
149 private: 148 private:
include/qpdf/QPDFMatrix.hh
@@ -31,7 +31,6 @@ @@ -31,7 +31,6 @@
31 // (a, b, c, d, e, f) = │ c d 0 │ 31 // (a, b, c, d, e, f) = │ c d 0 │
32 // │ e f 1 │ 32 // │ e f 1 │
33 // └ ┘ 33 // └ ┘
34 -  
35 class QPDFMatrix 34 class QPDFMatrix
36 { 35 {
37 public: 36 public:
@@ -79,12 +78,9 @@ class QPDFMatrix @@ -79,12 +78,9 @@ class QPDFMatrix
79 // operator== tests for exact equality, not considering deltas for floating point. 78 // operator== tests for exact equality, not considering deltas for floating point.
80 QPDF_DLL 79 QPDF_DLL
81 bool operator==(QPDFMatrix const& rhs) const; 80 bool operator==(QPDFMatrix const& rhs) const;
  81 +
82 QPDF_DLL 82 QPDF_DLL
83 - bool  
84 - operator!=(QPDFMatrix const& rhs) const  
85 - {  
86 - return !operator==(rhs);  
87 - } 83 + bool operator!=(QPDFMatrix const& rhs) const;
88 84
89 double a; 85 double a;
90 double b; 86 double b;
include/qpdf/QPDFNameTreeObjectHelper.hh
@@ -28,16 +28,15 @@ @@ -28,16 +28,15 @@
28 28
29 #include <qpdf/DLL.h> 29 #include <qpdf/DLL.h>
30 30
31 -// This is an object helper for name trees. See section 7.9.6 in the PDF spec (ISO 32000) for a  
32 -// description of name trees. When looking up items in the name tree, use UTF-8 strings. All names  
33 -// are normalized for lookup purposes.  
34 -  
35 -// See examples/pdf-name-number-tree.cc for a demonstration of using QPDFNameTreeObjectHelper.  
36 -  
37 class NNTreeImpl; 31 class NNTreeImpl;
38 class NNTreeIterator; 32 class NNTreeIterator;
39 class NNTreeDetails; 33 class NNTreeDetails;
40 34
  35 +// This is an object helper for name trees. See section 7.9.6 in the PDF spec (ISO 32000) for a
  36 +// description of name trees. When looking up items in the name tree, use UTF-8 strings. All names
  37 +// are normalized for lookup purposes.
  38 +//
  39 +// See examples/pdf-name-number-tree.cc for a demonstration of using QPDFNameTreeObjectHelper.
41 class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper 40 class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper
42 { 41 {
43 public: 42 public:
@@ -78,7 +77,6 @@ class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper @@ -78,7 +77,6 @@ class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper
78 bool valid() const; 77 bool valid() const;
79 QPDF_DLL 78 QPDF_DLL
80 iterator& operator++(); 79 iterator& operator++();
81 - QPDF_DLL  
82 iterator 80 iterator
83 operator++(int) 81 operator++(int)
84 { 82 {
@@ -88,7 +86,6 @@ class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper @@ -88,7 +86,6 @@ class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper
88 } 86 }
89 QPDF_DLL 87 QPDF_DLL
90 iterator& operator--(); 88 iterator& operator--();
91 - QPDF_DLL  
92 iterator 89 iterator
93 operator--(int) 90 operator--(int)
94 { 91 {
@@ -102,7 +99,6 @@ class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper @@ -102,7 +99,6 @@ class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper
102 pointer operator->(); 99 pointer operator->();
103 QPDF_DLL 100 QPDF_DLL
104 bool operator==(iterator const& other) const; 101 bool operator==(iterator const& other) const;
105 - QPDF_DLL  
106 bool 102 bool
107 operator!=(iterator const& other) const 103 operator!=(iterator const& other) const
108 { 104 {
@@ -172,7 +168,6 @@ class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper @@ -172,7 +168,6 @@ class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper
172 friend class QPDFNameTreeObjectHelper; 168 friend class QPDFNameTreeObjectHelper;
173 169
174 public: 170 public:
175 - QPDF_DLL  
176 ~Members() = default; 171 ~Members() = default;
177 172
178 private: 173 private:
include/qpdf/QPDFNumberTreeObjectHelper.hh
@@ -27,15 +27,14 @@ @@ -27,15 +27,14 @@
27 27
28 #include <qpdf/DLL.h> 28 #include <qpdf/DLL.h>
29 29
30 -// This is an object helper for number trees. See section 7.9.7 in the PDF spec (ISO 32000) for a  
31 -// description of number trees.  
32 -  
33 -// See examples/pdf-name-number-tree.cc for a demonstration of using QPDFNumberTreeObjectHelper.  
34 -  
35 class NNTreeImpl; 30 class NNTreeImpl;
36 class NNTreeIterator; 31 class NNTreeIterator;
37 class NNTreeDetails; 32 class NNTreeDetails;
38 33
  34 +// This is an object helper for number trees. See section 7.9.7 in the PDF spec (ISO 32000) for a
  35 +// description of number trees.
  36 +//
  37 +// See examples/pdf-name-number-tree.cc for a demonstration of using QPDFNumberTreeObjectHelper.
39 class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper 38 class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper
40 { 39 {
41 public: 40 public:
@@ -93,7 +92,6 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper @@ -93,7 +92,6 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper
93 bool valid() const; 92 bool valid() const;
94 QPDF_DLL 93 QPDF_DLL
95 iterator& operator++(); 94 iterator& operator++();
96 - QPDF_DLL  
97 iterator 95 iterator
98 operator++(int) 96 operator++(int)
99 { 97 {
@@ -103,7 +101,6 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper @@ -103,7 +101,6 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper
103 } 101 }
104 QPDF_DLL 102 QPDF_DLL
105 iterator& operator--(); 103 iterator& operator--();
106 - QPDF_DLL  
107 iterator 104 iterator
108 operator--(int) 105 operator--(int)
109 { 106 {
@@ -117,7 +114,6 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper @@ -117,7 +114,6 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper
117 pointer operator->(); 114 pointer operator->();
118 QPDF_DLL 115 QPDF_DLL
119 bool operator==(iterator const& other) const; 116 bool operator==(iterator const& other) const;
120 - QPDF_DLL  
121 bool 117 bool
122 operator!=(iterator const& other) const 118 operator!=(iterator const& other) const
123 { 119 {
@@ -189,7 +185,6 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper @@ -189,7 +185,6 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper
189 typedef QPDFNumberTreeObjectHelper::numtree_number numtree_number; 185 typedef QPDFNumberTreeObjectHelper::numtree_number numtree_number;
190 186
191 public: 187 public:
192 - QPDF_DLL  
193 ~Members() = default; 188 ~Members() = default;
194 189
195 private: 190 private:
include/qpdf/QPDFObjGen.hh
@@ -35,57 +35,47 @@ class QPDFObjectHelper; @@ -35,57 +35,47 @@ class QPDFObjectHelper;
35 class QPDFObjGen 35 class QPDFObjGen
36 { 36 {
37 public: 37 public:
38 - QPDF_DLL  
39 QPDFObjGen() = default; 38 QPDFObjGen() = default;
40 - QPDF_DLL  
41 QPDFObjGen(int obj, int gen) : 39 QPDFObjGen(int obj, int gen) :
42 obj(obj), 40 obj(obj),
43 gen(gen) 41 gen(gen)
44 { 42 {
45 } 43 }
46 - QPDF_DLL  
47 bool 44 bool
48 operator<(QPDFObjGen const& rhs) const 45 operator<(QPDFObjGen const& rhs) const
49 { 46 {
50 return (obj < rhs.obj) || (obj == rhs.obj && gen < rhs.gen); 47 return (obj < rhs.obj) || (obj == rhs.obj && gen < rhs.gen);
51 } 48 }
52 - QPDF_DLL  
53 bool 49 bool
54 operator==(QPDFObjGen const& rhs) const 50 operator==(QPDFObjGen const& rhs) const
55 { 51 {
56 return obj == rhs.obj && gen == rhs.gen; 52 return obj == rhs.obj && gen == rhs.gen;
57 } 53 }
58 - QPDF_DLL  
59 bool 54 bool
60 operator!=(QPDFObjGen const& rhs) const 55 operator!=(QPDFObjGen const& rhs) const
61 { 56 {
62 return !(*this == rhs); 57 return !(*this == rhs);
63 } 58 }
64 - QPDF_DLL  
65 int 59 int
66 getObj() const 60 getObj() const
67 { 61 {
68 return obj; 62 return obj;
69 } 63 }
70 - QPDF_DLL  
71 int 64 int
72 getGen() const 65 getGen() const
73 { 66 {
74 return gen; 67 return gen;
75 } 68 }
76 - QPDF_DLL  
77 bool 69 bool
78 isIndirect() const 70 isIndirect() const
79 { 71 {
80 return obj != 0; 72 return obj != 0;
81 } 73 }
82 - QPDF_DLL  
83 std::string 74 std::string
84 unparse(char separator = ',') const 75 unparse(char separator = ',') const
85 { 76 {
86 return std::to_string(obj) + separator + std::to_string(gen); 77 return std::to_string(obj) + separator + std::to_string(gen);
87 } 78 }
88 - QPDF_DLL  
89 friend std::ostream& 79 friend std::ostream&
90 operator<<(std::ostream& os, QPDFObjGen og) 80 operator<<(std::ostream& os, QPDFObjGen og)
91 { 81 {
@@ -116,7 +106,6 @@ class QPDFObjGen @@ -116,7 +106,6 @@ class QPDFObjGen
116 public: 106 public:
117 // Add 'og' to the set. Return false if 'og' is already present in the set. Attempts to 107 // Add 'og' to the set. Return false if 'og' is already present in the set. Attempts to
118 // insert QPDFObjGen(0, 0) are ignored. 108 // insert QPDFObjGen(0, 0) are ignored.
119 - QPDF_DLL  
120 bool 109 bool
121 add(QPDFObjGen og) 110 add(QPDFObjGen og)
122 { 111 {
@@ -129,7 +118,6 @@ class QPDFObjGen @@ -129,7 +118,6 @@ class QPDFObjGen
129 return true; 118 return true;
130 } 119 }
131 120
132 - QPDF_DLL  
133 void 121 void
134 erase(QPDFObjGen og) 122 erase(QPDFObjGen og)
135 { 123 {
include/qpdf/QPDFObjectHandle.hh
@@ -156,9 +156,7 @@ class QPDFObjectHandle final: public qpdf::BaseHandle @@ -156,9 +156,7 @@ class QPDFObjectHandle final: public qpdf::BaseHandle
156 class QPDF_DLL_CLASS TokenFilter 156 class QPDF_DLL_CLASS TokenFilter
157 { 157 {
158 public: 158 public:
159 - QPDF_DLL  
160 TokenFilter() = default; 159 TokenFilter() = default;
161 - QPDF_DLL  
162 virtual ~TokenFilter() = default; 160 virtual ~TokenFilter() = default;
163 virtual void handleToken(QPDFTokenizer::Token const&) = 0; 161 virtual void handleToken(QPDFTokenizer::Token const&) = 0;
164 QPDF_DLL 162 QPDF_DLL
@@ -196,7 +194,6 @@ class QPDFObjectHandle final: public qpdf::BaseHandle @@ -196,7 +194,6 @@ class QPDFObjectHandle final: public qpdf::BaseHandle
196 class StringDecrypter 194 class StringDecrypter
197 { 195 {
198 public: 196 public:
199 - QPDF_DLL  
200 virtual ~StringDecrypter() = default; 197 virtual ~StringDecrypter() = default;
201 virtual void decryptString(std::string& val) = 0; 198 virtual void decryptString(std::string& val) = 0;
202 }; 199 };
@@ -206,7 +203,6 @@ class QPDFObjectHandle final: public qpdf::BaseHandle @@ -206,7 +203,6 @@ class QPDFObjectHandle final: public qpdf::BaseHandle
206 class QPDF_DLL_CLASS ParserCallbacks 203 class QPDF_DLL_CLASS ParserCallbacks
207 { 204 {
208 public: 205 public:
209 - QPDF_DLL  
210 virtual ~ParserCallbacks() = default; 206 virtual ~ParserCallbacks() = default;
211 // One of the handleObject methods must be overridden. 207 // One of the handleObject methods must be overridden.
212 QPDF_DLL 208 QPDF_DLL
@@ -286,18 +282,13 @@ class QPDFObjectHandle final: public qpdf::BaseHandle @@ -286,18 +282,13 @@ class QPDFObjectHandle final: public qpdf::BaseHandle
286 double f; 282 double f;
287 }; 283 };
288 284
289 - QPDF_DLL  
290 QPDFObjectHandle() = default; 285 QPDFObjectHandle() = default;
291 - QPDF_DLL  
292 QPDFObjectHandle(QPDFObjectHandle const&) = default; 286 QPDFObjectHandle(QPDFObjectHandle const&) = default;
293 - QPDF_DLL  
294 QPDFObjectHandle& operator=(QPDFObjectHandle const&) = default; 287 QPDFObjectHandle& operator=(QPDFObjectHandle const&) = default;
295 - QPDF_DLL  
296 QPDFObjectHandle(QPDFObjectHandle&&) = default; 288 QPDFObjectHandle(QPDFObjectHandle&&) = default;
297 - QPDF_DLL  
298 QPDFObjectHandle& operator=(QPDFObjectHandle&&) = default; 289 QPDFObjectHandle& operator=(QPDFObjectHandle&&) = default;
299 290
300 - [[deprecated("use operator bool()")]] QPDF_DLL inline bool isInitialized() const; 291 + [[deprecated("use operator bool()")]] inline bool isInitialized() const;
301 292
302 // This method returns true if the QPDFObjectHandle objects point to exactly the same underlying 293 // This method returns true if the QPDFObjectHandle objects point to exactly the same underlying
303 // object, meaning that changes to one are reflected in the other, or "if you paint one, the 294 // object, meaning that changes to one are reflected in the other, or "if you paint one, the
@@ -348,7 +339,7 @@ class QPDFObjectHandle final: public qpdf::BaseHandle @@ -348,7 +339,7 @@ class QPDFObjectHandle final: public qpdf::BaseHandle
348 339
349 // This returns true in addition to the query for the specific type for indirect objects. 340 // This returns true in addition to the query for the specific type for indirect objects.
350 QPDF_DLL 341 QPDF_DLL
351 - inline bool isIndirect() const; 342 + bool isIndirect() const;
352 343
353 // This returns true for indirect objects from a QPDF that has been destroyed. Trying unparse 344 // This returns true for indirect objects from a QPDF that has been destroyed. Trying unparse
354 // such an object will throw a logic_error. 345 // such an object will throw a logic_error.
@@ -1145,9 +1136,9 @@ class QPDFObjectHandle final: public qpdf::BaseHandle @@ -1145,9 +1136,9 @@ class QPDFObjectHandle final: public qpdf::BaseHandle
1145 QPDF_DLL 1136 QPDF_DLL
1146 QPDFObjGen getObjGen() const; 1137 QPDFObjGen getObjGen() const;
1147 QPDF_DLL 1138 QPDF_DLL
1148 - inline int getObjectID() const; 1139 + int getObjectID() const;
1149 QPDF_DLL 1140 QPDF_DLL
1150 - inline int getGeneration() const; 1141 + int getGeneration() const;
1151 1142
1152 QPDF_DLL 1143 QPDF_DLL
1153 std::string unparse() const; 1144 std::string unparse() const;
@@ -1424,11 +1415,9 @@ class QPDFObjectHandle::QPDFDictItems @@ -1424,11 +1415,9 @@ class QPDFObjectHandle::QPDFDictItems
1424 using pointer = T*; 1415 using pointer = T*;
1425 using reference = T&; 1416 using reference = T&;
1426 1417
1427 - QPDF_DLL  
1428 virtual ~iterator() = default; 1418 virtual ~iterator() = default;
1429 QPDF_DLL 1419 QPDF_DLL
1430 iterator& operator++(); 1420 iterator& operator++();
1431 - QPDF_DLL  
1432 iterator 1421 iterator
1433 operator++(int) 1422 operator++(int)
1434 { 1423 {
@@ -1438,7 +1427,6 @@ class QPDFObjectHandle::QPDFDictItems @@ -1438,7 +1427,6 @@ class QPDFObjectHandle::QPDFDictItems
1438 } 1427 }
1439 QPDF_DLL 1428 QPDF_DLL
1440 iterator& operator--(); 1429 iterator& operator--();
1441 - QPDF_DLL  
1442 iterator 1430 iterator
1443 operator--(int) 1431 operator--(int)
1444 { 1432 {
@@ -1452,7 +1440,6 @@ class QPDFObjectHandle::QPDFDictItems @@ -1452,7 +1440,6 @@ class QPDFObjectHandle::QPDFDictItems
1452 pointer operator->(); 1440 pointer operator->();
1453 QPDF_DLL 1441 QPDF_DLL
1454 bool operator==(iterator const& other) const; 1442 bool operator==(iterator const& other) const;
1455 - QPDF_DLL  
1456 bool 1443 bool
1457 operator!=(iterator const& other) const 1444 operator!=(iterator const& other) const
1458 { 1445 {
@@ -1468,7 +1455,6 @@ class QPDFObjectHandle::QPDFDictItems @@ -1468,7 +1455,6 @@ class QPDFObjectHandle::QPDFDictItems
1468 friend class QPDFDictItems::iterator; 1455 friend class QPDFDictItems::iterator;
1469 1456
1470 public: 1457 public:
1471 - QPDF_DLL  
1472 ~Members() = default; 1458 ~Members() = default;
1473 1459
1474 private: 1460 private:
@@ -1522,11 +1508,9 @@ class QPDFObjectHandle::QPDFArrayItems @@ -1522,11 +1508,9 @@ class QPDFObjectHandle::QPDFArrayItems
1522 using pointer = T*; 1508 using pointer = T*;
1523 using reference = T&; 1509 using reference = T&;
1524 1510
1525 - QPDF_DLL  
1526 virtual ~iterator() = default; 1511 virtual ~iterator() = default;
1527 QPDF_DLL 1512 QPDF_DLL
1528 iterator& operator++(); 1513 iterator& operator++();
1529 - QPDF_DLL  
1530 iterator 1514 iterator
1531 operator++(int) 1515 operator++(int)
1532 { 1516 {
@@ -1536,7 +1520,6 @@ class QPDFObjectHandle::QPDFArrayItems @@ -1536,7 +1520,6 @@ class QPDFObjectHandle::QPDFArrayItems
1536 } 1520 }
1537 QPDF_DLL 1521 QPDF_DLL
1538 iterator& operator--(); 1522 iterator& operator--();
1539 - QPDF_DLL  
1540 iterator 1523 iterator
1541 operator--(int) 1524 operator--(int)
1542 { 1525 {
@@ -1550,7 +1533,6 @@ class QPDFObjectHandle::QPDFArrayItems @@ -1550,7 +1533,6 @@ class QPDFObjectHandle::QPDFArrayItems
1550 pointer operator->(); 1533 pointer operator->();
1551 QPDF_DLL 1534 QPDF_DLL
1552 bool operator==(iterator const& other) const; 1535 bool operator==(iterator const& other) const;
1553 - QPDF_DLL  
1554 bool 1536 bool
1555 operator!=(iterator const& other) const 1537 operator!=(iterator const& other) const
1556 { 1538 {
@@ -1566,7 +1548,6 @@ class QPDFObjectHandle::QPDFArrayItems @@ -1566,7 +1548,6 @@ class QPDFObjectHandle::QPDFArrayItems
1566 friend class QPDFArrayItems::iterator; 1548 friend class QPDFArrayItems::iterator;
1567 1549
1568 public: 1550 public:
1569 - QPDF_DLL  
1570 ~Members() = default; 1551 ~Members() = default;
1571 1552
1572 private: 1553 private:
@@ -1607,24 +1588,6 @@ namespace qpdf @@ -1607,24 +1588,6 @@ namespace qpdf
1607 1588
1608 } // namespace qpdf 1589 } // namespace qpdf
1609 1590
1610 -inline int  
1611 -QPDFObjectHandle::getObjectID() const  
1612 -{  
1613 - return getObjGen().getObj();  
1614 -}  
1615 -  
1616 -inline int  
1617 -QPDFObjectHandle::getGeneration() const  
1618 -{  
1619 - return getObjGen().getGen();  
1620 -}  
1621 -  
1622 -inline bool  
1623 -QPDFObjectHandle::isIndirect() const  
1624 -{  
1625 - return (obj != nullptr) && (getObjectID() != 0);  
1626 -}  
1627 -  
1628 inline bool 1591 inline bool
1629 QPDFObjectHandle::isInitialized() const 1592 QPDFObjectHandle::isInitialized() const
1630 { 1593 {
include/qpdf/QPDFObjectHelper.hh
@@ -34,20 +34,17 @@ @@ -34,20 +34,17 @@
34 class QPDF_DLL_CLASS QPDFObjectHelper: public qpdf::BaseHandle 34 class QPDF_DLL_CLASS QPDFObjectHelper: public qpdf::BaseHandle
35 { 35 {
36 public: 36 public:
37 - QPDF_DLL  
38 QPDFObjectHelper(QPDFObjectHandle oh) : 37 QPDFObjectHelper(QPDFObjectHandle oh) :
39 qpdf::BaseHandle(oh.getObj()) 38 qpdf::BaseHandle(oh.getObj())
40 { 39 {
41 } 40 }
42 QPDF_DLL 41 QPDF_DLL
43 virtual ~QPDFObjectHelper(); 42 virtual ~QPDFObjectHelper();
44 - QPDF_DLL  
45 QPDFObjectHandle 43 QPDFObjectHandle
46 getObjectHandle() 44 getObjectHandle()
47 { 45 {
48 return {obj}; 46 return {obj};
49 } 47 }
50 - QPDF_DLL  
51 QPDFObjectHandle const 48 QPDFObjectHandle const
52 getObjectHandle() const 49 getObjectHandle() const
53 { 50 {
include/qpdf/QPDFOutlineDocumentHelper.hh
@@ -35,13 +35,12 @@ @@ -35,13 +35,12 @@
35 // section 12.3.3 of the PDF spec (ISO-32000). With the help of QPDFOutlineObjectHelper, the 35 // section 12.3.3 of the PDF spec (ISO-32000). With the help of QPDFOutlineObjectHelper, the
36 // outlines tree is traversed, and a bidirectional map is made between pages and outlines. See also 36 // outlines tree is traversed, and a bidirectional map is made between pages and outlines. See also
37 // QPDFOutlineObjectHelper. 37 // QPDFOutlineObjectHelper.
38 -  
39 class QPDFOutlineDocumentHelper: public QPDFDocumentHelper 38 class QPDFOutlineDocumentHelper: public QPDFDocumentHelper
40 { 39 {
41 public: 40 public:
42 QPDF_DLL 41 QPDF_DLL
43 QPDFOutlineDocumentHelper(QPDF&); 42 QPDFOutlineDocumentHelper(QPDF&);
44 - QPDF_DLL 43 +
45 ~QPDFOutlineDocumentHelper() override = default; 44 ~QPDFOutlineDocumentHelper() override = default;
46 45
47 QPDF_DLL 46 QPDF_DLL
@@ -79,7 +78,6 @@ class QPDFOutlineDocumentHelper: public QPDFDocumentHelper @@ -79,7 +78,6 @@ class QPDFOutlineDocumentHelper: public QPDFDocumentHelper
79 friend class QPDFOutlineDocumentHelper; 78 friend class QPDFOutlineDocumentHelper;
80 79
81 public: 80 public:
82 - QPDF_DLL  
83 ~Members() = default; 81 ~Members() = default;
84 82
85 private: 83 private:
include/qpdf/QPDFOutlineObjectHelper.hh
@@ -30,11 +30,9 @@ class QPDFOutlineDocumentHelper; @@ -30,11 +30,9 @@ class QPDFOutlineDocumentHelper;
30 30
31 // This is an object helper for outline items. Outlines, also known as bookmarks, are described in 31 // This is an object helper for outline items. Outlines, also known as bookmarks, are described in
32 // section 12.3.3 of the PDF spec (ISO-32000). See comments below for details. 32 // section 12.3.3 of the PDF spec (ISO-32000). See comments below for details.
33 -  
34 class QPDFOutlineObjectHelper: public QPDFObjectHelper 33 class QPDFOutlineObjectHelper: public QPDFObjectHelper
35 { 34 {
36 public: 35 public:
37 - QPDF_DLL  
38 ~QPDFOutlineObjectHelper() override 36 ~QPDFOutlineObjectHelper() override
39 { 37 {
40 // This must be cleared explicitly to avoid circular references that prevent cleanup of 38 // This must be cleared explicitly to avoid circular references that prevent cleanup of
@@ -87,7 +85,6 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper @@ -87,7 +85,6 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper
87 }; 85 };
88 86
89 private: 87 private:
90 - QPDF_DLL  
91 QPDFOutlineObjectHelper(QPDFObjectHandle, QPDFOutlineDocumentHelper&, int); 88 QPDFOutlineObjectHelper(QPDFObjectHandle, QPDFOutlineDocumentHelper&, int);
92 89
93 class Members 90 class Members
@@ -95,7 +92,6 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper @@ -95,7 +92,6 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper
95 friend class QPDFOutlineObjectHelper; 92 friend class QPDFOutlineObjectHelper;
96 93
97 public: 94 public:
98 - QPDF_DLL  
99 ~Members() = default; 95 ~Members() = default;
100 96
101 private: 97 private:
include/qpdf/QPDFPageDocumentHelper.hh
@@ -37,7 +37,7 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper @@ -37,7 +37,7 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper
37 public: 37 public:
38 QPDF_DLL 38 QPDF_DLL
39 QPDFPageDocumentHelper(QPDF&); 39 QPDFPageDocumentHelper(QPDF&);
40 - QPDF_DLL 40 +
41 ~QPDFPageDocumentHelper() override = default; 41 ~QPDFPageDocumentHelper() override = default;
42 42
43 // Traverse page tree, and return all /Page objects wrapped in QPDFPageObjectHelper objects. 43 // Traverse page tree, and return all /Page objects wrapped in QPDFPageObjectHelper objects.
@@ -117,7 +117,6 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper @@ -117,7 +117,6 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper
117 friend class QPDFPageDocumentHelper; 117 friend class QPDFPageDocumentHelper;
118 118
119 public: 119 public:
120 - QPDF_DLL  
121 ~Members() = default; 120 ~Members() = default;
122 121
123 private: 122 private:
include/qpdf/QPDFPageLabelDocumentHelper.hh
@@ -44,7 +44,7 @@ class QPDFPageLabelDocumentHelper: public QPDFDocumentHelper @@ -44,7 +44,7 @@ class QPDFPageLabelDocumentHelper: public QPDFDocumentHelper
44 public: 44 public:
45 QPDF_DLL 45 QPDF_DLL
46 QPDFPageLabelDocumentHelper(QPDF&); 46 QPDFPageLabelDocumentHelper(QPDF&);
47 - QPDF_DLL 47 +
48 ~QPDFPageLabelDocumentHelper() override = default; 48 ~QPDFPageLabelDocumentHelper() override = default;
49 49
50 QPDF_DLL 50 QPDF_DLL
@@ -82,7 +82,6 @@ class QPDFPageLabelDocumentHelper: public QPDFDocumentHelper @@ -82,7 +82,6 @@ class QPDFPageLabelDocumentHelper: public QPDFDocumentHelper
82 friend class QPDFPageLabelDocumentHelper; 82 friend class QPDFPageLabelDocumentHelper;
83 83
84 public: 84 public:
85 - QPDF_DLL  
86 ~Members() = default; 85 ~Members() = default;
87 86
88 private: 87 private:
include/qpdf/QPDFPageObjectHelper.hh
@@ -31,15 +31,14 @@ @@ -31,15 +31,14 @@
31 31
32 class QPDFAcroFormDocumentHelper; 32 class QPDFAcroFormDocumentHelper;
33 33
  34 +// This is a helper class for page objects, but as of qpdf 10.1, many of the methods also work
  35 +// for form XObjects. When this is the case, it is noted in the comment.
34 class QPDFPageObjectHelper: public QPDFObjectHelper 36 class QPDFPageObjectHelper: public QPDFObjectHelper
35 { 37 {
36 - // This is a helper class for page objects, but as of qpdf 10.1, many of the methods also work  
37 - // for form XObjects. When this is the case, it is noted in the comment.  
38 -  
39 public: 38 public:
40 QPDF_DLL 39 QPDF_DLL
41 QPDFPageObjectHelper(QPDFObjectHandle); 40 QPDFPageObjectHelper(QPDFObjectHandle);
42 - QPDF_DLL 41 +
43 ~QPDFPageObjectHelper() override = default; 42 ~QPDFPageObjectHelper() override = default;
44 43
45 // PAGE ATTRIBUTES 44 // PAGE ATTRIBUTES
@@ -411,7 +410,6 @@ class QPDFPageObjectHelper: public QPDFObjectHelper @@ -411,7 +410,6 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
411 friend class QPDFPageObjectHelper; 410 friend class QPDFPageObjectHelper;
412 411
413 public: 412 public:
414 - QPDF_DLL  
415 ~Members() = default; 413 ~Members() = default;
416 414
417 private: 415 private:
include/qpdf/QPDFStreamFilter.hh
@@ -27,10 +27,8 @@ @@ -27,10 +27,8 @@
27 class QPDF_DLL_CLASS QPDFStreamFilter 27 class QPDF_DLL_CLASS QPDFStreamFilter
28 { 28 {
29 public: 29 public:
30 - QPDF_DLL  
31 QPDFStreamFilter() = default; 30 QPDFStreamFilter() = default;
32 31
33 - QPDF_DLL  
34 virtual ~QPDFStreamFilter() = default; 32 virtual ~QPDFStreamFilter() = default;
35 33
36 // A QPDFStreamFilter class must implement, at a minimum, setDecodeParms() and 34 // A QPDFStreamFilter class must implement, at a minimum, setDecodeParms() and
include/qpdf/QPDFSystemError.hh
@@ -32,7 +32,7 @@ class QPDF_DLL_CLASS QPDFSystemError: public std::runtime_error @@ -32,7 +32,7 @@ class QPDF_DLL_CLASS QPDFSystemError: public std::runtime_error
32 public: 32 public:
33 QPDF_DLL 33 QPDF_DLL
34 QPDFSystemError(std::string const& description, int system_errno); 34 QPDFSystemError(std::string const& description, int system_errno);
35 - QPDF_DLL 35 +
36 ~QPDFSystemError() noexcept override = default; 36 ~QPDFSystemError() noexcept override = default;
37 37
38 // To get a complete error string, call what(), provided by std::exception. The accessors below 38 // To get a complete error string, call what(), provided by std::exception. The accessors below
include/qpdf/QPDFUsage.hh
@@ -30,7 +30,6 @@ class QPDF_DLL_CLASS QPDFUsage: public std::runtime_error @@ -30,7 +30,6 @@ class QPDF_DLL_CLASS QPDFUsage: public std::runtime_error
30 public: 30 public:
31 QPDF_DLL 31 QPDF_DLL
32 QPDFUsage(std::string const& msg); 32 QPDFUsage(std::string const& msg);
33 - QPDF_DLL  
34 ~QPDFUsage() noexcept override = default; 33 ~QPDFUsage() noexcept override = default;
35 }; 34 };
36 35
include/qpdf/QPDFWriter.hh
@@ -17,9 +17,6 @@ @@ -17,9 +17,6 @@
17 // License. At your option, you may continue to consider qpdf to be licensed under those terms. 17 // License. At your option, you may continue to consider qpdf to be licensed under those terms.
18 // Please see the manual for additional information. 18 // Please see the manual for additional information.
19 19
20 -// This class implements a simple writer for saving QPDF objects to new PDF files. See comments  
21 -// through the header file for additional details.  
22 -  
23 #ifndef QPDFWRITER_HH 20 #ifndef QPDFWRITER_HH
24 #define QPDFWRITER_HH 21 #define QPDFWRITER_HH
25 22
@@ -51,6 +48,8 @@ class QPDF; @@ -51,6 +48,8 @@ class QPDF;
51 class Pl_Count; 48 class Pl_Count;
52 class Pl_MD5; 49 class Pl_MD5;
53 50
  51 +// This class implements a simple writer for saving QPDF objects to new PDF files. See comments
  52 +// through the header file for additional details.
54 class QPDFWriter 53 class QPDFWriter
55 { 54 {
56 public: 55 public:
@@ -71,7 +70,6 @@ class QPDFWriter @@ -71,7 +70,6 @@ class QPDFWriter
71 QPDF_DLL 70 QPDF_DLL
72 QPDFWriter(QPDF& pdf, char const* description, FILE* file, bool close_file); 71 QPDFWriter(QPDF& pdf, char const* description, FILE* file, bool close_file);
73 72
74 - QPDF_DLL  
75 ~QPDFWriter() = default; 73 ~QPDFWriter() = default;
76 74
77 class QPDF_DLL_CLASS ProgressReporter 75 class QPDF_DLL_CLASS ProgressReporter
include/qpdf/QPDFXRefEntry.hh
@@ -37,14 +37,12 @@ class QPDFXRefEntry @@ -37,14 +37,12 @@ class QPDFXRefEntry
37 QPDF_DLL 37 QPDF_DLL
38 QPDFXRefEntry(int type, qpdf_offset_t field1, int field2); 38 QPDFXRefEntry(int type, qpdf_offset_t field1, int field2);
39 // Create a type 1 "uncompressed" entry. 39 // Create a type 1 "uncompressed" entry.
40 - QPDF_DLL  
41 QPDFXRefEntry(qpdf_offset_t offset) : 40 QPDFXRefEntry(qpdf_offset_t offset) :
42 type(1), 41 type(1),
43 field1(offset) 42 field1(offset)
44 { 43 {
45 } 44 }
46 // Create a type 2 "compressed" entry. 45 // Create a type 2 "compressed" entry.
47 - QPDF_DLL  
48 QPDFXRefEntry(int stream_number, int index) : 46 QPDFXRefEntry(int stream_number, int index) :
49 type(2), 47 type(2),
50 field1(stream_number), 48 field1(stream_number),
include/qpdf/QUtil.hh
@@ -190,7 +190,7 @@ namespace QUtil @@ -190,7 +190,7 @@ namespace QUtil
190 190
191 // Returns lower-case hex-encoded version of the char including a leading "#". 191 // Returns lower-case hex-encoded version of the char including a leading "#".
192 QPDF_DLL 192 QPDF_DLL
193 - inline std::string hex_encode_char(char); 193 + std::string hex_encode_char(char);
194 194
195 // Returns a string that is the result of decoding the input string. The input string may 195 // Returns a string that is the result of decoding the input string. The input string may
196 // consist of mixed case hexadecimal digits. Any characters that are not hexadecimal digits will 196 // consist of mixed case hexadecimal digits. Any characters that are not hexadecimal digits will
@@ -202,7 +202,7 @@ namespace QUtil @@ -202,7 +202,7 @@ namespace QUtil
202 // Decode a single hex digit into a char in the range 0 <= char < 16. Return a char >= 16 if 202 // Decode a single hex digit into a char in the range 0 <= char < 16. Return a char >= 16 if
203 // digit is not a valid hex digit. 203 // digit is not a valid hex digit.
204 QPDF_DLL 204 QPDF_DLL
205 - inline constexpr char hex_decode_char(char digit) noexcept; 205 + char hex_decode_char(char digit);
206 206
207 // Set stdin, stdout to binary mode 207 // Set stdin, stdout to binary mode
208 QPDF_DLL 208 QPDF_DLL
@@ -431,16 +431,16 @@ namespace QUtil @@ -431,16 +431,16 @@ namespace QUtil
431 // These routines help the tokenizer recognize certain character classes without using ctype, 431 // These routines help the tokenizer recognize certain character classes without using ctype,
432 // which we avoid because of locale considerations. 432 // which we avoid because of locale considerations.
433 QPDF_DLL 433 QPDF_DLL
434 - inline bool is_hex_digit(char); 434 + bool is_hex_digit(char);
435 435
436 QPDF_DLL 436 QPDF_DLL
437 - inline bool is_space(char); 437 + bool is_space(char);
438 438
439 QPDF_DLL 439 QPDF_DLL
440 - inline bool is_digit(char); 440 + bool is_digit(char);
441 441
442 QPDF_DLL 442 QPDF_DLL
443 - inline bool is_number(char const*); 443 + bool is_number(char const*);
444 444
445 // This method parses the numeric range syntax used by the qpdf command-line tool. May throw 445 // This method parses the numeric range syntax used by the qpdf command-line tool. May throw
446 // std::runtime_error. A numeric range is as comma-separated list of groups. A group may be a 446 // std::runtime_error. A numeric range is as comma-separated list of groups. A group may be a
@@ -489,65 +489,4 @@ namespace QUtil @@ -489,65 +489,4 @@ namespace QUtil
489 size_t get_max_memory_usage(); 489 size_t get_max_memory_usage();
490 }; // namespace QUtil 490 }; // namespace QUtil
491 491
492 -inline bool  
493 -QUtil::is_hex_digit(char ch)  
494 -{  
495 - return hex_decode_char(ch) < '\20';  
496 -}  
497 -  
498 -inline bool  
499 -QUtil::is_space(char ch)  
500 -{  
501 - return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t' || ch == '\f' || ch == '\v';  
502 -}  
503 -  
504 -inline bool  
505 -QUtil::is_digit(char ch)  
506 -{  
507 - return ((ch >= '0') && (ch <= '9'));  
508 -}  
509 -  
510 -inline bool  
511 -QUtil::is_number(char const* p)  
512 -{  
513 - // ^[\+\-]?(\.\d*|\d+(\.\d*)?)$  
514 - if (!*p) {  
515 - return false;  
516 - }  
517 - if ((*p == '-') || (*p == '+')) {  
518 - ++p;  
519 - }  
520 - bool found_dot = false;  
521 - bool found_digit = false;  
522 - for (; *p; ++p) {  
523 - if (*p == '.') {  
524 - if (found_dot) {  
525 - // only one dot  
526 - return false;  
527 - }  
528 - found_dot = true;  
529 - } else if (QUtil::is_digit(*p)) {  
530 - found_digit = true;  
531 - } else {  
532 - return false;  
533 - }  
534 - }  
535 - return found_digit;  
536 -}  
537 -  
538 -inline std::string  
539 -QUtil::hex_encode_char(char c)  
540 -{  
541 - static auto constexpr hexchars = "0123456789abcdef";  
542 - return {'#', hexchars[static_cast<unsigned char>(c) >> 4], hexchars[c & 0x0f]};  
543 -}  
544 -  
545 -inline constexpr char  
546 -QUtil::hex_decode_char(char digit) noexcept  
547 -{  
548 - return digit <= '9' && digit >= '0'  
549 - ? char(digit - '0')  
550 - : (digit >= 'a' ? char(digit - 'a' + 10) : (digit >= 'A' ? char(digit - 'A' + 10) : '\20'));  
551 -}  
552 -  
553 #endif // QUTIL_HH 492 #endif // QUTIL_HH
libqpdf/FileInputSource.cc
@@ -5,12 +5,6 @@ @@ -5,12 +5,6 @@
5 #include <algorithm> 5 #include <algorithm>
6 #include <cstring> 6 #include <cstring>
7 7
8 -FileInputSource::FileInputSource() :  
9 - close_file(false),  
10 - file(nullptr)  
11 -{  
12 -}  
13 -  
14 FileInputSource::FileInputSource(char const* filename) : 8 FileInputSource::FileInputSource(char const* filename) :
15 close_file(true), 9 close_file(true),
16 filename(filename), 10 filename(filename),
libqpdf/JSON.cc
@@ -8,9 +8,13 @@ @@ -8,9 +8,13 @@
8 #include <qpdf/Pl_String.hh> 8 #include <qpdf/Pl_String.hh>
9 #include <qpdf/QTC.hh> 9 #include <qpdf/QTC.hh>
10 #include <qpdf/QUtil.hh> 10 #include <qpdf/QUtil.hh>
  11 +#include <qpdf/Util.hh>
  12 +
11 #include <cstring> 13 #include <cstring>
12 #include <stdexcept> 14 #include <stdexcept>
13 15
  16 +using namespace qpdf;
  17 +
14 JSON::Members::Members(std::unique_ptr<JSON_value> value) : 18 JSON::Members::Members(std::unique_ptr<JSON_value> value) :
15 value(std::move(value)) 19 value(std::move(value))
16 { 20 {
@@ -761,7 +765,7 @@ JSONParser::tokenError() @@ -761,7 +765,7 @@ JSONParser::tokenError()
761 QTC::TC("libtests", "JSON parse unexpected sign"); 765 QTC::TC("libtests", "JSON parse unexpected sign");
762 throw std::runtime_error( 766 throw std::runtime_error(
763 "JSON: offset " + std::to_string(offset) + ": numeric literal: unexpected sign"); 767 "JSON: offset " + std::to_string(offset) + ": numeric literal: unexpected sign");
764 - } else if (QUtil::is_space(*p) || strchr("{}[]:,", *p)) { 768 + } else if (util::is_space(*p) || strchr("{}[]:,", *p)) {
765 QTC::TC("libtests", "JSON parse incomplete number"); 769 QTC::TC("libtests", "JSON parse incomplete number");
766 throw std::runtime_error( 770 throw std::runtime_error(
767 "JSON: offset " + std::to_string(offset) + ": numeric literal: incomplete number"); 771 "JSON: offset " + std::to_string(offset) + ": numeric literal: incomplete number");
@@ -1078,7 +1082,7 @@ JSONParser::getToken() @@ -1078,7 +1082,7 @@ JSONParser::getToken()
1078 1082
1079 case ls_u4: 1083 case ls_u4:
1080 using ui = unsigned int; 1084 using ui = unsigned int;
1081 - if (ui val = ui(QUtil::hex_decode_char(*p)); val < 16) { 1085 + if (ui val = ui(util::hex_decode_char(*p)); val < 16) {
1082 u_value = 16 * u_value + val; 1086 u_value = 16 * u_value + val;
1083 } else { 1087 } else {
1084 tokenError(); 1088 tokenError();
libqpdf/PDFVersion.cc
@@ -2,11 +2,6 @@ @@ -2,11 +2,6 @@
2 2
3 #include <qpdf/QUtil.hh> 3 #include <qpdf/QUtil.hh>
4 4
5 -PDFVersion::PDFVersion() :  
6 - PDFVersion(0, 0, 0)  
7 -{  
8 -}  
9 -  
10 PDFVersion::PDFVersion(int major_version, int minor_version, int extension_level) : 5 PDFVersion::PDFVersion(int major_version, int minor_version, int extension_level) :
11 major_version(major_version), 6 major_version(major_version),
12 minor_version(minor_version), 7 minor_version(minor_version),
libqpdf/Pl_Base64.cc
@@ -2,9 +2,13 @@ @@ -2,9 +2,13 @@
2 2
3 #include <qpdf/QIntC.hh> 3 #include <qpdf/QIntC.hh>
4 #include <qpdf/QUtil.hh> 4 #include <qpdf/QUtil.hh>
  5 +#include <qpdf/Util.hh>
  6 +
5 #include <cstring> 7 #include <cstring>
6 #include <stdexcept> 8 #include <stdexcept>
7 9
  10 +using namespace qpdf;
  11 +
8 static char 12 static char
9 to_c(unsigned int ch) 13 to_c(unsigned int ch)
10 { 14 {
@@ -50,7 +54,7 @@ Pl_Base64::decode(unsigned char const* data, size_t len) @@ -50,7 +54,7 @@ Pl_Base64::decode(unsigned char const* data, size_t len)
50 { 54 {
51 unsigned char const* p = data; 55 unsigned char const* p = data;
52 while (len > 0) { 56 while (len > 0) {
53 - if (!QUtil::is_space(to_c(*p))) { 57 + if (!util::is_space(to_c(*p))) {
54 this->buf[this->pos++] = *p; 58 this->buf[this->pos++] = *p;
55 if (this->pos == 4) { 59 if (this->pos == 4) {
56 flush(); 60 flush();
libqpdf/Pl_Buffer.cc
@@ -5,16 +5,24 @@ @@ -5,16 +5,24 @@
5 #include <cstring> 5 #include <cstring>
6 #include <stdexcept> 6 #include <stdexcept>
7 7
  8 +class Pl_Buffer::Members
  9 +{
  10 + public:
  11 + Members() = default;
  12 + Members(Members const&) = delete;
  13 +
  14 + bool ready{true};
  15 + std::string data;
  16 +};
  17 +
8 Pl_Buffer::Pl_Buffer(char const* identifier, Pipeline* next) : 18 Pl_Buffer::Pl_Buffer(char const* identifier, Pipeline* next) :
9 Pipeline(identifier, next), 19 Pipeline(identifier, next),
10 - m(new Members()) 20 + m(std::make_unique<Members>())
11 { 21 {
12 } 22 }
13 23
14 -Pl_Buffer::~Pl_Buffer() // NOLINT (modernize-use-equals-default)  
15 -{  
16 - // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer  
17 -} 24 +// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
  25 +Pl_Buffer::~Pl_Buffer() = default;
18 26
19 void 27 void
20 Pl_Buffer::write(unsigned char const* buf, size_t len) 28 Pl_Buffer::write(unsigned char const* buf, size_t len)
libqpdf/Pl_Concatenate.cc
@@ -10,10 +10,8 @@ Pl_Concatenate::Pl_Concatenate(char const* identifier, Pipeline* next) : @@ -10,10 +10,8 @@ Pl_Concatenate::Pl_Concatenate(char const* identifier, Pipeline* next) :
10 } 10 }
11 } 11 }
12 12
13 -Pl_Concatenate::~Pl_Concatenate() // NOLINT (modernize-use-equals-default)  
14 -{  
15 - // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer  
16 -} 13 +// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
  14 +Pl_Concatenate::~Pl_Concatenate() = default;
17 15
18 void 16 void
19 Pl_Concatenate::write(unsigned char const* data, size_t len) 17 Pl_Concatenate::write(unsigned char const* data, size_t len)
libqpdf/Pl_Count.cc
@@ -2,13 +2,21 @@ @@ -2,13 +2,21 @@
2 2
3 #include <qpdf/QIntC.hh> 3 #include <qpdf/QIntC.hh>
4 4
5 -Pl_Count::Members::Members() 5 +class Pl_Count::Members
6 { 6 {
7 -} 7 + public:
  8 + Members() = default;
  9 + Members(Members const&) = delete;
  10 + ~Members() = default;
  11 +
  12 + // Must be qpdf_offset_t, not size_t, to handle writing more than size_t can handle.
  13 + qpdf_offset_t count{0};
  14 + unsigned char last_char{'\0'};
  15 +};
8 16
9 Pl_Count::Pl_Count(char const* identifier, Pipeline* next) : 17 Pl_Count::Pl_Count(char const* identifier, Pipeline* next) :
10 Pipeline(identifier, next), 18 Pipeline(identifier, next),
11 - m(new Members()) 19 + m(std::make_unique<Members>())
12 { 20 {
13 if (!next) { 21 if (!next) {
14 throw std::logic_error("Attempt to create Pl_Count with nullptr as next"); 22 throw std::logic_error("Attempt to create Pl_Count with nullptr as next");
libqpdf/Pl_DCT.cc
@@ -57,31 +57,52 @@ progress_monitor(j_common_ptr cinfo) @@ -57,31 +57,52 @@ progress_monitor(j_common_ptr cinfo)
57 } 57 }
58 } 58 }
59 59
60 -Pl_DCT::Members::Members() :  
61 - action(a_decompress),  
62 - buf("DCT compressed image") 60 +class Pl_DCT::Members
63 { 61 {
64 -} 62 + public:
  63 + // For compression
  64 + Members(
  65 + JDIMENSION image_width,
  66 + JDIMENSION image_height,
  67 + int components,
  68 + J_COLOR_SPACE color_space,
  69 + CompressConfig* config_callback) :
  70 + action(a_compress),
  71 + buf("DCT uncompressed image"),
  72 + image_width(image_width),
  73 + image_height(image_height),
  74 + components(components),
  75 + color_space(color_space),
  76 + config_callback(config_callback)
  77 + {
  78 + }
65 79
66 -Pl_DCT::Members::Members(  
67 - JDIMENSION image_width,  
68 - JDIMENSION image_height,  
69 - int components,  
70 - J_COLOR_SPACE color_space,  
71 - CompressConfig* config_callback) :  
72 - action(a_compress),  
73 - buf("DCT uncompressed image"),  
74 - image_width(image_width),  
75 - image_height(image_height),  
76 - components(components),  
77 - color_space(color_space),  
78 - config_callback(config_callback)  
79 -{  
80 -} 80 + // For decompression
  81 + Members() :
  82 + action(a_decompress),
  83 + buf("DCT compressed image")
  84 + {
  85 + }
  86 +
  87 + Members(Members const&) = delete;
  88 +
  89 + ~Members() = default;
  90 +
  91 + action_e action;
  92 + Pl_Buffer buf;
  93 +
  94 + // Used for compression
  95 + JDIMENSION image_width{0};
  96 + JDIMENSION image_height{0};
  97 + int components{1};
  98 + J_COLOR_SPACE color_space{JCS_GRAYSCALE};
  99 +
  100 + CompressConfig* config_callback{nullptr};
  101 +};
81 102
82 Pl_DCT::Pl_DCT(char const* identifier, Pipeline* next) : 103 Pl_DCT::Pl_DCT(char const* identifier, Pipeline* next) :
83 Pipeline(identifier, next), 104 Pipeline(identifier, next),
84 - m(new Members()) 105 + m(std::make_unique<Members>())
85 { 106 {
86 if (!next) { 107 if (!next) {
87 throw std::logic_error("Attempt to create Pl_DCT with nullptr as next"); 108 throw std::logic_error("Attempt to create Pl_DCT with nullptr as next");
@@ -115,14 +136,13 @@ Pl_DCT::Pl_DCT( @@ -115,14 +136,13 @@ Pl_DCT::Pl_DCT(
115 J_COLOR_SPACE color_space, 136 J_COLOR_SPACE color_space,
116 CompressConfig* compress_callback) : 137 CompressConfig* compress_callback) :
117 Pipeline(identifier, next), 138 Pipeline(identifier, next),
118 - m(new Members(image_width, image_height, components, color_space, compress_callback)) 139 + m(std::make_unique<Members>(
  140 + image_width, image_height, components, color_space, compress_callback))
119 { 141 {
120 } 142 }
121 143
122 -Pl_DCT::~Pl_DCT() // NOLINT (modernize-use-equals-default)  
123 -{  
124 - // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer  
125 -} 144 +// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
  145 +Pl_DCT::~Pl_DCT() = default;
126 146
127 void 147 void
128 Pl_DCT::write(unsigned char const* data, size_t len) 148 Pl_DCT::write(unsigned char const* data, size_t len)
libqpdf/Pl_Discard.cc
@@ -2,15 +2,16 @@ @@ -2,15 +2,16 @@
2 2
3 // Exercised in md5 test suite 3 // Exercised in md5 test suite
4 4
  5 +// Pl_Discard does not use the member pattern as thee is no prospect of it ever requiring data
  6 +// members.
  7 +
5 Pl_Discard::Pl_Discard() : 8 Pl_Discard::Pl_Discard() :
6 Pipeline("discard", nullptr) 9 Pipeline("discard", nullptr)
7 { 10 {
8 } 11 }
9 12
10 -Pl_Discard::~Pl_Discard() // NOLINT (modernize-use-equals-default)  
11 -{  
12 - // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer  
13 -} 13 +// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
  14 +Pl_Discard::~Pl_Discard() = default;
14 15
15 void 16 void
16 Pl_Discard::write(unsigned char const* buf, size_t len) 17 Pl_Discard::write(unsigned char const* buf, size_t len)
libqpdf/Pl_Flate.cc
@@ -68,17 +68,15 @@ Pl_Flate::Members::~Members() @@ -68,17 +68,15 @@ Pl_Flate::Members::~Members()
68 Pl_Flate::Pl_Flate( 68 Pl_Flate::Pl_Flate(
69 char const* identifier, Pipeline* next, action_e action, unsigned int out_bufsize_int) : 69 char const* identifier, Pipeline* next, action_e action, unsigned int out_bufsize_int) :
70 Pipeline(identifier, next), 70 Pipeline(identifier, next),
71 - m(std::shared_ptr<Members>(new Members(QIntC::to_size(out_bufsize_int), action))) 71 + m(std::make_unique<Members>(QIntC::to_size(out_bufsize_int), action))
72 { 72 {
73 if (!next) { 73 if (!next) {
74 throw std::logic_error("Attempt to create Pl_Flate with nullptr as next"); 74 throw std::logic_error("Attempt to create Pl_Flate with nullptr as next");
75 } 75 }
76 } 76 }
77 77
78 -Pl_Flate::~Pl_Flate() // NOLINT (modernize-use-equals-default)  
79 -{  
80 - // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer  
81 -} 78 +// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
  79 +Pl_Flate::~Pl_Flate() = default;
82 80
83 unsigned long long 81 unsigned long long
84 Pl_Flate::memory_limit() 82 Pl_Flate::memory_limit()
libqpdf/Pl_Function.cc
@@ -2,20 +2,28 @@ @@ -2,20 +2,28 @@
2 2
3 #include <stdexcept> 3 #include <stdexcept>
4 4
5 -Pl_Function::Members::Members(writer_t fn) :  
6 - fn(fn) 5 +class Pl_Function::Members
7 { 6 {
8 -} 7 + public:
  8 + Members(writer_t fn) :
  9 + fn(fn)
  10 + {
  11 + }
  12 + Members(Members const&) = delete;
  13 + ~Members() = default;
  14 +
  15 + writer_t fn;
  16 +};
9 17
10 Pl_Function::Pl_Function(char const* identifier, Pipeline* next, writer_t fn) : 18 Pl_Function::Pl_Function(char const* identifier, Pipeline* next, writer_t fn) :
11 Pipeline(identifier, next), 19 Pipeline(identifier, next),
12 - m(new Members(fn)) 20 + m(std::make_unique<Members>(fn))
13 { 21 {
14 } 22 }
15 23
16 Pl_Function::Pl_Function(char const* identifier, Pipeline* next, writer_c_t fn, void* udata) : 24 Pl_Function::Pl_Function(char const* identifier, Pipeline* next, writer_c_t fn, void* udata) :
17 Pipeline(identifier, next), 25 Pipeline(identifier, next),
18 - m(new Members(nullptr)) 26 + m(std::make_unique<Members>(nullptr))
19 { 27 {
20 m->fn = [identifier, fn, udata](unsigned char const* data, size_t len) { 28 m->fn = [identifier, fn, udata](unsigned char const* data, size_t len) {
21 int code = fn(data, len, udata); 29 int code = fn(data, len, udata);
libqpdf/Pl_OStream.cc
@@ -2,21 +2,27 @@ @@ -2,21 +2,27 @@
2 2
3 #include <stdexcept> 3 #include <stdexcept>
4 4
5 -Pl_OStream::Members::Members(std::ostream& os) :  
6 - os(os) 5 +class Pl_OStream::Members
7 { 6 {
8 -} 7 + public:
  8 + Members(std::ostream& os) :
  9 + os(os)
  10 + {
  11 + }
  12 + Members(Members const&) = delete;
  13 + ~Members() = default;
  14 +
  15 + std::ostream& os;
  16 +};
9 17
10 Pl_OStream::Pl_OStream(char const* identifier, std::ostream& os) : 18 Pl_OStream::Pl_OStream(char const* identifier, std::ostream& os) :
11 Pipeline(identifier, nullptr), 19 Pipeline(identifier, nullptr),
12 - m(new Members(os)) 20 + m(std::make_unique<Members>(os))
13 { 21 {
14 } 22 }
15 23
16 -Pl_OStream::~Pl_OStream() // NOLINT (modernize-use-equals-default)  
17 -{  
18 - // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer  
19 -} 24 +// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
  25 +Pl_OStream::~Pl_OStream() = default;
20 26
21 void 27 void
22 Pl_OStream::write(unsigned char const* buf, size_t len) 28 Pl_OStream::write(unsigned char const* buf, size_t len)
libqpdf/Pl_QPDFTokenizer.cc
@@ -4,15 +4,22 @@ @@ -4,15 +4,22 @@
4 #include <qpdf/QTC.hh> 4 #include <qpdf/QTC.hh>
5 #include <stdexcept> 5 #include <stdexcept>
6 6
7 -Pl_QPDFTokenizer::Members::Members() :  
8 - buf("tokenizer buffer") 7 +class Pl_QPDFTokenizer::Members
9 { 8 {
10 -} 9 + public:
  10 + Members() = default;
  11 + Members(Members const&) = delete;
  12 + ~Members() = default;
  13 +
  14 + QPDFObjectHandle::TokenFilter* filter{nullptr};
  15 + QPDFTokenizer tokenizer;
  16 + Pl_Buffer buf{"tokenizer buffer"};
  17 +};
11 18
12 Pl_QPDFTokenizer::Pl_QPDFTokenizer( 19 Pl_QPDFTokenizer::Pl_QPDFTokenizer(
13 char const* identifier, QPDFObjectHandle::TokenFilter* filter, Pipeline* next) : 20 char const* identifier, QPDFObjectHandle::TokenFilter* filter, Pipeline* next) :
14 Pipeline(identifier, next), 21 Pipeline(identifier, next),
15 - m(new Members) 22 + m(std::make_unique<Members>())
16 { 23 {
17 m->filter = filter; 24 m->filter = filter;
18 QPDFObjectHandle::TokenFilter::PipelineAccessor::setPipeline(m->filter, next); 25 QPDFObjectHandle::TokenFilter::PipelineAccessor::setPipeline(m->filter, next);
@@ -20,10 +27,8 @@ Pl_QPDFTokenizer::Pl_QPDFTokenizer( @@ -20,10 +27,8 @@ Pl_QPDFTokenizer::Pl_QPDFTokenizer(
20 m->tokenizer.includeIgnorable(); 27 m->tokenizer.includeIgnorable();
21 } 28 }
22 29
23 -Pl_QPDFTokenizer::~Pl_QPDFTokenizer() // NOLINT (modernize-use-equals-default)  
24 -{  
25 - // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer  
26 -} 30 +// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
  31 +Pl_QPDFTokenizer::~Pl_QPDFTokenizer() = default;
27 32
28 void 33 void
29 Pl_QPDFTokenizer::write(unsigned char const* data, size_t len) 34 Pl_QPDFTokenizer::write(unsigned char const* data, size_t len)
libqpdf/Pl_RunLength.cc
@@ -8,14 +8,26 @@ namespace @@ -8,14 +8,26 @@ namespace
8 unsigned long long memory_limit{0}; 8 unsigned long long memory_limit{0};
9 } // namespace 9 } // namespace
10 10
11 -Pl_RunLength::Members::Members(action_e action) :  
12 - action(action) 11 +class Pl_RunLength::Members
13 { 12 {
14 -} 13 + public:
  14 + Members(action_e action) :
  15 + action(action)
  16 + {
  17 + }
  18 + Members(Members const&) = delete;
  19 + ~Members() = default;
  20 +
  21 + action_e action;
  22 + state_e state{st_top};
  23 + unsigned char buf[128];
  24 + unsigned int length{0};
  25 + std::string out;
  26 +};
15 27
16 Pl_RunLength::Pl_RunLength(char const* identifier, Pipeline* next, action_e action) : 28 Pl_RunLength::Pl_RunLength(char const* identifier, Pipeline* next, action_e action) :
17 Pipeline(identifier, next), 29 Pipeline(identifier, next),
18 - m(new Members(action)) 30 + m(std::make_unique<Members>(action))
19 { 31 {
20 if (!next) { 32 if (!next) {
21 throw std::logic_error("Attempt to create Pl_RunLength with nullptr as next"); 33 throw std::logic_error("Attempt to create Pl_RunLength with nullptr as next");
libqpdf/Pl_StdioFile.cc
@@ -6,21 +6,27 @@ @@ -6,21 +6,27 @@
6 #include <cerrno> 6 #include <cerrno>
7 #include <stdexcept> 7 #include <stdexcept>
8 8
9 -Pl_StdioFile::Members::Members(FILE* f) :  
10 - file(f) 9 +class Pl_StdioFile::Members
11 { 10 {
12 -} 11 + public:
  12 + Members(FILE* f) :
  13 + file(f)
  14 + {
  15 + }
  16 + Members(Members const&) = delete;
  17 + ~Members() = default;
  18 +
  19 + FILE* file;
  20 +};
13 21
14 Pl_StdioFile::Pl_StdioFile(char const* identifier, FILE* f) : 22 Pl_StdioFile::Pl_StdioFile(char const* identifier, FILE* f) :
15 Pipeline(identifier, nullptr), 23 Pipeline(identifier, nullptr),
16 - m(new Members(f)) 24 + m(std::make_unique<Members>(f))
17 { 25 {
18 } 26 }
19 27
20 -Pl_StdioFile::~Pl_StdioFile() // NOLINT (modernize-use-equals-default)  
21 -{  
22 - // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer  
23 -} 28 +// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
  29 +Pl_StdioFile::~Pl_StdioFile() = default;
24 30
25 void 31 void
26 Pl_StdioFile::write(unsigned char const* buf, size_t len) 32 Pl_StdioFile::write(unsigned char const* buf, size_t len)
libqpdf/Pl_String.cc
@@ -2,21 +2,27 @@ @@ -2,21 +2,27 @@
2 2
3 #include <stdexcept> 3 #include <stdexcept>
4 4
5 -Pl_String::Members::Members(std::string& s) :  
6 - s(s) 5 +class Pl_String::Members
7 { 6 {
8 -} 7 + public:
  8 + Members(std::string& s) :
  9 + s(s)
  10 + {
  11 + }
  12 + Members(Members const&) = delete;
  13 + ~Members() = default;
  14 +
  15 + std::string& s;
  16 +};
9 17
10 Pl_String::Pl_String(char const* identifier, Pipeline* next, std::string& s) : 18 Pl_String::Pl_String(char const* identifier, Pipeline* next, std::string& s) :
11 Pipeline(identifier, next), 19 Pipeline(identifier, next),
12 - m(new Members(s)) 20 + m(std::make_unique<Members>(s))
13 { 21 {
14 } 22 }
15 23
16 -Pl_String::~Pl_String() // NOLINT (modernize-use-equals-default)  
17 -{  
18 - // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer  
19 -} 24 +// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
  25 +Pl_String::~Pl_String() = default;
20 26
21 void 27 void
22 Pl_String::write(unsigned char const* buf, size_t len) 28 Pl_String::write(unsigned char const* buf, size_t len)
libqpdf/QPDF.cc
@@ -22,6 +22,9 @@ @@ -22,6 +22,9 @@
22 #include <qpdf/QPDFParser.hh> 22 #include <qpdf/QPDFParser.hh>
23 #include <qpdf/QTC.hh> 23 #include <qpdf/QTC.hh>
24 #include <qpdf/QUtil.hh> 24 #include <qpdf/QUtil.hh>
  25 +#include <qpdf/Util.hh>
  26 +
  27 +using namespace qpdf;
25 28
26 // This must be a fixed value. This API returns a const reference to it, and the C API relies on its 29 // This must be a fixed value. This API returns a const reference to it, and the C API relies on its
27 // being static as well. 30 // being static as well.
@@ -200,7 +203,7 @@ QPDF::Members::Members() : @@ -200,7 +203,7 @@ QPDF::Members::Members() :
200 } 203 }
201 204
202 QPDF::QPDF() : 205 QPDF::QPDF() :
203 - m(new Members()) 206 + m(std::make_unique<Members>())
204 { 207 {
205 m->tokenizer.allowEOF(); 208 m->tokenizer.allowEOF();
206 // Generate a unique ID. It just has to be unique among all QPDF objects allocated throughout 209 // Generate a unique ID. It just has to be unique among all QPDF objects allocated throughout
@@ -368,14 +371,14 @@ QPDF::numWarnings() const @@ -368,14 +371,14 @@ QPDF::numWarnings() const
368 bool 371 bool
369 QPDF::validatePDFVersion(char const*& p, std::string& version) 372 QPDF::validatePDFVersion(char const*& p, std::string& version)
370 { 373 {
371 - bool valid = QUtil::is_digit(*p); 374 + bool valid = util::is_digit(*p);
372 if (valid) { 375 if (valid) {
373 - while (QUtil::is_digit(*p)) { 376 + while (util::is_digit(*p)) {
374 version.append(1, *p++); 377 version.append(1, *p++);
375 } 378 }
376 - if ((*p == '.') && QUtil::is_digit(*(p + 1))) { 379 + if ((*p == '.') && util::is_digit(*(p + 1))) {
377 version.append(1, *p++); 380 version.append(1, *p++);
378 - while (QUtil::is_digit(*p)) { 381 + while (util::is_digit(*p)) {
379 version.append(1, *p++); 382 version.append(1, *p++);
380 } 383 }
381 } else { 384 } else {
@@ -709,7 +712,7 @@ QPDF::read_xref(qpdf_offset_t xref_offset) @@ -709,7 +712,7 @@ QPDF::read_xref(qpdf_offset_t xref_offset)
709 while (!done) { 712 while (!done) {
710 char ch; 713 char ch;
711 if (1 == m->file->read(&ch, 1)) { 714 if (1 == m->file->read(&ch, 1)) {
712 - if (QUtil::is_space(ch)) { 715 + if (util::is_space(ch)) {
713 skipped_space = true; 716 skipped_space = true;
714 } else { 717 } else {
715 m->file->unreadCh(ch); 718 m->file->unreadCh(ch);
@@ -724,7 +727,7 @@ QPDF::read_xref(qpdf_offset_t xref_offset) @@ -724,7 +727,7 @@ QPDF::read_xref(qpdf_offset_t xref_offset)
724 m->file->read(buf, sizeof(buf) - 1); 727 m->file->read(buf, sizeof(buf) - 1);
725 // The PDF spec says xref must be followed by a line terminator, but files exist in the wild 728 // The PDF spec says xref must be followed by a line terminator, but files exist in the wild
726 // where it is terminated by arbitrary whitespace. 729 // where it is terminated by arbitrary whitespace.
727 - if ((strncmp(buf, "xref", 4) == 0) && QUtil::is_space(buf[4])) { 730 + if ((strncmp(buf, "xref", 4) == 0) && util::is_space(buf[4])) {
728 if (skipped_space) { 731 if (skipped_space) {
729 QTC::TC("qpdf", "QPDF xref skipped space"); 732 QTC::TC("qpdf", "QPDF xref skipped space");
730 warn(damagedPDF("", 0, "extraneous whitespace seen before xref")); 733 warn(damagedPDF("", 0, "extraneous whitespace seen before xref"));
@@ -737,8 +740,8 @@ QPDF::read_xref(qpdf_offset_t xref_offset) @@ -737,8 +740,8 @@ QPDF::read_xref(qpdf_offset_t xref_offset)
737 : (buf[4] == ' ') ? 2 740 : (buf[4] == ' ') ? 2
738 : 9999)); 741 : 9999));
739 int skip = 4; 742 int skip = 4;
740 - // buf is null-terminated, and QUtil::is_space('\0') is false, so this won't overrun.  
741 - while (QUtil::is_space(buf[skip])) { 743 + // buf is null-terminated, and util::is_space('\0') is false, so this won't overrun.
  744 + while (util::is_space(buf[skip])) {
742 ++skip; 745 ++skip;
743 } 746 }
744 xref_offset = read_xrefTable(xref_offset + skip); 747 xref_offset = read_xrefTable(xref_offset + skip);
@@ -795,37 +798,37 @@ QPDF::parse_xrefFirst(std::string const&amp; line, int&amp; obj, int&amp; num, int&amp; bytes) @@ -795,37 +798,37 @@ QPDF::parse_xrefFirst(std::string const&amp; line, int&amp; obj, int&amp; num, int&amp; bytes)
795 char const* start = line.c_str(); 798 char const* start = line.c_str();
796 799
797 // Skip zero or more spaces 800 // Skip zero or more spaces
798 - while (QUtil::is_space(*p)) { 801 + while (util::is_space(*p)) {
799 ++p; 802 ++p;
800 } 803 }
801 // Require digit 804 // Require digit
802 - if (!QUtil::is_digit(*p)) { 805 + if (!util::is_digit(*p)) {
803 return false; 806 return false;
804 } 807 }
805 // Gather digits 808 // Gather digits
806 std::string obj_str; 809 std::string obj_str;
807 - while (QUtil::is_digit(*p)) { 810 + while (util::is_digit(*p)) {
808 obj_str.append(1, *p++); 811 obj_str.append(1, *p++);
809 } 812 }
810 // Require space 813 // Require space
811 - if (!QUtil::is_space(*p)) { 814 + if (!util::is_space(*p)) {
812 return false; 815 return false;
813 } 816 }
814 // Skip spaces 817 // Skip spaces
815 - while (QUtil::is_space(*p)) { 818 + while (util::is_space(*p)) {
816 ++p; 819 ++p;
817 } 820 }
818 // Require digit 821 // Require digit
819 - if (!QUtil::is_digit(*p)) { 822 + if (!util::is_digit(*p)) {
820 return false; 823 return false;
821 } 824 }
822 // Gather digits 825 // Gather digits
823 std::string num_str; 826 std::string num_str;
824 - while (QUtil::is_digit(*p)) { 827 + while (util::is_digit(*p)) {
825 num_str.append(1, *p++); 828 num_str.append(1, *p++);
826 } 829 }
827 // Skip any space including line terminators 830 // Skip any space including line terminators
828 - while (QUtil::is_space(*p)) { 831 + while (util::is_space(*p)) {
829 ++p; 832 ++p;
830 } 833 }
831 bytes = toI(p - start); 834 bytes = toI(p - start);
@@ -847,51 +850,51 @@ QPDF::read_bad_xrefEntry(qpdf_offset_t&amp; f1, int&amp; f2, char&amp; type) @@ -847,51 +850,51 @@ QPDF::read_bad_xrefEntry(qpdf_offset_t&amp; f1, int&amp; f2, char&amp; type)
847 850
848 // Skip zero or more spaces. There aren't supposed to be any. 851 // Skip zero or more spaces. There aren't supposed to be any.
849 bool invalid = false; 852 bool invalid = false;
850 - while (QUtil::is_space(*p)) { 853 + while (util::is_space(*p)) {
851 ++p; 854 ++p;
852 QTC::TC("qpdf", "QPDF ignore first space in xref entry"); 855 QTC::TC("qpdf", "QPDF ignore first space in xref entry");
853 invalid = true; 856 invalid = true;
854 } 857 }
855 // Require digit 858 // Require digit
856 - if (!QUtil::is_digit(*p)) { 859 + if (!util::is_digit(*p)) {
857 return false; 860 return false;
858 } 861 }
859 // Gather digits 862 // Gather digits
860 std::string f1_str; 863 std::string f1_str;
861 - while (QUtil::is_digit(*p)) { 864 + while (util::is_digit(*p)) {
862 f1_str.append(1, *p++); 865 f1_str.append(1, *p++);
863 } 866 }
864 // Require space 867 // Require space
865 - if (!QUtil::is_space(*p)) { 868 + if (!util::is_space(*p)) {
866 return false; 869 return false;
867 } 870 }
868 - if (QUtil::is_space(*(p + 1))) { 871 + if (util::is_space(*(p + 1))) {
869 QTC::TC("qpdf", "QPDF ignore first extra space in xref entry"); 872 QTC::TC("qpdf", "QPDF ignore first extra space in xref entry");
870 invalid = true; 873 invalid = true;
871 } 874 }
872 // Skip spaces 875 // Skip spaces
873 - while (QUtil::is_space(*p)) { 876 + while (util::is_space(*p)) {
874 ++p; 877 ++p;
875 } 878 }
876 // Require digit 879 // Require digit
877 - if (!QUtil::is_digit(*p)) { 880 + if (!util::is_digit(*p)) {
878 return false; 881 return false;
879 } 882 }
880 // Gather digits 883 // Gather digits
881 std::string f2_str; 884 std::string f2_str;
882 - while (QUtil::is_digit(*p)) { 885 + while (util::is_digit(*p)) {
883 f2_str.append(1, *p++); 886 f2_str.append(1, *p++);
884 } 887 }
885 // Require space 888 // Require space
886 - if (!QUtil::is_space(*p)) { 889 + if (!util::is_space(*p)) {
887 return false; 890 return false;
888 } 891 }
889 - if (QUtil::is_space(*(p + 1))) { 892 + if (util::is_space(*(p + 1))) {
890 QTC::TC("qpdf", "QPDF ignore second extra space in xref entry"); 893 QTC::TC("qpdf", "QPDF ignore second extra space in xref entry");
891 invalid = true; 894 invalid = true;
892 } 895 }
893 // Skip spaces 896 // Skip spaces
894 - while (QUtil::is_space(*p)) { 897 + while (util::is_space(*p)) {
895 ++p; 898 ++p;
896 } 899 }
897 if ((*p == 'f') || (*p == 'n')) { 900 if ((*p == 'f') || (*p == 'n')) {
@@ -938,12 +941,12 @@ QPDF::read_xrefEntry(qpdf_offset_t&amp; f1, int&amp; f2, char&amp; type) @@ -938,12 +941,12 @@ QPDF::read_xrefEntry(qpdf_offset_t&amp; f1, int&amp; f2, char&amp; type)
938 ++f1_len; 941 ++f1_len;
939 ++p; 942 ++p;
940 } 943 }
941 - while (QUtil::is_digit(*p) && f1_len++ < 10) { 944 + while (util::is_digit(*p) && f1_len++ < 10) {
942 f1 *= 10; 945 f1 *= 10;
943 f1 += *p++ - '0'; 946 f1 += *p++ - '0';
944 } 947 }
945 // Require space 948 // Require space
946 - if (!QUtil::is_space(*p++)) { 949 + if (!util::is_space(*p++)) {
947 // Entry doesn't start with space or digit. 950 // Entry doesn't start with space or digit.
948 // C++20: [[unlikely]] 951 // C++20: [[unlikely]]
949 return false; 952 return false;
@@ -953,11 +956,11 @@ QPDF::read_xrefEntry(qpdf_offset_t&amp; f1, int&amp; f2, char&amp; type) @@ -953,11 +956,11 @@ QPDF::read_xrefEntry(qpdf_offset_t&amp; f1, int&amp; f2, char&amp; type)
953 ++f2_len; 956 ++f2_len;
954 ++p; 957 ++p;
955 } 958 }
956 - while (QUtil::is_digit(*p) && f2_len++ < 5) { 959 + while (util::is_digit(*p) && f2_len++ < 5) {
957 f2 *= 10; 960 f2 *= 10;
958 f2 += static_cast<int>(*p++ - '0'); 961 f2 += static_cast<int>(*p++ - '0');
959 } 962 }
960 - if (QUtil::is_space(*p++) && (*p == 'f' || *p == 'n')) { 963 + if (util::is_space(*p++) && (*p == 'f' || *p == 'n')) {
961 // C++20: [[likely]] 964 // C++20: [[likely]]
962 type = *p; 965 type = *p;
963 // No test for valid line[19]. 966 // No test for valid line[19].
@@ -1602,7 +1605,7 @@ QPDF::validateStreamLineEnd(QPDFObjectHandle&amp; object, QPDFObjGen og, qpdf_offset @@ -1602,7 +1605,7 @@ QPDF::validateStreamLineEnd(QPDFObjectHandle&amp; object, QPDFObjGen og, qpdf_offset
1602 } 1605 }
1603 return; 1606 return;
1604 } 1607 }
1605 - if (!QUtil::is_space(ch)) { 1608 + if (!util::is_space(ch)) {
1606 QTC::TC("qpdf", "QPDF stream without newline"); 1609 QTC::TC("qpdf", "QPDF stream without newline");
1607 m->file->unreadCh(ch); 1610 m->file->unreadCh(ch);
1608 warn(damagedPDF( 1611 warn(damagedPDF(
libqpdf/QPDFArgParser.cc
@@ -5,10 +5,13 @@ @@ -5,10 +5,13 @@
5 #include <qpdf/QPDFUsage.hh> 5 #include <qpdf/QPDFUsage.hh>
6 #include <qpdf/QTC.hh> 6 #include <qpdf/QTC.hh>
7 #include <qpdf/QUtil.hh> 7 #include <qpdf/QUtil.hh>
  8 +#include <qpdf/Util.hh>
  9 +
8 #include <cstdlib> 10 #include <cstdlib>
9 #include <cstring> 11 #include <cstring>
10 #include <iostream> 12 #include <iostream>
11 13
  14 +using namespace qpdf;
12 using namespace std::literals; 15 using namespace std::literals;
13 16
14 QPDFArgParser::Members::Members(int argc, char const* const argv[], char const* progname_env) : 17 QPDFArgParser::Members::Members(int argc, char const* const argv[], char const* progname_env) :
@@ -285,7 +288,7 @@ QPDFArgParser::handleBashArguments() @@ -285,7 +288,7 @@ QPDFArgParser::handleBashArguments()
285 bool append = false; 288 bool append = false;
286 switch (state) { 289 switch (state) {
287 case st_top: 290 case st_top:
288 - if (QUtil::is_space(ch)) { 291 + if (util::is_space(ch)) {
289 if (!arg.empty()) { 292 if (!arg.empty()) {
290 m->bash_argv.push_back(QUtil::make_shared_cstr(arg)); 293 m->bash_argv.push_back(QUtil::make_shared_cstr(arg));
291 arg.clear(); 294 arg.clear();
libqpdf/QPDFJob.cc
@@ -29,9 +29,12 @@ @@ -29,9 +29,12 @@
29 #include <qpdf/QPDFWriter.hh> 29 #include <qpdf/QPDFWriter.hh>
30 #include <qpdf/QTC.hh> 30 #include <qpdf/QTC.hh>
31 #include <qpdf/QUtil.hh> 31 #include <qpdf/QUtil.hh>
  32 +#include <qpdf/Util.hh>
32 33
33 #include <qpdf/auto_job_schema.hh> // JOB_SCHEMA_DATA 34 #include <qpdf/auto_job_schema.hh> // JOB_SCHEMA_DATA
34 35
  36 +using namespace qpdf;
  37 +
35 namespace 38 namespace
36 { 39 {
37 class ImageOptimizer: public QPDFObjectHandle::StreamDataProvider 40 class ImageOptimizer: public QPDFObjectHandle::StreamDataProvider
@@ -388,7 +391,7 @@ QPDFJob::parseRotationParameter(std::string const&amp; parameter) @@ -388,7 +391,7 @@ QPDFJob::parseRotationParameter(std::string const&amp; parameter)
388 if ((first == '+') || (first == '-')) { 391 if ((first == '+') || (first == '-')) {
389 relative = ((first == '+') ? 1 : -1); 392 relative = ((first == '+') ? 1 : -1);
390 angle_str = angle_str.substr(1); 393 angle_str = angle_str.substr(1);
391 - } else if (!QUtil::is_digit(angle_str.at(0))) { 394 + } else if (!util::is_digit(angle_str.at(0))) {
392 angle_str = ""; 395 angle_str = "";
393 } 396 }
394 } 397 }
libqpdf/QPDFMatrix.cc
@@ -138,3 +138,9 @@ QPDFMatrix::operator==(QPDFMatrix const&amp; rhs) const @@ -138,3 +138,9 @@ QPDFMatrix::operator==(QPDFMatrix const&amp; rhs) const
138 (this->a == rhs.a) && (this->b == rhs.b) && (this->c == rhs.c) && (this->d == rhs.d) && 138 (this->a == rhs.a) && (this->b == rhs.b) && (this->c == rhs.c) && (this->d == rhs.d) &&
139 (this->e == rhs.e) && (this->f == rhs.f)); 139 (this->e == rhs.e) && (this->f == rhs.f));
140 } 140 }
  141 +
  142 +bool
  143 +QPDFMatrix::operator!=(QPDFMatrix const& rhs) const
  144 +{
  145 + return !operator==(rhs);
  146 +}
libqpdf/QPDFObjectHandle.cc
@@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
15 #include <qpdf/QIntC.hh> 15 #include <qpdf/QIntC.hh>
16 #include <qpdf/QTC.hh> 16 #include <qpdf/QTC.hh>
17 #include <qpdf/QUtil.hh> 17 #include <qpdf/QUtil.hh>
  18 +#include <qpdf/Util.hh>
18 19
19 #include <algorithm> 20 #include <algorithm>
20 #include <array> 21 #include <array>
@@ -279,7 +280,7 @@ Name::normalize(std::string const&amp; name) @@ -279,7 +280,7 @@ Name::normalize(std::string const&amp; name)
279 } else if ( 280 } else if (
280 ch < 33 || ch == '#' || ch == '/' || ch == '(' || ch == ')' || ch == '{' || ch == '}' || 281 ch < 33 || ch == '#' || ch == '/' || ch == '(' || ch == ')' || ch == '{' || ch == '}' ||
281 ch == '<' || ch == '>' || ch == '[' || ch == ']' || ch == '%' || ch > 126) { 282 ch == '<' || ch == '>' || ch == '[' || ch == ']' || ch == '%' || ch > 126) {
282 - result += QUtil::hex_encode_char(ch); 283 + result += util::hex_encode_char(ch);
283 } else { 284 } else {
284 result += ch; 285 result += ch;
285 } 286 }
@@ -2369,6 +2370,24 @@ QPDFObjectHandle::getObjGen() const @@ -2369,6 +2370,24 @@ QPDFObjectHandle::getObjGen() const
2369 return obj ? obj->getObjGen() : QPDFObjGen(); 2370 return obj ? obj->getObjGen() : QPDFObjGen();
2370 } 2371 }
2371 2372
  2373 +int
  2374 +QPDFObjectHandle::getObjectID() const
  2375 +{
  2376 + return getObjGen().getObj();
  2377 +}
  2378 +
  2379 +int
  2380 +QPDFObjectHandle::getGeneration() const
  2381 +{
  2382 + return getObjGen().getGen();
  2383 +}
  2384 +
  2385 +bool
  2386 +QPDFObjectHandle::isIndirect() const
  2387 +{
  2388 + return getObjectID() != 0;
  2389 +}
  2390 +
2372 // Indirect object accessors 2391 // Indirect object accessors
2373 QPDF* 2392 QPDF*
2374 QPDFObjectHandle::getOwningQPDF() const 2393 QPDFObjectHandle::getOwningQPDF() const
libqpdf/QPDFObjectHelper.cc
1 #include <qpdf/QPDFObjectHelper.hh> 1 #include <qpdf/QPDFObjectHelper.hh>
2 2
3 -QPDFObjectHelper::~QPDFObjectHelper() // NOLINT (modernize-use-equals-default)  
4 -{  
5 - // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer  
6 -} 3 +// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
  4 +QPDFObjectHelper::~QPDFObjectHelper() = default;
libqpdf/QPDFTokenizer.cc
@@ -8,11 +8,14 @@ @@ -8,11 +8,14 @@
8 #include <qpdf/QPDFObjectHandle.hh> 8 #include <qpdf/QPDFObjectHandle.hh>
9 #include <qpdf/QTC.hh> 9 #include <qpdf/QTC.hh>
10 #include <qpdf/QUtil.hh> 10 #include <qpdf/QUtil.hh>
  11 +#include <qpdf/Util.hh>
11 12
12 #include <cstdlib> 13 #include <cstdlib>
13 #include <cstring> 14 #include <cstring>
14 #include <stdexcept> 15 #include <stdexcept>
15 16
  17 +using namespace qpdf;
  18 +
16 static inline bool 19 static inline bool
17 is_delimiter(char ch) 20 is_delimiter(char ch)
18 { 21 {
@@ -123,7 +126,7 @@ QPDFTokenizer::includeIgnorable() @@ -123,7 +126,7 @@ QPDFTokenizer::includeIgnorable()
123 bool 126 bool
124 QPDFTokenizer::isSpace(char ch) 127 QPDFTokenizer::isSpace(char ch)
125 { 128 {
126 - return ((ch == '\0') || QUtil::is_space(ch)); 129 + return (ch == '\0' || util::is_space(ch));
127 } 130 }
128 131
129 bool 132 bool
@@ -440,7 +443,7 @@ QPDFTokenizer::inNameHex1(char ch) @@ -440,7 +443,7 @@ QPDFTokenizer::inNameHex1(char ch)
440 { 443 {
441 this->hex_char = ch; 444 this->hex_char = ch;
442 445
443 - if (char hval = QUtil::hex_decode_char(ch); hval < '0') { 446 + if (char hval = util::hex_decode_char(ch); hval < '0') {
444 this->char_code = int(hval) << 4; 447 this->char_code = int(hval) << 4;
445 this->state = st_name_hex2; 448 this->state = st_name_hex2;
446 } else { 449 } else {
@@ -456,7 +459,7 @@ QPDFTokenizer::inNameHex1(char ch) @@ -456,7 +459,7 @@ QPDFTokenizer::inNameHex1(char ch)
456 void 459 void
457 QPDFTokenizer::inNameHex2(char ch) 460 QPDFTokenizer::inNameHex2(char ch)
458 { 461 {
459 - if (char hval = QUtil::hex_decode_char(ch); hval < '0') { 462 + if (char hval = util::hex_decode_char(ch); hval < '0') {
460 this->char_code |= int(hval); 463 this->char_code |= int(hval);
461 } else { 464 } else {
462 QTC::TC("qpdf", "QPDFTokenizer bad name 2"); 465 QTC::TC("qpdf", "QPDFTokenizer bad name 2");
@@ -483,7 +486,7 @@ QPDFTokenizer::inNameHex2(char ch) @@ -483,7 +486,7 @@ QPDFTokenizer::inNameHex2(char ch)
483 void 486 void
484 QPDFTokenizer::inSign(char ch) 487 QPDFTokenizer::inSign(char ch)
485 { 488 {
486 - if (QUtil::is_digit(ch)) { 489 + if (util::is_digit(ch)) {
487 this->state = st_number; 490 this->state = st_number;
488 } else if (ch == '.') { 491 } else if (ch == '.') {
489 this->state = st_decimal; 492 this->state = st_decimal;
@@ -496,7 +499,7 @@ QPDFTokenizer::inSign(char ch) @@ -496,7 +499,7 @@ QPDFTokenizer::inSign(char ch)
496 void 499 void
497 QPDFTokenizer::inDecimal(char ch) 500 QPDFTokenizer::inDecimal(char ch)
498 { 501 {
499 - if (QUtil::is_digit(ch)) { 502 + if (util::is_digit(ch)) {
500 this->state = st_real; 503 this->state = st_real;
501 } else { 504 } else {
502 this->state = st_literal; 505 this->state = st_literal;
@@ -507,7 +510,7 @@ QPDFTokenizer::inDecimal(char ch) @@ -507,7 +510,7 @@ QPDFTokenizer::inDecimal(char ch)
507 void 510 void
508 QPDFTokenizer::inNumber(char ch) 511 QPDFTokenizer::inNumber(char ch)
509 { 512 {
510 - if (QUtil::is_digit(ch)) { 513 + if (util::is_digit(ch)) {
511 } else if (ch == '.') { 514 } else if (ch == '.') {
512 this->state = st_real; 515 this->state = st_real;
513 } else if (isDelimiter(ch)) { 516 } else if (isDelimiter(ch)) {
@@ -523,7 +526,7 @@ QPDFTokenizer::inNumber(char ch) @@ -523,7 +526,7 @@ QPDFTokenizer::inNumber(char ch)
523 void 526 void
524 QPDFTokenizer::inReal(char ch) 527 QPDFTokenizer::inReal(char ch)
525 { 528 {
526 - if (QUtil::is_digit(ch)) { 529 + if (util::is_digit(ch)) {
527 } else if (isDelimiter(ch)) { 530 } else if (isDelimiter(ch)) {
528 this->type = tt_real; 531 this->type = tt_real;
529 this->state = st_token_ready; 532 this->state = st_token_ready;
@@ -645,7 +648,7 @@ QPDFTokenizer::inLiteral(char ch) @@ -645,7 +648,7 @@ QPDFTokenizer::inLiteral(char ch)
645 void 648 void
646 QPDFTokenizer::inHexstring(char ch) 649 QPDFTokenizer::inHexstring(char ch)
647 { 650 {
648 - if (char hval = QUtil::hex_decode_char(ch); hval < '0') { 651 + if (char hval = util::hex_decode_char(ch); hval < '0') {
649 this->char_code = int(hval) << 4; 652 this->char_code = int(hval) << 4;
650 this->state = st_in_hexstring_2nd; 653 this->state = st_in_hexstring_2nd;
651 654
@@ -667,7 +670,7 @@ QPDFTokenizer::inHexstring(char ch) @@ -667,7 +670,7 @@ QPDFTokenizer::inHexstring(char ch)
667 void 670 void
668 QPDFTokenizer::inHexstring2nd(char ch) 671 QPDFTokenizer::inHexstring2nd(char ch)
669 { 672 {
670 - if (char hval = QUtil::hex_decode_char(ch); hval < '0') { 673 + if (char hval = util::hex_decode_char(ch); hval < '0') {
671 this->val += char(this->char_code) | hval; 674 this->val += char(this->char_code) | hval;
672 this->state = st_in_hexstring; 675 this->state = st_in_hexstring;
673 676
libqpdf/QPDF_json.cc
@@ -9,9 +9,13 @@ @@ -9,9 +9,13 @@
9 #include <qpdf/QPDFObject_private.hh> 9 #include <qpdf/QPDFObject_private.hh>
10 #include <qpdf/QTC.hh> 10 #include <qpdf/QTC.hh>
11 #include <qpdf/QUtil.hh> 11 #include <qpdf/QUtil.hh>
  12 +#include <qpdf/Util.hh>
  13 +
12 #include <algorithm> 14 #include <algorithm>
13 #include <cstring> 15 #include <cstring>
14 16
  17 +using namespace qpdf;
  18 +
15 // This chart shows an example of the state transitions that would occur in parsing a minimal file. 19 // This chart shows an example of the state transitions that would occur in parsing a minimal file.
16 20
17 // | 21 // |
@@ -67,10 +71,10 @@ is_indirect_object(std::string const&amp; v, int&amp; obj, int&amp; gen) @@ -67,10 +71,10 @@ is_indirect_object(std::string const&amp; v, int&amp; obj, int&amp; gen)
67 char const* p = v.c_str(); 71 char const* p = v.c_str();
68 std::string o_str; 72 std::string o_str;
69 std::string g_str; 73 std::string g_str;
70 - if (!QUtil::is_digit(*p)) { 74 + if (!util::is_digit(*p)) {
71 return false; 75 return false;
72 } 76 }
73 - while (QUtil::is_digit(*p)) { 77 + while (util::is_digit(*p)) {
74 o_str.append(1, *p++); 78 o_str.append(1, *p++);
75 } 79 }
76 if (*p != ' ') { 80 if (*p != ' ') {
@@ -79,10 +83,10 @@ is_indirect_object(std::string const&amp; v, int&amp; obj, int&amp; gen) @@ -79,10 +83,10 @@ is_indirect_object(std::string const&amp; v, int&amp; obj, int&amp; gen)
79 while (*p == ' ') { 83 while (*p == ' ') {
80 ++p; 84 ++p;
81 } 85 }
82 - if (!QUtil::is_digit(*p)) { 86 + if (!util::is_digit(*p)) {
83 return false; 87 return false;
84 } 88 }
85 - while (QUtil::is_digit(*p)) { 89 + while (util::is_digit(*p)) {
86 g_str.append(1, *p++); 90 g_str.append(1, *p++);
87 } 91 }
88 if (*p != ' ') { 92 if (*p != ' ') {
@@ -128,7 +132,7 @@ is_binary_string(std::string const&amp; v, std::string&amp; str) @@ -128,7 +132,7 @@ is_binary_string(std::string const&amp; v, std::string&amp; str)
128 str = v.substr(2); 132 str = v.substr(2);
129 int count = 0; 133 int count = 0;
130 for (char c: str) { 134 for (char c: str) {
131 - if (!QUtil::is_hex_digit(c)) { 135 + if (!util::is_hex_digit(c)) {
132 return false; 136 return false;
133 } 137 }
134 ++count; 138 ++count;
libqpdf/QPDF_linearization.cc
@@ -12,11 +12,14 @@ @@ -12,11 +12,14 @@
12 #include <qpdf/QPDFWriter_private.hh> 12 #include <qpdf/QPDFWriter_private.hh>
13 #include <qpdf/QTC.hh> 13 #include <qpdf/QTC.hh>
14 #include <qpdf/QUtil.hh> 14 #include <qpdf/QUtil.hh>
  15 +#include <qpdf/Util.hh>
15 16
16 #include <algorithm> 17 #include <algorithm>
17 #include <cmath> 18 #include <cmath>
18 #include <cstring> 19 #include <cstring>
19 20
  21 +using namespace qpdf;
  22 +
20 template <class T, class int_type> 23 template <class T, class int_type>
21 static void 24 static void
22 load_vector_int( 25 load_vector_int(
@@ -105,7 +108,7 @@ QPDF::isLinearized() @@ -105,7 +108,7 @@ QPDF::isLinearized()
105 char* p = buf; 108 char* p = buf;
106 while (lindict_obj == -1) { 109 while (lindict_obj == -1) {
107 // Find a digit or end of buffer 110 // Find a digit or end of buffer
108 - while (((p - buf) < tbuf_size) && (!QUtil::is_digit(*p))) { 111 + while (((p - buf) < tbuf_size) && (!util::is_digit(*p))) {
109 ++p; 112 ++p;
110 } 113 }
111 if (p - buf == tbuf_size) { 114 if (p - buf == tbuf_size) {
@@ -114,7 +117,7 @@ QPDF::isLinearized() @@ -114,7 +117,7 @@ QPDF::isLinearized()
114 // Seek to the digit. Then skip over digits for a potential 117 // Seek to the digit. Then skip over digits for a potential
115 // next iteration. 118 // next iteration.
116 m->file->seek(p - buf, SEEK_SET); 119 m->file->seek(p - buf, SEEK_SET);
117 - while (((p - buf) < tbuf_size) && QUtil::is_digit(*p)) { 120 + while (((p - buf) < tbuf_size) && util::is_digit(*p)) {
118 ++p; 121 ++p;
119 } 122 }
120 123
libqpdf/QUtil.cc
@@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
8 #include <qpdf/QIntC.hh> 8 #include <qpdf/QIntC.hh>
9 #include <qpdf/QPDFSystemError.hh> 9 #include <qpdf/QPDFSystemError.hh>
10 #include <qpdf/QTC.hh> 10 #include <qpdf/QTC.hh>
  11 +#include <qpdf/Util.hh>
11 12
12 #include <cerrno> 13 #include <cerrno>
13 #include <cstdlib> 14 #include <cstdlib>
@@ -37,6 +38,8 @@ @@ -37,6 +38,8 @@
37 # include <malloc.h> 38 # include <malloc.h>
38 #endif 39 #endif
39 40
  41 +using namespace qpdf;
  42 +
40 // First element is 24 43 // First element is 24
41 static unsigned short pdf_doc_low_to_unicode[] = { 44 static unsigned short pdf_doc_low_to_unicode[] = {
42 0x02d8, // 0x18 BREVE 45 0x02d8, // 0x18 BREVE
@@ -396,7 +399,7 @@ unsigned long long @@ -396,7 +399,7 @@ unsigned long long
396 QUtil::string_to_ull(char const* str) 399 QUtil::string_to_ull(char const* str)
397 { 400 {
398 char const* p = str; 401 char const* p = str;
399 - while (*p && is_space(*p)) { 402 + while (*p && util::is_space(*p)) {
400 ++p; 403 ++p;
401 } 404 }
402 if (*p == '-') { 405 if (*p == '-') {
@@ -739,7 +742,7 @@ QUtil::hex_decode(std::string const&amp; input) @@ -739,7 +742,7 @@ QUtil::hex_decode(std::string const&amp; input)
739 bool first = true; 742 bool first = true;
740 char decoded; 743 char decoded;
741 for (auto ch: input) { 744 for (auto ch: input) {
742 - ch = hex_decode_char(ch); 745 + ch = util::hex_decode_char(ch);
743 if (ch < '\20') { 746 if (ch < '\20') {
744 if (first) { 747 if (first) {
745 decoded = static_cast<char>(ch << 4); 748 decoded = static_cast<char>(ch << 4);
@@ -2002,3 +2005,63 @@ QUtil::get_max_memory_usage() @@ -2002,3 +2005,63 @@ QUtil::get_max_memory_usage()
2002 return 0; 2005 return 0;
2003 #endif 2006 #endif
2004 } 2007 }
  2008 +
  2009 +char
  2010 +QUtil::hex_decode_char(char digit)
  2011 +{
  2012 + return util::hex_decode_char(digit);
  2013 +}
  2014 +
  2015 +std::string
  2016 +QUtil::hex_encode_char(char c)
  2017 +{
  2018 + return util::hex_encode_char(c);
  2019 +}
  2020 +
  2021 +bool
  2022 +QUtil::is_number(char const* p)
  2023 +{
  2024 + // No longer used by qpdf.
  2025 +
  2026 + // ^[\+\-]?(\.\d*|\d+(\.\d*)?)$
  2027 + if (!*p) {
  2028 + return false;
  2029 + }
  2030 + if ((*p == '-') || (*p == '+')) {
  2031 + ++p;
  2032 + }
  2033 + bool found_dot = false;
  2034 + bool found_digit = false;
  2035 + for (; *p; ++p) {
  2036 + if (*p == '.') {
  2037 + if (found_dot) {
  2038 + // only one dot
  2039 + return false;
  2040 + }
  2041 + found_dot = true;
  2042 + } else if (util::is_digit(*p)) {
  2043 + found_digit = true;
  2044 + } else {
  2045 + return false;
  2046 + }
  2047 + }
  2048 + return found_digit;
  2049 +}
  2050 +
  2051 +bool
  2052 +QUtil::is_space(char c)
  2053 +{
  2054 + return util::is_space(c);
  2055 +}
  2056 +
  2057 +bool
  2058 +QUtil::is_digit(char c)
  2059 +{
  2060 + return util::is_digit(c);
  2061 +}
  2062 +
  2063 +bool
  2064 +QUtil::is_hex_digit(char c)
  2065 +{
  2066 + return util::is_hex_digit(c);
  2067 +}
libqpdf/qpdf/Util.hh 0 → 100644
  1 +#ifndef UTIL_HH
  2 +#define UTIL_HH
  3 +
  4 +#include <string>
  5 +
  6 +namespace qpdf::util
  7 +{
  8 + // This is a collection of useful utility functions for qpdf internal use. They include inline
  9 + // functions, some of which are exposed as regular functions in QUtil. Implementations are in
  10 + // QUtil.cc.
  11 +
  12 + inline constexpr char
  13 + hex_decode_char(char digit)
  14 + {
  15 + return digit <= '9' && digit >= '0'
  16 + ? char(digit - '0')
  17 + : (digit >= 'a' ? char(digit - 'a' + 10)
  18 + : (digit >= 'A' ? char(digit - 'A' + 10) : '\20'));
  19 + }
  20 +
  21 + inline constexpr bool
  22 + is_hex_digit(char ch)
  23 + {
  24 + return hex_decode_char(ch) < '\20';
  25 + }
  26 +
  27 + inline constexpr bool
  28 + is_space(char ch)
  29 + {
  30 + return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t' || ch == '\f' || ch == '\v';
  31 + }
  32 +
  33 + inline bool
  34 + is_digit(char ch)
  35 + {
  36 + return (ch >= '0' && ch <= '9');
  37 + }
  38 +
  39 + // Returns lower-case hex-encoded version of the char including a leading "#".
  40 + inline std::string
  41 + hex_encode_char(char c)
  42 + {
  43 + static auto constexpr hexchars = "0123456789abcdef";
  44 + return {'#', hexchars[static_cast<unsigned char>(c) >> 4], hexchars[c & 0x0f]};
  45 + }
  46 +
  47 +} // namespace qpdf::util
  48 +
  49 +#endif // UTIL_HH
qpdf/sizes.cc
@@ -108,7 +108,6 @@ main() @@ -108,7 +108,6 @@ main()
108 print_size(QPDFNameTreeObjectHelper::iterator); 108 print_size(QPDFNameTreeObjectHelper::iterator);
109 print_size(QPDFNumberTreeObjectHelper); 109 print_size(QPDFNumberTreeObjectHelper);
110 print_size(QPDFNumberTreeObjectHelper::iterator); 110 print_size(QPDFNumberTreeObjectHelper::iterator);
111 - print_size(QPDFObjGen);  
112 print_size(QPDFObjectHandle); 111 print_size(QPDFObjectHandle);
113 print_size(QPDFObjectHandle::ParserCallbacks); 112 print_size(QPDFObjectHandle::ParserCallbacks);
114 print_size(QPDFObjectHandle::QPDFArrayItems); 113 print_size(QPDFObjectHandle::QPDFArrayItems);
@@ -117,6 +116,7 @@ main() @@ -117,6 +116,7 @@ main()
117 print_size(QPDFObjectHandle::QPDFDictItems::iterator); 116 print_size(QPDFObjectHandle::QPDFDictItems::iterator);
118 print_size(QPDFObjectHandle::StreamDataProvider); 117 print_size(QPDFObjectHandle::StreamDataProvider);
119 print_size(QPDFObjectHandle::TokenFilter); 118 print_size(QPDFObjectHandle::TokenFilter);
  119 + print_size(QPDFObjectHelper);
120 print_size(QPDFOutlineDocumentHelper); 120 print_size(QPDFOutlineDocumentHelper);
121 print_size(QPDFOutlineObjectHelper); 121 print_size(QPDFOutlineObjectHelper);
122 print_size(QPDFPageDocumentHelper); 122 print_size(QPDFPageDocumentHelper);