Commit a4b7907e7eb94f5d88f0d1e7b3ddd4069244727f
Committed by
GitHub
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 | 886 | * Changes to the types of public or protected data members without |
| 887 | 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 | 891 | Not breaking ABI/API still requires care. |
| 892 | 892 | ... | ... |
include/qpdf/Buffer.hh
include/qpdf/ClosedFileInputSource.hh
| ... | ... | @@ -20,22 +20,25 @@ |
| 20 | 20 | #ifndef QPDF_CLOSEDFILEINPUTSOURCE_HH |
| 21 | 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 | 23 | #include <qpdf/InputSource.hh> |
| 29 | 24 | |
| 30 | 25 | #include <memory> |
| 31 | 26 | |
| 32 | 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 | 33 | class QPDF_DLL_CLASS ClosedFileInputSource: public InputSource |
| 35 | 34 | { |
| 36 | 35 | public: |
| 37 | 36 | QPDF_DLL |
| 38 | 37 | ClosedFileInputSource(char const* filename); |
| 38 | + | |
| 39 | + ClosedFileInputSource(ClosedFileInputSource const&) = delete; | |
| 40 | + ClosedFileInputSource& operator=(ClosedFileInputSource const&) = delete; | |
| 41 | + | |
| 39 | 42 | QPDF_DLL |
| 40 | 43 | ~ClosedFileInputSource() override; |
| 41 | 44 | QPDF_DLL |
| ... | ... | @@ -60,9 +63,6 @@ class QPDF_DLL_CLASS ClosedFileInputSource: public InputSource |
| 60 | 63 | void stayOpen(bool); |
| 61 | 64 | |
| 62 | 65 | private: |
| 63 | - ClosedFileInputSource(ClosedFileInputSource const&) = delete; | |
| 64 | - ClosedFileInputSource& operator=(ClosedFileInputSource const&) = delete; | |
| 65 | - | |
| 66 | 66 | QPDF_DLL_PRIVATE |
| 67 | 67 | void before(); |
| 68 | 68 | QPDF_DLL_PRIVATE | ... | ... |
include/qpdf/FileInputSource.hh
| ... | ... | @@ -25,8 +25,7 @@ |
| 25 | 25 | class QPDF_DLL_CLASS FileInputSource: public InputSource |
| 26 | 26 | { |
| 27 | 27 | public: |
| 28 | - QPDF_DLL | |
| 29 | - FileInputSource(); | |
| 28 | + FileInputSource() = default; | |
| 30 | 29 | QPDF_DLL |
| 31 | 30 | FileInputSource(char const* filename); |
| 32 | 31 | QPDF_DLL |
| ... | ... | @@ -35,6 +34,10 @@ class QPDF_DLL_CLASS FileInputSource: public InputSource |
| 35 | 34 | void setFilename(char const* filename); |
| 36 | 35 | QPDF_DLL |
| 37 | 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 | 41 | QPDF_DLL |
| 39 | 42 | ~FileInputSource() override; |
| 40 | 43 | QPDF_DLL |
| ... | ... | @@ -53,12 +56,9 @@ class QPDF_DLL_CLASS FileInputSource: public InputSource |
| 53 | 56 | void unreadCh(char ch) override; |
| 54 | 57 | |
| 55 | 58 | private: |
| 56 | - FileInputSource(FileInputSource const&) = delete; | |
| 57 | - FileInputSource& operator=(FileInputSource const&) = delete; | |
| 58 | - | |
| 59 | - bool close_file; | |
| 59 | + bool close_file{false}; | |
| 60 | 60 | std::string filename; |
| 61 | - FILE* file; | |
| 61 | + FILE* file{nullptr}; | |
| 62 | 62 | }; |
| 63 | 63 | |
| 64 | 64 | #endif // QPDF_FILEINPUTSOURCE_HH | ... | ... |
include/qpdf/InputSource.hh
include/qpdf/JSON.hh
| ... | ... | @@ -20,15 +20,6 @@ |
| 20 | 20 | #ifndef JSON_HH |
| 21 | 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 | 23 | #include <qpdf/DLL.h> |
| 33 | 24 | #include <qpdf/Types.h> |
| 34 | 25 | |
| ... | ... | @@ -43,12 +34,19 @@ |
| 43 | 34 | class Pipeline; |
| 44 | 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 | 45 | class JSON |
| 47 | 46 | { |
| 48 | 47 | public: |
| 49 | 48 | static int constexpr LATEST = 2; |
| 50 | 49 | |
| 51 | - QPDF_DLL | |
| 52 | 50 | JSON() = default; |
| 53 | 51 | |
| 54 | 52 | QPDF_DLL |
| ... | ... | @@ -147,6 +145,7 @@ class JSON |
| 147 | 145 | // |
| 148 | 146 | // - If argument is wrong type, including null, return false |
| 149 | 147 | // - If argument is right type, return true and initialize the value |
| 148 | + | |
| 150 | 149 | QPDF_DLL |
| 151 | 150 | bool getString(std::string& utf8) const; |
| 152 | 151 | QPDF_DLL |
| ... | ... | @@ -210,7 +209,6 @@ class JSON |
| 210 | 209 | class QPDF_DLL_CLASS Reactor |
| 211 | 210 | { |
| 212 | 211 | public: |
| 213 | - QPDF_DLL | |
| 214 | 212 | virtual ~Reactor() = default; |
| 215 | 213 | |
| 216 | 214 | // The start/end methods are called when parsing of a dictionary or array is started or |
| ... | ... | @@ -377,7 +375,6 @@ class JSON |
| 377 | 375 | friend class JSON; |
| 378 | 376 | |
| 379 | 377 | public: |
| 380 | - QPDF_DLL | |
| 381 | 378 | ~Members() = default; |
| 382 | 379 | |
| 383 | 380 | private: | ... | ... |
include/qpdf/PDFVersion.hh
| ... | ... | @@ -23,18 +23,16 @@ |
| 23 | 23 | #include <qpdf/DLL.h> |
| 24 | 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 | 29 | class PDFVersion |
| 27 | 30 | { |
| 28 | 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 | 33 | PDFVersion(PDFVersion const&) = default; |
| 36 | - QPDF_DLL | |
| 37 | 34 | PDFVersion& operator=(PDFVersion const&) = default; |
| 35 | + | |
| 38 | 36 | QPDF_DLL |
| 39 | 37 | PDFVersion(int major, int minor, int extension = 0); |
| 40 | 38 | QPDF_DLL |
| ... | ... | @@ -59,9 +57,9 @@ class PDFVersion |
| 59 | 57 | int getExtensionLevel() const; |
| 60 | 58 | |
| 61 | 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 | 65 | #endif // PDFVERSION_HH | ... | ... |
include/qpdf/Pipeline.hh
| ... | ... | @@ -17,6 +17,14 @@ |
| 17 | 17 | // License. At your option, you may continue to consider qpdf to be licensed under those terms. |
| 18 | 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 | 28 | // Generalized Pipeline interface. By convention, subclasses of Pipeline are called Pl_Something. |
| 21 | 29 | // |
| 22 | 30 | // When an instance of Pipeline is created with a pointer to a next pipeline, that pipeline writes |
| ... | ... | @@ -32,15 +40,7 @@ |
| 32 | 40 | // Some pipelines are reusable (i.e., you can call write() after calling finish() and can call |
| 33 | 41 | // finish() multiple times) while others are not. It is up to the caller to use a pipeline |
| 34 | 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 | 44 | // Remember to use QPDF_DLL_CLASS on anything derived from Pipeline so it will work with |
| 45 | 45 | // dynamic_cast across the shared object boundary. |
| 46 | 46 | class QPDF_DLL_CLASS Pipeline |
| ... | ... | @@ -49,7 +49,6 @@ class QPDF_DLL_CLASS Pipeline |
| 49 | 49 | QPDF_DLL |
| 50 | 50 | Pipeline(char const* identifier, Pipeline* next); |
| 51 | 51 | |
| 52 | - QPDF_DLL | |
| 53 | 52 | virtual ~Pipeline() = default; |
| 54 | 53 | |
| 55 | 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 | 97 | protected: |
| 99 | 98 | QPDF_DLL |
| 100 | 99 | Pipeline* getNext(bool allow_null = false); |
| 101 | - QPDF_DLL | |
| 100 | + | |
| 102 | 101 | Pipeline* |
| 103 | 102 | next() const noexcept |
| 104 | 103 | { | ... | ... |
include/qpdf/Pl_Buffer.hh
| ... | ... | @@ -20,6 +20,12 @@ |
| 20 | 20 | #ifndef PL_BUFFER_HH |
| 21 | 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 | 29 | // This pipeline accumulates the data passed to it into a memory buffer. Each subsequent use of |
| 24 | 30 | // this buffer appends to the data accumulated so far. getBuffer() may be called only after calling |
| 25 | 31 | // finish() and before calling any subsequent write(). At that point, a dynamically allocated |
| ... | ... | @@ -28,13 +34,6 @@ |
| 28 | 34 | // |
| 29 | 35 | // For this pipeline, "next" may be null. If a next pointer is provided, this pipeline will also |
| 30 | 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 | 37 | class QPDF_DLL_CLASS Pl_Buffer: public Pipeline |
| 39 | 38 | { |
| 40 | 39 | public: |
| ... | ... | @@ -69,23 +68,9 @@ class QPDF_DLL_CLASS Pl_Buffer: public Pipeline |
| 69 | 68 | std::string getString(); |
| 70 | 69 | |
| 71 | 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 | 76 | #endif // PL_BUFFER_HH | ... | ... |
include/qpdf/Pl_Concatenate.hh
| ... | ... | @@ -20,18 +20,18 @@ |
| 20 | 20 | #ifndef PL_CONCATENATE_HH |
| 21 | 21 | #define PL_CONCATENATE_HH |
| 22 | 22 | |
| 23 | +#include <qpdf/Pipeline.hh> | |
| 24 | + | |
| 23 | 25 | // This pipeline will drop all regular finish calls rather than passing them onto next. To finish |
| 24 | 26 | // downstream streams, call manualFinish. This makes it possible to pipe multiple streams (e.g. |
| 25 | 27 | // with QPDFObjectHandle::pipeStreamData) to a downstream like Pl_Flate that can't handle multiple |
| 26 | 28 | // calls to finish(). |
| 27 | - | |
| 28 | -#include <qpdf/Pipeline.hh> | |
| 29 | - | |
| 30 | 29 | class QPDF_DLL_CLASS Pl_Concatenate: public Pipeline |
| 31 | 30 | { |
| 32 | 31 | public: |
| 33 | 32 | QPDF_DLL |
| 34 | 33 | Pl_Concatenate(char const* identifier, Pipeline* next); |
| 34 | + | |
| 35 | 35 | QPDF_DLL |
| 36 | 36 | ~Pl_Concatenate() override; |
| 37 | 37 | |
| ... | ... | @@ -51,7 +51,6 @@ class QPDF_DLL_CLASS Pl_Concatenate: public Pipeline |
| 51 | 51 | friend class Pl_Concatenate; |
| 52 | 52 | |
| 53 | 53 | public: |
| 54 | - QPDF_DLL | |
| 55 | 54 | ~Members() = default; |
| 56 | 55 | |
| 57 | 56 | private: |
| ... | ... | @@ -59,7 +58,7 @@ class QPDF_DLL_CLASS Pl_Concatenate: public Pipeline |
| 59 | 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 | 64 | #endif // PL_CONCATENATE_HH | ... | ... |
include/qpdf/Pl_Count.hh
| ... | ... | @@ -20,11 +20,10 @@ |
| 20 | 20 | #ifndef PL_COUNT_HH |
| 21 | 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 | 23 | #include <qpdf/Pipeline.hh> |
| 26 | 24 | #include <qpdf/Types.h> |
| 27 | 25 | |
| 26 | +// This pipeline is reusable; i.e., it is safe to call write() after calling finish(). | |
| 28 | 27 | class QPDF_DLL_CLASS Pl_Count: public Pipeline |
| 29 | 28 | { |
| 30 | 29 | public: |
| ... | ... | @@ -45,24 +44,9 @@ class QPDF_DLL_CLASS Pl_Count: public Pipeline |
| 45 | 44 | unsigned char getLastChar() const; |
| 46 | 45 | |
| 47 | 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 | 52 | #endif // PL_COUNT_HH | ... | ... |
include/qpdf/Pl_DCT.hh
| ... | ... | @@ -89,39 +89,9 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline |
| 89 | 89 | |
| 90 | 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 | 97 | #endif // PL_DCT_HH | ... | ... |
include/qpdf/Pl_Discard.hh
| ... | ... | @@ -20,12 +20,11 @@ |
| 20 | 20 | #ifndef PL_DISCARD_HH |
| 21 | 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 | 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 | 28 | class QPDF_DLL_CLASS Pl_Discard: public Pipeline |
| 30 | 29 | { |
| 31 | 30 | public: |
| ... | ... | @@ -37,22 +36,6 @@ class QPDF_DLL_CLASS Pl_Discard: public Pipeline |
| 37 | 36 | void write(unsigned char const*, size_t) override; |
| 38 | 37 | QPDF_DLL |
| 39 | 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 | 41 | #endif // PL_DISCARD_HH | ... | ... |
include/qpdf/Pl_Flate.hh
| ... | ... | @@ -104,11 +104,10 @@ class QPDF_DLL_CLASS Pl_Flate: public Pipeline |
| 104 | 104 | friend class Pl_Flate; |
| 105 | 105 | |
| 106 | 106 | public: |
| 107 | - QPDF_DLL | |
| 107 | + Members(size_t out_bufsize, action_e action); | |
| 108 | 108 | ~Members(); |
| 109 | 109 | |
| 110 | 110 | private: |
| 111 | - Members(size_t out_bufsize, action_e action); | |
| 112 | 111 | Members(Members const&) = delete; |
| 113 | 112 | |
| 114 | 113 | std::shared_ptr<unsigned char> outbuf; |
| ... | ... | @@ -121,7 +120,7 @@ class QPDF_DLL_CLASS Pl_Flate: public Pipeline |
| 121 | 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 | 126 | #endif // PL_FLATE_HH | ... | ... |
include/qpdf/Pl_Function.hh
| ... | ... | @@ -62,22 +62,9 @@ class QPDF_DLL_CLASS Pl_Function: public Pipeline |
| 62 | 62 | void finish() override; |
| 63 | 63 | |
| 64 | 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 | 70 | #endif // PL_FUNCTION_HH | ... | ... |
include/qpdf/Pl_OStream.hh
| ... | ... | @@ -17,8 +17,6 @@ |
| 17 | 17 | // License. At your option, you may continue to consider qpdf to be licensed under those terms. |
| 18 | 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 | 20 | #ifndef PL_OSTREAM_HH |
| 23 | 21 | #define PL_OSTREAM_HH |
| 24 | 22 | |
| ... | ... | @@ -26,10 +24,9 @@ |
| 26 | 24 | |
| 27 | 25 | #include <iostream> |
| 28 | 26 | |
| 27 | +// End-of-line pipeline that simply writes its data to a stdio FILE* object. | |
| 29 | 28 | // |
| 30 | 29 | // This pipeline is reusable. |
| 31 | -// | |
| 32 | - | |
| 33 | 30 | class QPDF_DLL_CLASS Pl_OStream: public Pipeline |
| 34 | 31 | { |
| 35 | 32 | public: |
| ... | ... | @@ -45,22 +42,9 @@ class QPDF_DLL_CLASS Pl_OStream: public Pipeline |
| 45 | 42 | void finish() override; |
| 46 | 43 | |
| 47 | 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 | 50 | #endif // PL_OSTREAM_HH | ... | ... |
include/qpdf/Pl_QPDFTokenizer.hh
| ... | ... | @@ -31,11 +31,10 @@ |
| 31 | 31 | // Tokenize the incoming text using QPDFTokenizer and pass the tokens in turn to a |
| 32 | 32 | // QPDFObjectHandle::TokenFilter object. All bytes of incoming content will be included in exactly |
| 33 | 33 | // one token and passed downstream. |
| 34 | - | |
| 34 | +// | |
| 35 | 35 | // This is a very low-level interface for working with token filters. Most code will want to use |
| 36 | 36 | // QPDFObjectHandle::filterPageContents or QPDFObjectHandle::addTokenFilter. See QPDFObjectHandle.hh |
| 37 | 37 | // for details. |
| 38 | - | |
| 39 | 38 | class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline |
| 40 | 39 | { |
| 41 | 40 | public: |
| ... | ... | @@ -52,23 +51,9 @@ class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline |
| 52 | 51 | void finish() override; |
| 53 | 52 | |
| 54 | 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 | 59 | #endif // PL_QPDFTOKENIZER_HH | ... | ... |
include/qpdf/Pl_RunLength.hh
| ... | ... | @@ -52,26 +52,9 @@ class QPDF_DLL_CLASS Pl_RunLength: public Pipeline |
| 52 | 52 | |
| 53 | 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 | 60 | #endif // PL_RUNLENGTH_HH | ... | ... |
include/qpdf/Pl_StdioFile.hh
| ... | ... | @@ -29,7 +29,6 @@ |
| 29 | 29 | // |
| 30 | 30 | // This pipeline is reusable. |
| 31 | 31 | // |
| 32 | - | |
| 33 | 32 | class QPDF_DLL_CLASS Pl_StdioFile: public Pipeline |
| 34 | 33 | { |
| 35 | 34 | public: |
| ... | ... | @@ -45,22 +44,10 @@ class QPDF_DLL_CLASS Pl_StdioFile: public Pipeline |
| 45 | 44 | void finish() override; |
| 46 | 45 | |
| 47 | 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 | 53 | #endif // PL_STDIOFILE_HH | ... | ... |
include/qpdf/Pl_String.hh
| ... | ... | @@ -20,6 +20,10 @@ |
| 20 | 20 | #ifndef PL_STRING_HH |
| 21 | 21 | #define PL_STRING_HH |
| 22 | 22 | |
| 23 | +#include <qpdf/Pipeline.hh> | |
| 24 | + | |
| 25 | +#include <string> | |
| 26 | + | |
| 23 | 27 | // This pipeline accumulates the data passed to it into a std::string, a reference to which is |
| 24 | 28 | // passed in at construction. Each subsequent use of this pipeline appends to the data accumulated |
| 25 | 29 | // so far. |
| ... | ... | @@ -31,11 +35,6 @@ |
| 31 | 35 | // this in front of another pipeline to capture data that is written to the other pipeline without |
| 32 | 36 | // interfering with when finish is called on the other pipeline and without having to put a |
| 33 | 37 | // Pl_Concatenate after it. |
| 34 | - | |
| 35 | -#include <qpdf/Pipeline.hh> | |
| 36 | - | |
| 37 | -#include <string> | |
| 38 | - | |
| 39 | 38 | class QPDF_DLL_CLASS Pl_String: public Pipeline |
| 40 | 39 | { |
| 41 | 40 | public: |
| ... | ... | @@ -50,22 +49,9 @@ class QPDF_DLL_CLASS Pl_String: public Pipeline |
| 50 | 49 | void finish() override; |
| 51 | 50 | |
| 52 | 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 | 57 | #endif // PL_STRING_HH | ... | ... |
include/qpdf/QPDF.hh
| ... | ... | @@ -1496,13 +1496,11 @@ class QPDF |
| 1496 | 1496 | friend class ResolveRecorder; |
| 1497 | 1497 | |
| 1498 | 1498 | public: |
| 1499 | - QPDF_DLL | |
| 1500 | - ~Members() = default; | |
| 1501 | - | |
| 1502 | - private: | |
| 1503 | 1499 | Members(); |
| 1504 | 1500 | Members(Members const&) = delete; |
| 1501 | + ~Members() = default; | |
| 1505 | 1502 | |
| 1503 | + private: | |
| 1506 | 1504 | std::shared_ptr<QPDFLogger> log; |
| 1507 | 1505 | unsigned long long unique_id{0}; |
| 1508 | 1506 | QPDFTokenizer tokenizer; |
| ... | ... | @@ -1577,7 +1575,7 @@ class QPDF |
| 1577 | 1575 | |
| 1578 | 1576 | // Keep all member variables inside the Members object, which we dynamically allocate. This |
| 1579 | 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 | 1581 | #endif // QPDF_HH | ... | ... |
include/qpdf/QPDFAcroFormDocumentHelper.hh
| ... | ... | @@ -20,6 +20,18 @@ |
| 20 | 20 | #ifndef QPDFACROFORMDOCUMENTHELPER_HH |
| 21 | 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 | 35 | // This document helper is intended to help with operations on interactive forms. Here are the key |
| 24 | 36 | // things to know: |
| 25 | 37 | |
| ... | ... | @@ -53,25 +65,12 @@ |
| 53 | 65 | // under "/Fields" in the "/AcroForm" dictionary. In a more complex case, you may have to trace |
| 54 | 66 | // through various "/Kids" elements in the "/AcroForm" field entry until you find the annotation |
| 55 | 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 | 68 | class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper |
| 70 | 69 | { |
| 71 | 70 | public: |
| 72 | 71 | QPDF_DLL |
| 73 | 72 | QPDFAcroFormDocumentHelper(QPDF&); |
| 74 | - QPDF_DLL | |
| 73 | + | |
| 75 | 74 | ~QPDFAcroFormDocumentHelper() override = default; |
| 76 | 75 | |
| 77 | 76 | // This class lazily creates an internal cache of the mapping among form fields, annotations, |
| ... | ... | @@ -232,7 +231,6 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper |
| 232 | 231 | friend class QPDFAcroFormDocumentHelper; |
| 233 | 232 | |
| 234 | 233 | public: |
| 235 | - QPDF_DLL | |
| 236 | 234 | ~Members() = default; |
| 237 | 235 | |
| 238 | 236 | private: | ... | ... |
include/qpdf/QPDFAnnotationObjectHelper.hh
| ... | ... | @@ -30,7 +30,7 @@ class QPDFAnnotationObjectHelper: public QPDFObjectHelper |
| 30 | 30 | public: |
| 31 | 31 | QPDF_DLL |
| 32 | 32 | QPDFAnnotationObjectHelper(QPDFObjectHandle); |
| 33 | - QPDF_DLL | |
| 33 | + | |
| 34 | 34 | ~QPDFAnnotationObjectHelper() override = default; |
| 35 | 35 | |
| 36 | 36 | // This class provides helper methods for annotations. More functionality will likely be added |
| ... | ... | @@ -92,7 +92,6 @@ class QPDFAnnotationObjectHelper: public QPDFObjectHelper |
| 92 | 92 | friend class QPDFAnnotationObjectHelper; |
| 93 | 93 | |
| 94 | 94 | public: |
| 95 | - QPDF_DLL | |
| 96 | 95 | ~Members() = default; |
| 97 | 96 | |
| 98 | 97 | private: | ... | ... |
include/qpdf/QPDFCryptoImpl.hh
| ... | ... | @@ -32,40 +32,28 @@ |
| 32 | 32 | // so, provide an implementation of QPDFCryptoImpl, ensure that you |
| 33 | 33 | // register it by calling QPDFCryptoProvider::registerImpl, and make |
| 34 | 34 | // it the default by calling QPDFCryptoProvider::setDefaultProvider. |
| 35 | - | |
| 36 | 35 | class QPDF_DLL_CLASS QPDFCryptoImpl |
| 37 | 36 | { |
| 38 | 37 | public: |
| 39 | - QPDF_DLL | |
| 40 | 38 | QPDFCryptoImpl() = default; |
| 41 | 39 | |
| 42 | - QPDF_DLL | |
| 43 | 40 | virtual ~QPDFCryptoImpl() = default; |
| 44 | 41 | |
| 45 | 42 | // Random Number Generation |
| 46 | 43 | |
| 47 | - QPDF_DLL | |
| 48 | 44 | virtual void provideRandomData(unsigned char* data, size_t len) = 0; |
| 49 | 45 | |
| 50 | 46 | // Hashing |
| 51 | 47 | |
| 52 | 48 | typedef unsigned char MD5_Digest[16]; |
| 53 | - QPDF_DLL | |
| 54 | 49 | virtual void MD5_init() = 0; |
| 55 | - QPDF_DLL | |
| 56 | 50 | virtual void MD5_update(unsigned char const* data, size_t len) = 0; |
| 57 | - QPDF_DLL | |
| 58 | 51 | virtual void MD5_finalize() = 0; |
| 59 | - QPDF_DLL | |
| 60 | 52 | virtual void MD5_digest(MD5_Digest) = 0; |
| 61 | 53 | |
| 62 | - QPDF_DLL | |
| 63 | 54 | virtual void SHA2_init(int bits) = 0; |
| 64 | - QPDF_DLL | |
| 65 | 55 | virtual void SHA2_update(unsigned char const* data, size_t len) = 0; |
| 66 | - QPDF_DLL | |
| 67 | 56 | virtual void SHA2_finalize() = 0; |
| 68 | - QPDF_DLL | |
| 69 | 57 | virtual std::string SHA2_digest() = 0; |
| 70 | 58 | |
| 71 | 59 | // Encryption/Decryption |
| ... | ... | @@ -74,26 +62,20 @@ class QPDF_DLL_CLASS QPDFCryptoImpl |
| 74 | 62 | // and readers. Search for RC4 in README.md |
| 75 | 63 | |
| 76 | 64 | // key_len of -1 means treat key_data as a null-terminated string |
| 77 | - QPDF_DLL | |
| 78 | 65 | virtual void RC4_init(unsigned char const* key_data, int key_len = -1) = 0; |
| 79 | 66 | // out_data = 0 means to encrypt/decrypt in place |
| 80 | - QPDF_DLL | |
| 81 | 67 | virtual void |
| 82 | 68 | RC4_process(unsigned char const* in_data, size_t len, unsigned char* out_data = nullptr) = 0; |
| 83 | - QPDF_DLL | |
| 84 | 69 | virtual void RC4_finalize() = 0; |
| 85 | 70 | |
| 86 | 71 | static size_t constexpr rijndael_buf_size = 16; |
| 87 | - QPDF_DLL | |
| 88 | 72 | virtual void rijndael_init( |
| 89 | 73 | bool encrypt, |
| 90 | 74 | unsigned char const* key_data, |
| 91 | 75 | size_t key_len, |
| 92 | 76 | bool cbc_mode, |
| 93 | 77 | unsigned char* cbc_block) = 0; |
| 94 | - QPDF_DLL | |
| 95 | 78 | virtual void rijndael_process(unsigned char* in_data, unsigned char* out_data) = 0; |
| 96 | - QPDF_DLL | |
| 97 | 79 | virtual void rijndael_finalize() = 0; |
| 98 | 80 | }; |
| 99 | 81 | ... | ... |
include/qpdf/QPDFCryptoProvider.hh
| ... | ... | @@ -31,7 +31,6 @@ |
| 31 | 31 | // This class is part of qpdf's pluggable crypto provider support. Most users won't need to know or |
| 32 | 32 | // care about this class, but you can use it if you want to supply your own crypto implementation. |
| 33 | 33 | // See also comments in QPDFCryptoImpl.hh. |
| 34 | - | |
| 35 | 34 | class QPDFCryptoProvider |
| 36 | 35 | { |
| 37 | 36 | public: |
| ... | ... | @@ -92,7 +91,6 @@ class QPDFCryptoProvider |
| 92 | 91 | |
| 93 | 92 | public: |
| 94 | 93 | Members() = default; |
| 95 | - QPDF_DLL | |
| 96 | 94 | ~Members() = default; |
| 97 | 95 | |
| 98 | 96 | private: | ... | ... |
include/qpdf/QPDFDocumentHelper.hh
| ... | ... | @@ -30,28 +30,24 @@ |
| 30 | 30 | // the underlying QPDF object unless there is a specific comment in a specific helper method that |
| 31 | 31 | // says otherwise. The pattern of using helper objects was introduced to allow creation of higher |
| 32 | 32 | // level helper functions without polluting the public interface of QPDF. |
| 33 | - | |
| 34 | 33 | class QPDF_DLL_CLASS QPDFDocumentHelper |
| 35 | 34 | { |
| 36 | 35 | public: |
| 37 | - QPDF_DLL | |
| 38 | 36 | QPDFDocumentHelper(QPDF& qpdf) : |
| 39 | 37 | qpdf(qpdf) |
| 40 | 38 | { |
| 41 | 39 | } |
| 42 | 40 | QPDF_DLL |
| 43 | 41 | virtual ~QPDFDocumentHelper(); |
| 44 | - QPDF_DLL | |
| 45 | 42 | QPDF& |
| 46 | 43 | getQPDF() |
| 47 | 44 | { |
| 48 | - return this->qpdf; | |
| 45 | + return qpdf; | |
| 49 | 46 | } |
| 50 | - QPDF_DLL | |
| 51 | 47 | QPDF const& |
| 52 | 48 | getQPDF() const |
| 53 | 49 | { |
| 54 | - return this->qpdf; | |
| 50 | + return qpdf; | |
| 55 | 51 | } |
| 56 | 52 | |
| 57 | 53 | protected: | ... | ... |
include/qpdf/QPDFEFStreamObjectHelper.hh
| ... | ... | @@ -29,13 +29,12 @@ |
| 29 | 29 | |
| 30 | 30 | // This class provides a higher level interface around Embedded File Streams, which are discussed in |
| 31 | 31 | // section 7.11.4 of the ISO-32000 PDF specification. |
| 32 | - | |
| 33 | 32 | class QPDFEFStreamObjectHelper: public QPDFObjectHelper |
| 34 | 33 | { |
| 35 | 34 | public: |
| 36 | 35 | QPDF_DLL |
| 37 | 36 | QPDFEFStreamObjectHelper(QPDFObjectHandle); |
| 38 | - QPDF_DLL | |
| 37 | + | |
| 39 | 38 | ~QPDFEFStreamObjectHelper() override = default; |
| 40 | 39 | |
| 41 | 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 | 97 | friend class QPDFEFStreamObjectHelper; |
| 99 | 98 | |
| 100 | 99 | public: |
| 101 | - QPDF_DLL | |
| 102 | 100 | ~Members() = default; |
| 103 | 101 | |
| 104 | 102 | private: | ... | ... |
include/qpdf/QPDFEmbeddedFileDocumentHelper.hh
| ... | ... | @@ -33,13 +33,12 @@ |
| 33 | 33 | // This class provides a higher level interface around document-level file attachments, also known |
| 34 | 34 | // as embedded files. These are discussed in sections 7.7.4 and 7.11 of the ISO-32000 PDF |
| 35 | 35 | // specification. |
| 36 | - | |
| 37 | 36 | class QPDFEmbeddedFileDocumentHelper: public QPDFDocumentHelper |
| 38 | 37 | { |
| 39 | 38 | public: |
| 40 | 39 | QPDF_DLL |
| 41 | 40 | QPDFEmbeddedFileDocumentHelper(QPDF&); |
| 42 | - QPDF_DLL | |
| 41 | + | |
| 43 | 42 | ~QPDFEmbeddedFileDocumentHelper() override = default; |
| 44 | 43 | |
| 45 | 44 | QPDF_DLL |
| ... | ... | @@ -73,7 +72,6 @@ class QPDFEmbeddedFileDocumentHelper: public QPDFDocumentHelper |
| 73 | 72 | friend class QPDFEmbeddedFileDocumentHelper; |
| 74 | 73 | |
| 75 | 74 | public: |
| 76 | - QPDF_DLL | |
| 77 | 75 | ~Members() = default; |
| 78 | 76 | |
| 79 | 77 | private: | ... | ... |
include/qpdf/QPDFExc.hh
| ... | ... | @@ -37,7 +37,7 @@ class QPDF_DLL_CLASS QPDFExc: public std::runtime_error |
| 37 | 37 | std::string const& object, |
| 38 | 38 | qpdf_offset_t offset, |
| 39 | 39 | std::string const& message); |
| 40 | - QPDF_DLL | |
| 40 | + | |
| 41 | 41 | ~QPDFExc() noexcept override = default; |
| 42 | 42 | |
| 43 | 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 | 29 | |
| 30 | 30 | // This class provides a higher level interface around File Specification dictionaries, which are |
| 31 | 31 | // discussed in section 7.11 of the ISO-32000 PDF specification. |
| 32 | - | |
| 33 | 32 | class QPDFFileSpecObjectHelper: public QPDFObjectHelper |
| 34 | 33 | { |
| 35 | 34 | public: |
| 36 | 35 | QPDF_DLL |
| 37 | 36 | QPDFFileSpecObjectHelper(QPDFObjectHandle); |
| 38 | - QPDF_DLL | |
| 37 | + | |
| 39 | 38 | ~QPDFFileSpecObjectHelper() override = default; |
| 40 | 39 | |
| 41 | 40 | QPDF_DLL |
| ... | ... | @@ -93,7 +92,6 @@ class QPDFFileSpecObjectHelper: public QPDFObjectHelper |
| 93 | 92 | friend class QPDFFileSpecObjectHelper; |
| 94 | 93 | |
| 95 | 94 | public: |
| 96 | - QPDF_DLL | |
| 97 | 95 | ~Members() = default; |
| 98 | 96 | |
| 99 | 97 | private: | ... | ... |
include/qpdf/QPDFFormFieldObjectHelper.hh
| ... | ... | @@ -20,9 +20,6 @@ |
| 20 | 20 | #ifndef QPDFFORMFIELDOBJECTHELPER_HH |
| 21 | 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 | 23 | #include <qpdf/QPDFObjectHelper.hh> |
| 27 | 24 | |
| 28 | 25 | #include <qpdf/DLL.h> |
| ... | ... | @@ -30,6 +27,8 @@ |
| 30 | 27 | |
| 31 | 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 | 32 | class QPDFFormFieldObjectHelper: public QPDFObjectHelper |
| 34 | 33 | { |
| 35 | 34 | public: |
| ... | ... | @@ -37,7 +36,7 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper |
| 37 | 36 | QPDFFormFieldObjectHelper(); |
| 38 | 37 | QPDF_DLL |
| 39 | 38 | QPDFFormFieldObjectHelper(QPDFObjectHandle); |
| 40 | - QPDF_DLL | |
| 39 | + | |
| 41 | 40 | ~QPDFFormFieldObjectHelper() override = default; |
| 42 | 41 | |
| 43 | 42 | QPDF_DLL |
| ... | ... | @@ -199,7 +198,6 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper |
| 199 | 198 | friend class QPDFFormFieldObjectHelper; |
| 200 | 199 | |
| 201 | 200 | public: |
| 202 | - QPDF_DLL | |
| 203 | 201 | ~Members() = default; |
| 204 | 202 | |
| 205 | 203 | private: | ... | ... |
include/qpdf/QPDFLogger.hh
include/qpdf/QPDFMatrix.hh
| ... | ... | @@ -31,7 +31,6 @@ |
| 31 | 31 | // (a, b, c, d, e, f) = │ c d 0 │ |
| 32 | 32 | // │ e f 1 │ |
| 33 | 33 | // └ ┘ |
| 34 | - | |
| 35 | 34 | class QPDFMatrix |
| 36 | 35 | { |
| 37 | 36 | public: |
| ... | ... | @@ -79,12 +78,9 @@ class QPDFMatrix |
| 79 | 78 | // operator== tests for exact equality, not considering deltas for floating point. |
| 80 | 79 | QPDF_DLL |
| 81 | 80 | bool operator==(QPDFMatrix const& rhs) const; |
| 81 | + | |
| 82 | 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 | 85 | double a; |
| 90 | 86 | double b; | ... | ... |
include/qpdf/QPDFNameTreeObjectHelper.hh
| ... | ... | @@ -28,16 +28,15 @@ |
| 28 | 28 | |
| 29 | 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 | 31 | class NNTreeImpl; |
| 38 | 32 | class NNTreeIterator; |
| 39 | 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 | 40 | class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper |
| 42 | 41 | { |
| 43 | 42 | public: |
| ... | ... | @@ -78,7 +77,6 @@ class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper |
| 78 | 77 | bool valid() const; |
| 79 | 78 | QPDF_DLL |
| 80 | 79 | iterator& operator++(); |
| 81 | - QPDF_DLL | |
| 82 | 80 | iterator |
| 83 | 81 | operator++(int) |
| 84 | 82 | { |
| ... | ... | @@ -88,7 +86,6 @@ class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper |
| 88 | 86 | } |
| 89 | 87 | QPDF_DLL |
| 90 | 88 | iterator& operator--(); |
| 91 | - QPDF_DLL | |
| 92 | 89 | iterator |
| 93 | 90 | operator--(int) |
| 94 | 91 | { |
| ... | ... | @@ -102,7 +99,6 @@ class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper |
| 102 | 99 | pointer operator->(); |
| 103 | 100 | QPDF_DLL |
| 104 | 101 | bool operator==(iterator const& other) const; |
| 105 | - QPDF_DLL | |
| 106 | 102 | bool |
| 107 | 103 | operator!=(iterator const& other) const |
| 108 | 104 | { |
| ... | ... | @@ -172,7 +168,6 @@ class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper |
| 172 | 168 | friend class QPDFNameTreeObjectHelper; |
| 173 | 169 | |
| 174 | 170 | public: |
| 175 | - QPDF_DLL | |
| 176 | 171 | ~Members() = default; |
| 177 | 172 | |
| 178 | 173 | private: | ... | ... |
include/qpdf/QPDFNumberTreeObjectHelper.hh
| ... | ... | @@ -27,15 +27,14 @@ |
| 27 | 27 | |
| 28 | 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 | 30 | class NNTreeImpl; |
| 36 | 31 | class NNTreeIterator; |
| 37 | 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 | 38 | class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper |
| 40 | 39 | { |
| 41 | 40 | public: |
| ... | ... | @@ -93,7 +92,6 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper |
| 93 | 92 | bool valid() const; |
| 94 | 93 | QPDF_DLL |
| 95 | 94 | iterator& operator++(); |
| 96 | - QPDF_DLL | |
| 97 | 95 | iterator |
| 98 | 96 | operator++(int) |
| 99 | 97 | { |
| ... | ... | @@ -103,7 +101,6 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper |
| 103 | 101 | } |
| 104 | 102 | QPDF_DLL |
| 105 | 103 | iterator& operator--(); |
| 106 | - QPDF_DLL | |
| 107 | 104 | iterator |
| 108 | 105 | operator--(int) |
| 109 | 106 | { |
| ... | ... | @@ -117,7 +114,6 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper |
| 117 | 114 | pointer operator->(); |
| 118 | 115 | QPDF_DLL |
| 119 | 116 | bool operator==(iterator const& other) const; |
| 120 | - QPDF_DLL | |
| 121 | 117 | bool |
| 122 | 118 | operator!=(iterator const& other) const |
| 123 | 119 | { |
| ... | ... | @@ -189,7 +185,6 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper |
| 189 | 185 | typedef QPDFNumberTreeObjectHelper::numtree_number numtree_number; |
| 190 | 186 | |
| 191 | 187 | public: |
| 192 | - QPDF_DLL | |
| 193 | 188 | ~Members() = default; |
| 194 | 189 | |
| 195 | 190 | private: | ... | ... |
include/qpdf/QPDFObjGen.hh
| ... | ... | @@ -35,57 +35,47 @@ class QPDFObjectHelper; |
| 35 | 35 | class QPDFObjGen |
| 36 | 36 | { |
| 37 | 37 | public: |
| 38 | - QPDF_DLL | |
| 39 | 38 | QPDFObjGen() = default; |
| 40 | - QPDF_DLL | |
| 41 | 39 | QPDFObjGen(int obj, int gen) : |
| 42 | 40 | obj(obj), |
| 43 | 41 | gen(gen) |
| 44 | 42 | { |
| 45 | 43 | } |
| 46 | - QPDF_DLL | |
| 47 | 44 | bool |
| 48 | 45 | operator<(QPDFObjGen const& rhs) const |
| 49 | 46 | { |
| 50 | 47 | return (obj < rhs.obj) || (obj == rhs.obj && gen < rhs.gen); |
| 51 | 48 | } |
| 52 | - QPDF_DLL | |
| 53 | 49 | bool |
| 54 | 50 | operator==(QPDFObjGen const& rhs) const |
| 55 | 51 | { |
| 56 | 52 | return obj == rhs.obj && gen == rhs.gen; |
| 57 | 53 | } |
| 58 | - QPDF_DLL | |
| 59 | 54 | bool |
| 60 | 55 | operator!=(QPDFObjGen const& rhs) const |
| 61 | 56 | { |
| 62 | 57 | return !(*this == rhs); |
| 63 | 58 | } |
| 64 | - QPDF_DLL | |
| 65 | 59 | int |
| 66 | 60 | getObj() const |
| 67 | 61 | { |
| 68 | 62 | return obj; |
| 69 | 63 | } |
| 70 | - QPDF_DLL | |
| 71 | 64 | int |
| 72 | 65 | getGen() const |
| 73 | 66 | { |
| 74 | 67 | return gen; |
| 75 | 68 | } |
| 76 | - QPDF_DLL | |
| 77 | 69 | bool |
| 78 | 70 | isIndirect() const |
| 79 | 71 | { |
| 80 | 72 | return obj != 0; |
| 81 | 73 | } |
| 82 | - QPDF_DLL | |
| 83 | 74 | std::string |
| 84 | 75 | unparse(char separator = ',') const |
| 85 | 76 | { |
| 86 | 77 | return std::to_string(obj) + separator + std::to_string(gen); |
| 87 | 78 | } |
| 88 | - QPDF_DLL | |
| 89 | 79 | friend std::ostream& |
| 90 | 80 | operator<<(std::ostream& os, QPDFObjGen og) |
| 91 | 81 | { |
| ... | ... | @@ -116,7 +106,6 @@ class QPDFObjGen |
| 116 | 106 | public: |
| 117 | 107 | // Add 'og' to the set. Return false if 'og' is already present in the set. Attempts to |
| 118 | 108 | // insert QPDFObjGen(0, 0) are ignored. |
| 119 | - QPDF_DLL | |
| 120 | 109 | bool |
| 121 | 110 | add(QPDFObjGen og) |
| 122 | 111 | { |
| ... | ... | @@ -129,7 +118,6 @@ class QPDFObjGen |
| 129 | 118 | return true; |
| 130 | 119 | } |
| 131 | 120 | |
| 132 | - QPDF_DLL | |
| 133 | 121 | void |
| 134 | 122 | erase(QPDFObjGen og) |
| 135 | 123 | { | ... | ... |
include/qpdf/QPDFObjectHandle.hh
| ... | ... | @@ -156,9 +156,7 @@ class QPDFObjectHandle final: public qpdf::BaseHandle |
| 156 | 156 | class QPDF_DLL_CLASS TokenFilter |
| 157 | 157 | { |
| 158 | 158 | public: |
| 159 | - QPDF_DLL | |
| 160 | 159 | TokenFilter() = default; |
| 161 | - QPDF_DLL | |
| 162 | 160 | virtual ~TokenFilter() = default; |
| 163 | 161 | virtual void handleToken(QPDFTokenizer::Token const&) = 0; |
| 164 | 162 | QPDF_DLL |
| ... | ... | @@ -196,7 +194,6 @@ class QPDFObjectHandle final: public qpdf::BaseHandle |
| 196 | 194 | class StringDecrypter |
| 197 | 195 | { |
| 198 | 196 | public: |
| 199 | - QPDF_DLL | |
| 200 | 197 | virtual ~StringDecrypter() = default; |
| 201 | 198 | virtual void decryptString(std::string& val) = 0; |
| 202 | 199 | }; |
| ... | ... | @@ -206,7 +203,6 @@ class QPDFObjectHandle final: public qpdf::BaseHandle |
| 206 | 203 | class QPDF_DLL_CLASS ParserCallbacks |
| 207 | 204 | { |
| 208 | 205 | public: |
| 209 | - QPDF_DLL | |
| 210 | 206 | virtual ~ParserCallbacks() = default; |
| 211 | 207 | // One of the handleObject methods must be overridden. |
| 212 | 208 | QPDF_DLL |
| ... | ... | @@ -286,18 +282,13 @@ class QPDFObjectHandle final: public qpdf::BaseHandle |
| 286 | 282 | double f; |
| 287 | 283 | }; |
| 288 | 284 | |
| 289 | - QPDF_DLL | |
| 290 | 285 | QPDFObjectHandle() = default; |
| 291 | - QPDF_DLL | |
| 292 | 286 | QPDFObjectHandle(QPDFObjectHandle const&) = default; |
| 293 | - QPDF_DLL | |
| 294 | 287 | QPDFObjectHandle& operator=(QPDFObjectHandle const&) = default; |
| 295 | - QPDF_DLL | |
| 296 | 288 | QPDFObjectHandle(QPDFObjectHandle&&) = default; |
| 297 | - QPDF_DLL | |
| 298 | 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 | 293 | // This method returns true if the QPDFObjectHandle objects point to exactly the same underlying |
| 303 | 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 | 339 | |
| 349 | 340 | // This returns true in addition to the query for the specific type for indirect objects. |
| 350 | 341 | QPDF_DLL |
| 351 | - inline bool isIndirect() const; | |
| 342 | + bool isIndirect() const; | |
| 352 | 343 | |
| 353 | 344 | // This returns true for indirect objects from a QPDF that has been destroyed. Trying unparse |
| 354 | 345 | // such an object will throw a logic_error. |
| ... | ... | @@ -1145,9 +1136,9 @@ class QPDFObjectHandle final: public qpdf::BaseHandle |
| 1145 | 1136 | QPDF_DLL |
| 1146 | 1137 | QPDFObjGen getObjGen() const; |
| 1147 | 1138 | QPDF_DLL |
| 1148 | - inline int getObjectID() const; | |
| 1139 | + int getObjectID() const; | |
| 1149 | 1140 | QPDF_DLL |
| 1150 | - inline int getGeneration() const; | |
| 1141 | + int getGeneration() const; | |
| 1151 | 1142 | |
| 1152 | 1143 | QPDF_DLL |
| 1153 | 1144 | std::string unparse() const; |
| ... | ... | @@ -1424,11 +1415,9 @@ class QPDFObjectHandle::QPDFDictItems |
| 1424 | 1415 | using pointer = T*; |
| 1425 | 1416 | using reference = T&; |
| 1426 | 1417 | |
| 1427 | - QPDF_DLL | |
| 1428 | 1418 | virtual ~iterator() = default; |
| 1429 | 1419 | QPDF_DLL |
| 1430 | 1420 | iterator& operator++(); |
| 1431 | - QPDF_DLL | |
| 1432 | 1421 | iterator |
| 1433 | 1422 | operator++(int) |
| 1434 | 1423 | { |
| ... | ... | @@ -1438,7 +1427,6 @@ class QPDFObjectHandle::QPDFDictItems |
| 1438 | 1427 | } |
| 1439 | 1428 | QPDF_DLL |
| 1440 | 1429 | iterator& operator--(); |
| 1441 | - QPDF_DLL | |
| 1442 | 1430 | iterator |
| 1443 | 1431 | operator--(int) |
| 1444 | 1432 | { |
| ... | ... | @@ -1452,7 +1440,6 @@ class QPDFObjectHandle::QPDFDictItems |
| 1452 | 1440 | pointer operator->(); |
| 1453 | 1441 | QPDF_DLL |
| 1454 | 1442 | bool operator==(iterator const& other) const; |
| 1455 | - QPDF_DLL | |
| 1456 | 1443 | bool |
| 1457 | 1444 | operator!=(iterator const& other) const |
| 1458 | 1445 | { |
| ... | ... | @@ -1468,7 +1455,6 @@ class QPDFObjectHandle::QPDFDictItems |
| 1468 | 1455 | friend class QPDFDictItems::iterator; |
| 1469 | 1456 | |
| 1470 | 1457 | public: |
| 1471 | - QPDF_DLL | |
| 1472 | 1458 | ~Members() = default; |
| 1473 | 1459 | |
| 1474 | 1460 | private: |
| ... | ... | @@ -1522,11 +1508,9 @@ class QPDFObjectHandle::QPDFArrayItems |
| 1522 | 1508 | using pointer = T*; |
| 1523 | 1509 | using reference = T&; |
| 1524 | 1510 | |
| 1525 | - QPDF_DLL | |
| 1526 | 1511 | virtual ~iterator() = default; |
| 1527 | 1512 | QPDF_DLL |
| 1528 | 1513 | iterator& operator++(); |
| 1529 | - QPDF_DLL | |
| 1530 | 1514 | iterator |
| 1531 | 1515 | operator++(int) |
| 1532 | 1516 | { |
| ... | ... | @@ -1536,7 +1520,6 @@ class QPDFObjectHandle::QPDFArrayItems |
| 1536 | 1520 | } |
| 1537 | 1521 | QPDF_DLL |
| 1538 | 1522 | iterator& operator--(); |
| 1539 | - QPDF_DLL | |
| 1540 | 1523 | iterator |
| 1541 | 1524 | operator--(int) |
| 1542 | 1525 | { |
| ... | ... | @@ -1550,7 +1533,6 @@ class QPDFObjectHandle::QPDFArrayItems |
| 1550 | 1533 | pointer operator->(); |
| 1551 | 1534 | QPDF_DLL |
| 1552 | 1535 | bool operator==(iterator const& other) const; |
| 1553 | - QPDF_DLL | |
| 1554 | 1536 | bool |
| 1555 | 1537 | operator!=(iterator const& other) const |
| 1556 | 1538 | { |
| ... | ... | @@ -1566,7 +1548,6 @@ class QPDFObjectHandle::QPDFArrayItems |
| 1566 | 1548 | friend class QPDFArrayItems::iterator; |
| 1567 | 1549 | |
| 1568 | 1550 | public: |
| 1569 | - QPDF_DLL | |
| 1570 | 1551 | ~Members() = default; |
| 1571 | 1552 | |
| 1572 | 1553 | private: |
| ... | ... | @@ -1607,24 +1588,6 @@ namespace qpdf |
| 1607 | 1588 | |
| 1608 | 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 | 1591 | inline bool |
| 1629 | 1592 | QPDFObjectHandle::isInitialized() const |
| 1630 | 1593 | { | ... | ... |
include/qpdf/QPDFObjectHelper.hh
| ... | ... | @@ -34,20 +34,17 @@ |
| 34 | 34 | class QPDF_DLL_CLASS QPDFObjectHelper: public qpdf::BaseHandle |
| 35 | 35 | { |
| 36 | 36 | public: |
| 37 | - QPDF_DLL | |
| 38 | 37 | QPDFObjectHelper(QPDFObjectHandle oh) : |
| 39 | 38 | qpdf::BaseHandle(oh.getObj()) |
| 40 | 39 | { |
| 41 | 40 | } |
| 42 | 41 | QPDF_DLL |
| 43 | 42 | virtual ~QPDFObjectHelper(); |
| 44 | - QPDF_DLL | |
| 45 | 43 | QPDFObjectHandle |
| 46 | 44 | getObjectHandle() |
| 47 | 45 | { |
| 48 | 46 | return {obj}; |
| 49 | 47 | } |
| 50 | - QPDF_DLL | |
| 51 | 48 | QPDFObjectHandle const |
| 52 | 49 | getObjectHandle() const |
| 53 | 50 | { | ... | ... |
include/qpdf/QPDFOutlineDocumentHelper.hh
| ... | ... | @@ -35,13 +35,12 @@ |
| 35 | 35 | // section 12.3.3 of the PDF spec (ISO-32000). With the help of QPDFOutlineObjectHelper, the |
| 36 | 36 | // outlines tree is traversed, and a bidirectional map is made between pages and outlines. See also |
| 37 | 37 | // QPDFOutlineObjectHelper. |
| 38 | - | |
| 39 | 38 | class QPDFOutlineDocumentHelper: public QPDFDocumentHelper |
| 40 | 39 | { |
| 41 | 40 | public: |
| 42 | 41 | QPDF_DLL |
| 43 | 42 | QPDFOutlineDocumentHelper(QPDF&); |
| 44 | - QPDF_DLL | |
| 43 | + | |
| 45 | 44 | ~QPDFOutlineDocumentHelper() override = default; |
| 46 | 45 | |
| 47 | 46 | QPDF_DLL |
| ... | ... | @@ -79,7 +78,6 @@ class QPDFOutlineDocumentHelper: public QPDFDocumentHelper |
| 79 | 78 | friend class QPDFOutlineDocumentHelper; |
| 80 | 79 | |
| 81 | 80 | public: |
| 82 | - QPDF_DLL | |
| 83 | 81 | ~Members() = default; |
| 84 | 82 | |
| 85 | 83 | private: | ... | ... |
include/qpdf/QPDFOutlineObjectHelper.hh
| ... | ... | @@ -30,11 +30,9 @@ class QPDFOutlineDocumentHelper; |
| 30 | 30 | |
| 31 | 31 | // This is an object helper for outline items. Outlines, also known as bookmarks, are described in |
| 32 | 32 | // section 12.3.3 of the PDF spec (ISO-32000). See comments below for details. |
| 33 | - | |
| 34 | 33 | class QPDFOutlineObjectHelper: public QPDFObjectHelper |
| 35 | 34 | { |
| 36 | 35 | public: |
| 37 | - QPDF_DLL | |
| 38 | 36 | ~QPDFOutlineObjectHelper() override |
| 39 | 37 | { |
| 40 | 38 | // This must be cleared explicitly to avoid circular references that prevent cleanup of |
| ... | ... | @@ -87,7 +85,6 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper |
| 87 | 85 | }; |
| 88 | 86 | |
| 89 | 87 | private: |
| 90 | - QPDF_DLL | |
| 91 | 88 | QPDFOutlineObjectHelper(QPDFObjectHandle, QPDFOutlineDocumentHelper&, int); |
| 92 | 89 | |
| 93 | 90 | class Members |
| ... | ... | @@ -95,7 +92,6 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper |
| 95 | 92 | friend class QPDFOutlineObjectHelper; |
| 96 | 93 | |
| 97 | 94 | public: |
| 98 | - QPDF_DLL | |
| 99 | 95 | ~Members() = default; |
| 100 | 96 | |
| 101 | 97 | private: | ... | ... |
include/qpdf/QPDFPageDocumentHelper.hh
| ... | ... | @@ -37,7 +37,7 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper |
| 37 | 37 | public: |
| 38 | 38 | QPDF_DLL |
| 39 | 39 | QPDFPageDocumentHelper(QPDF&); |
| 40 | - QPDF_DLL | |
| 40 | + | |
| 41 | 41 | ~QPDFPageDocumentHelper() override = default; |
| 42 | 42 | |
| 43 | 43 | // Traverse page tree, and return all /Page objects wrapped in QPDFPageObjectHelper objects. |
| ... | ... | @@ -117,7 +117,6 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper |
| 117 | 117 | friend class QPDFPageDocumentHelper; |
| 118 | 118 | |
| 119 | 119 | public: |
| 120 | - QPDF_DLL | |
| 121 | 120 | ~Members() = default; |
| 122 | 121 | |
| 123 | 122 | private: | ... | ... |
include/qpdf/QPDFPageLabelDocumentHelper.hh
| ... | ... | @@ -44,7 +44,7 @@ class QPDFPageLabelDocumentHelper: public QPDFDocumentHelper |
| 44 | 44 | public: |
| 45 | 45 | QPDF_DLL |
| 46 | 46 | QPDFPageLabelDocumentHelper(QPDF&); |
| 47 | - QPDF_DLL | |
| 47 | + | |
| 48 | 48 | ~QPDFPageLabelDocumentHelper() override = default; |
| 49 | 49 | |
| 50 | 50 | QPDF_DLL |
| ... | ... | @@ -82,7 +82,6 @@ class QPDFPageLabelDocumentHelper: public QPDFDocumentHelper |
| 82 | 82 | friend class QPDFPageLabelDocumentHelper; |
| 83 | 83 | |
| 84 | 84 | public: |
| 85 | - QPDF_DLL | |
| 86 | 85 | ~Members() = default; |
| 87 | 86 | |
| 88 | 87 | private: | ... | ... |
include/qpdf/QPDFPageObjectHelper.hh
| ... | ... | @@ -31,15 +31,14 @@ |
| 31 | 31 | |
| 32 | 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 | 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 | 38 | public: |
| 40 | 39 | QPDF_DLL |
| 41 | 40 | QPDFPageObjectHelper(QPDFObjectHandle); |
| 42 | - QPDF_DLL | |
| 41 | + | |
| 43 | 42 | ~QPDFPageObjectHelper() override = default; |
| 44 | 43 | |
| 45 | 44 | // PAGE ATTRIBUTES |
| ... | ... | @@ -411,7 +410,6 @@ class QPDFPageObjectHelper: public QPDFObjectHelper |
| 411 | 410 | friend class QPDFPageObjectHelper; |
| 412 | 411 | |
| 413 | 412 | public: |
| 414 | - QPDF_DLL | |
| 415 | 413 | ~Members() = default; |
| 416 | 414 | |
| 417 | 415 | private: | ... | ... |
include/qpdf/QPDFStreamFilter.hh
| ... | ... | @@ -27,10 +27,8 @@ |
| 27 | 27 | class QPDF_DLL_CLASS QPDFStreamFilter |
| 28 | 28 | { |
| 29 | 29 | public: |
| 30 | - QPDF_DLL | |
| 31 | 30 | QPDFStreamFilter() = default; |
| 32 | 31 | |
| 33 | - QPDF_DLL | |
| 34 | 32 | virtual ~QPDFStreamFilter() = default; |
| 35 | 33 | |
| 36 | 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 | 32 | public: |
| 33 | 33 | QPDF_DLL |
| 34 | 34 | QPDFSystemError(std::string const& description, int system_errno); |
| 35 | - QPDF_DLL | |
| 35 | + | |
| 36 | 36 | ~QPDFSystemError() noexcept override = default; |
| 37 | 37 | |
| 38 | 38 | // To get a complete error string, call what(), provided by std::exception. The accessors below | ... | ... |
include/qpdf/QPDFUsage.hh
include/qpdf/QPDFWriter.hh
| ... | ... | @@ -17,9 +17,6 @@ |
| 17 | 17 | // License. At your option, you may continue to consider qpdf to be licensed under those terms. |
| 18 | 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 | 20 | #ifndef QPDFWRITER_HH |
| 24 | 21 | #define QPDFWRITER_HH |
| 25 | 22 | |
| ... | ... | @@ -51,6 +48,8 @@ class QPDF; |
| 51 | 48 | class Pl_Count; |
| 52 | 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 | 53 | class QPDFWriter |
| 55 | 54 | { |
| 56 | 55 | public: |
| ... | ... | @@ -71,7 +70,6 @@ class QPDFWriter |
| 71 | 70 | QPDF_DLL |
| 72 | 71 | QPDFWriter(QPDF& pdf, char const* description, FILE* file, bool close_file); |
| 73 | 72 | |
| 74 | - QPDF_DLL | |
| 75 | 73 | ~QPDFWriter() = default; |
| 76 | 74 | |
| 77 | 75 | class QPDF_DLL_CLASS ProgressReporter | ... | ... |
include/qpdf/QPDFXRefEntry.hh
| ... | ... | @@ -37,14 +37,12 @@ class QPDFXRefEntry |
| 37 | 37 | QPDF_DLL |
| 38 | 38 | QPDFXRefEntry(int type, qpdf_offset_t field1, int field2); |
| 39 | 39 | // Create a type 1 "uncompressed" entry. |
| 40 | - QPDF_DLL | |
| 41 | 40 | QPDFXRefEntry(qpdf_offset_t offset) : |
| 42 | 41 | type(1), |
| 43 | 42 | field1(offset) |
| 44 | 43 | { |
| 45 | 44 | } |
| 46 | 45 | // Create a type 2 "compressed" entry. |
| 47 | - QPDF_DLL | |
| 48 | 46 | QPDFXRefEntry(int stream_number, int index) : |
| 49 | 47 | type(2), |
| 50 | 48 | field1(stream_number), | ... | ... |
include/qpdf/QUtil.hh
| ... | ... | @@ -190,7 +190,7 @@ namespace QUtil |
| 190 | 190 | |
| 191 | 191 | // Returns lower-case hex-encoded version of the char including a leading "#". |
| 192 | 192 | QPDF_DLL |
| 193 | - inline std::string hex_encode_char(char); | |
| 193 | + std::string hex_encode_char(char); | |
| 194 | 194 | |
| 195 | 195 | // Returns a string that is the result of decoding the input string. The input string may |
| 196 | 196 | // consist of mixed case hexadecimal digits. Any characters that are not hexadecimal digits will |
| ... | ... | @@ -202,7 +202,7 @@ namespace QUtil |
| 202 | 202 | // Decode a single hex digit into a char in the range 0 <= char < 16. Return a char >= 16 if |
| 203 | 203 | // digit is not a valid hex digit. |
| 204 | 204 | QPDF_DLL |
| 205 | - inline constexpr char hex_decode_char(char digit) noexcept; | |
| 205 | + char hex_decode_char(char digit); | |
| 206 | 206 | |
| 207 | 207 | // Set stdin, stdout to binary mode |
| 208 | 208 | QPDF_DLL |
| ... | ... | @@ -431,16 +431,16 @@ namespace QUtil |
| 431 | 431 | // These routines help the tokenizer recognize certain character classes without using ctype, |
| 432 | 432 | // which we avoid because of locale considerations. |
| 433 | 433 | QPDF_DLL |
| 434 | - inline bool is_hex_digit(char); | |
| 434 | + bool is_hex_digit(char); | |
| 435 | 435 | |
| 436 | 436 | QPDF_DLL |
| 437 | - inline bool is_space(char); | |
| 437 | + bool is_space(char); | |
| 438 | 438 | |
| 439 | 439 | QPDF_DLL |
| 440 | - inline bool is_digit(char); | |
| 440 | + bool is_digit(char); | |
| 441 | 441 | |
| 442 | 442 | QPDF_DLL |
| 443 | - inline bool is_number(char const*); | |
| 443 | + bool is_number(char const*); | |
| 444 | 444 | |
| 445 | 445 | // This method parses the numeric range syntax used by the qpdf command-line tool. May throw |
| 446 | 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 | 489 | size_t get_max_memory_usage(); |
| 490 | 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 | 492 | #endif // QUTIL_HH | ... | ... |
libqpdf/FileInputSource.cc
libqpdf/JSON.cc
| ... | ... | @@ -8,9 +8,13 @@ |
| 8 | 8 | #include <qpdf/Pl_String.hh> |
| 9 | 9 | #include <qpdf/QTC.hh> |
| 10 | 10 | #include <qpdf/QUtil.hh> |
| 11 | +#include <qpdf/Util.hh> | |
| 12 | + | |
| 11 | 13 | #include <cstring> |
| 12 | 14 | #include <stdexcept> |
| 13 | 15 | |
| 16 | +using namespace qpdf; | |
| 17 | + | |
| 14 | 18 | JSON::Members::Members(std::unique_ptr<JSON_value> value) : |
| 15 | 19 | value(std::move(value)) |
| 16 | 20 | { |
| ... | ... | @@ -761,7 +765,7 @@ JSONParser::tokenError() |
| 761 | 765 | QTC::TC("libtests", "JSON parse unexpected sign"); |
| 762 | 766 | throw std::runtime_error( |
| 763 | 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 | 769 | QTC::TC("libtests", "JSON parse incomplete number"); |
| 766 | 770 | throw std::runtime_error( |
| 767 | 771 | "JSON: offset " + std::to_string(offset) + ": numeric literal: incomplete number"); |
| ... | ... | @@ -1078,7 +1082,7 @@ JSONParser::getToken() |
| 1078 | 1082 | |
| 1079 | 1083 | case ls_u4: |
| 1080 | 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 | 1086 | u_value = 16 * u_value + val; |
| 1083 | 1087 | } else { |
| 1084 | 1088 | tokenError(); | ... | ... |
libqpdf/PDFVersion.cc
libqpdf/Pl_Base64.cc
| ... | ... | @@ -2,9 +2,13 @@ |
| 2 | 2 | |
| 3 | 3 | #include <qpdf/QIntC.hh> |
| 4 | 4 | #include <qpdf/QUtil.hh> |
| 5 | +#include <qpdf/Util.hh> | |
| 6 | + | |
| 5 | 7 | #include <cstring> |
| 6 | 8 | #include <stdexcept> |
| 7 | 9 | |
| 10 | +using namespace qpdf; | |
| 11 | + | |
| 8 | 12 | static char |
| 9 | 13 | to_c(unsigned int ch) |
| 10 | 14 | { |
| ... | ... | @@ -50,7 +54,7 @@ Pl_Base64::decode(unsigned char const* data, size_t len) |
| 50 | 54 | { |
| 51 | 55 | unsigned char const* p = data; |
| 52 | 56 | while (len > 0) { |
| 53 | - if (!QUtil::is_space(to_c(*p))) { | |
| 57 | + if (!util::is_space(to_c(*p))) { | |
| 54 | 58 | this->buf[this->pos++] = *p; |
| 55 | 59 | if (this->pos == 4) { |
| 56 | 60 | flush(); | ... | ... |
libqpdf/Pl_Buffer.cc
| ... | ... | @@ -5,16 +5,24 @@ |
| 5 | 5 | #include <cstring> |
| 6 | 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 | 18 | Pl_Buffer::Pl_Buffer(char const* identifier, Pipeline* next) : |
| 9 | 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 | 27 | void |
| 20 | 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 | } |
| 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 | 16 | void |
| 19 | 17 | Pl_Concatenate::write(unsigned char const* data, size_t len) | ... | ... |
libqpdf/Pl_Count.cc
| ... | ... | @@ -2,13 +2,21 @@ |
| 2 | 2 | |
| 3 | 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 | 17 | Pl_Count::Pl_Count(char const* identifier, Pipeline* next) : |
| 10 | 18 | Pipeline(identifier, next), |
| 11 | - m(new Members()) | |
| 19 | + m(std::make_unique<Members>()) | |
| 12 | 20 | { |
| 13 | 21 | if (!next) { |
| 14 | 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 | 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 | 103 | Pl_DCT::Pl_DCT(char const* identifier, Pipeline* next) : |
| 83 | 104 | Pipeline(identifier, next), |
| 84 | - m(new Members()) | |
| 105 | + m(std::make_unique<Members>()) | |
| 85 | 106 | { |
| 86 | 107 | if (!next) { |
| 87 | 108 | throw std::logic_error("Attempt to create Pl_DCT with nullptr as next"); |
| ... | ... | @@ -115,14 +136,13 @@ Pl_DCT::Pl_DCT( |
| 115 | 136 | J_COLOR_SPACE color_space, |
| 116 | 137 | CompressConfig* compress_callback) : |
| 117 | 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 | 147 | void |
| 128 | 148 | Pl_DCT::write(unsigned char const* data, size_t len) | ... | ... |
libqpdf/Pl_Discard.cc
| ... | ... | @@ -2,15 +2,16 @@ |
| 2 | 2 | |
| 3 | 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 | 8 | Pl_Discard::Pl_Discard() : |
| 6 | 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 | 16 | void |
| 16 | 17 | Pl_Discard::write(unsigned char const* buf, size_t len) | ... | ... |
libqpdf/Pl_Flate.cc
| ... | ... | @@ -68,17 +68,15 @@ Pl_Flate::Members::~Members() |
| 68 | 68 | Pl_Flate::Pl_Flate( |
| 69 | 69 | char const* identifier, Pipeline* next, action_e action, unsigned int out_bufsize_int) : |
| 70 | 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 | 73 | if (!next) { |
| 74 | 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 | 81 | unsigned long long |
| 84 | 82 | Pl_Flate::memory_limit() | ... | ... |
libqpdf/Pl_Function.cc
| ... | ... | @@ -2,20 +2,28 @@ |
| 2 | 2 | |
| 3 | 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 | 18 | Pl_Function::Pl_Function(char const* identifier, Pipeline* next, writer_t fn) : |
| 11 | 19 | Pipeline(identifier, next), |
| 12 | - m(new Members(fn)) | |
| 20 | + m(std::make_unique<Members>(fn)) | |
| 13 | 21 | { |
| 14 | 22 | } |
| 15 | 23 | |
| 16 | 24 | Pl_Function::Pl_Function(char const* identifier, Pipeline* next, writer_c_t fn, void* udata) : |
| 17 | 25 | Pipeline(identifier, next), |
| 18 | - m(new Members(nullptr)) | |
| 26 | + m(std::make_unique<Members>(nullptr)) | |
| 19 | 27 | { |
| 20 | 28 | m->fn = [identifier, fn, udata](unsigned char const* data, size_t len) { |
| 21 | 29 | int code = fn(data, len, udata); | ... | ... |
libqpdf/Pl_OStream.cc
| ... | ... | @@ -2,21 +2,27 @@ |
| 2 | 2 | |
| 3 | 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 | 18 | Pl_OStream::Pl_OStream(char const* identifier, std::ostream& os) : |
| 11 | 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 | 27 | void |
| 22 | 28 | Pl_OStream::write(unsigned char const* buf, size_t len) | ... | ... |
libqpdf/Pl_QPDFTokenizer.cc
| ... | ... | @@ -4,15 +4,22 @@ |
| 4 | 4 | #include <qpdf/QTC.hh> |
| 5 | 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 | 19 | Pl_QPDFTokenizer::Pl_QPDFTokenizer( |
| 13 | 20 | char const* identifier, QPDFObjectHandle::TokenFilter* filter, Pipeline* next) : |
| 14 | 21 | Pipeline(identifier, next), |
| 15 | - m(new Members) | |
| 22 | + m(std::make_unique<Members>()) | |
| 16 | 23 | { |
| 17 | 24 | m->filter = filter; |
| 18 | 25 | QPDFObjectHandle::TokenFilter::PipelineAccessor::setPipeline(m->filter, next); |
| ... | ... | @@ -20,10 +27,8 @@ Pl_QPDFTokenizer::Pl_QPDFTokenizer( |
| 20 | 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 | 33 | void |
| 29 | 34 | Pl_QPDFTokenizer::write(unsigned char const* data, size_t len) | ... | ... |
libqpdf/Pl_RunLength.cc
| ... | ... | @@ -8,14 +8,26 @@ namespace |
| 8 | 8 | unsigned long long memory_limit{0}; |
| 9 | 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 | 28 | Pl_RunLength::Pl_RunLength(char const* identifier, Pipeline* next, action_e action) : |
| 17 | 29 | Pipeline(identifier, next), |
| 18 | - m(new Members(action)) | |
| 30 | + m(std::make_unique<Members>(action)) | |
| 19 | 31 | { |
| 20 | 32 | if (!next) { |
| 21 | 33 | throw std::logic_error("Attempt to create Pl_RunLength with nullptr as next"); | ... | ... |
libqpdf/Pl_StdioFile.cc
| ... | ... | @@ -6,21 +6,27 @@ |
| 6 | 6 | #include <cerrno> |
| 7 | 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 | 22 | Pl_StdioFile::Pl_StdioFile(char const* identifier, FILE* f) : |
| 15 | 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 | 31 | void |
| 26 | 32 | Pl_StdioFile::write(unsigned char const* buf, size_t len) | ... | ... |
libqpdf/Pl_String.cc
| ... | ... | @@ -2,21 +2,27 @@ |
| 2 | 2 | |
| 3 | 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 | 18 | Pl_String::Pl_String(char const* identifier, Pipeline* next, std::string& s) : |
| 11 | 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 | 27 | void |
| 22 | 28 | Pl_String::write(unsigned char const* buf, size_t len) | ... | ... |
libqpdf/QPDF.cc
| ... | ... | @@ -22,6 +22,9 @@ |
| 22 | 22 | #include <qpdf/QPDFParser.hh> |
| 23 | 23 | #include <qpdf/QTC.hh> |
| 24 | 24 | #include <qpdf/QUtil.hh> |
| 25 | +#include <qpdf/Util.hh> | |
| 26 | + | |
| 27 | +using namespace qpdf; | |
| 25 | 28 | |
| 26 | 29 | // This must be a fixed value. This API returns a const reference to it, and the C API relies on its |
| 27 | 30 | // being static as well. |
| ... | ... | @@ -200,7 +203,7 @@ QPDF::Members::Members() : |
| 200 | 203 | } |
| 201 | 204 | |
| 202 | 205 | QPDF::QPDF() : |
| 203 | - m(new Members()) | |
| 206 | + m(std::make_unique<Members>()) | |
| 204 | 207 | { |
| 205 | 208 | m->tokenizer.allowEOF(); |
| 206 | 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 | 371 | bool |
| 369 | 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 | 375 | if (valid) { |
| 373 | - while (QUtil::is_digit(*p)) { | |
| 376 | + while (util::is_digit(*p)) { | |
| 374 | 377 | version.append(1, *p++); |
| 375 | 378 | } |
| 376 | - if ((*p == '.') && QUtil::is_digit(*(p + 1))) { | |
| 379 | + if ((*p == '.') && util::is_digit(*(p + 1))) { | |
| 377 | 380 | version.append(1, *p++); |
| 378 | - while (QUtil::is_digit(*p)) { | |
| 381 | + while (util::is_digit(*p)) { | |
| 379 | 382 | version.append(1, *p++); |
| 380 | 383 | } |
| 381 | 384 | } else { |
| ... | ... | @@ -709,7 +712,7 @@ QPDF::read_xref(qpdf_offset_t xref_offset) |
| 709 | 712 | while (!done) { |
| 710 | 713 | char ch; |
| 711 | 714 | if (1 == m->file->read(&ch, 1)) { |
| 712 | - if (QUtil::is_space(ch)) { | |
| 715 | + if (util::is_space(ch)) { | |
| 713 | 716 | skipped_space = true; |
| 714 | 717 | } else { |
| 715 | 718 | m->file->unreadCh(ch); |
| ... | ... | @@ -724,7 +727,7 @@ QPDF::read_xref(qpdf_offset_t xref_offset) |
| 724 | 727 | m->file->read(buf, sizeof(buf) - 1); |
| 725 | 728 | // The PDF spec says xref must be followed by a line terminator, but files exist in the wild |
| 726 | 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 | 731 | if (skipped_space) { |
| 729 | 732 | QTC::TC("qpdf", "QPDF xref skipped space"); |
| 730 | 733 | warn(damagedPDF("", 0, "extraneous whitespace seen before xref")); |
| ... | ... | @@ -737,8 +740,8 @@ QPDF::read_xref(qpdf_offset_t xref_offset) |
| 737 | 740 | : (buf[4] == ' ') ? 2 |
| 738 | 741 | : 9999)); |
| 739 | 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 | 745 | ++skip; |
| 743 | 746 | } |
| 744 | 747 | xref_offset = read_xrefTable(xref_offset + skip); |
| ... | ... | @@ -795,37 +798,37 @@ QPDF::parse_xrefFirst(std::string const& line, int& obj, int& num, int& bytes) |
| 795 | 798 | char const* start = line.c_str(); |
| 796 | 799 | |
| 797 | 800 | // Skip zero or more spaces |
| 798 | - while (QUtil::is_space(*p)) { | |
| 801 | + while (util::is_space(*p)) { | |
| 799 | 802 | ++p; |
| 800 | 803 | } |
| 801 | 804 | // Require digit |
| 802 | - if (!QUtil::is_digit(*p)) { | |
| 805 | + if (!util::is_digit(*p)) { | |
| 803 | 806 | return false; |
| 804 | 807 | } |
| 805 | 808 | // Gather digits |
| 806 | 809 | std::string obj_str; |
| 807 | - while (QUtil::is_digit(*p)) { | |
| 810 | + while (util::is_digit(*p)) { | |
| 808 | 811 | obj_str.append(1, *p++); |
| 809 | 812 | } |
| 810 | 813 | // Require space |
| 811 | - if (!QUtil::is_space(*p)) { | |
| 814 | + if (!util::is_space(*p)) { | |
| 812 | 815 | return false; |
| 813 | 816 | } |
| 814 | 817 | // Skip spaces |
| 815 | - while (QUtil::is_space(*p)) { | |
| 818 | + while (util::is_space(*p)) { | |
| 816 | 819 | ++p; |
| 817 | 820 | } |
| 818 | 821 | // Require digit |
| 819 | - if (!QUtil::is_digit(*p)) { | |
| 822 | + if (!util::is_digit(*p)) { | |
| 820 | 823 | return false; |
| 821 | 824 | } |
| 822 | 825 | // Gather digits |
| 823 | 826 | std::string num_str; |
| 824 | - while (QUtil::is_digit(*p)) { | |
| 827 | + while (util::is_digit(*p)) { | |
| 825 | 828 | num_str.append(1, *p++); |
| 826 | 829 | } |
| 827 | 830 | // Skip any space including line terminators |
| 828 | - while (QUtil::is_space(*p)) { | |
| 831 | + while (util::is_space(*p)) { | |
| 829 | 832 | ++p; |
| 830 | 833 | } |
| 831 | 834 | bytes = toI(p - start); |
| ... | ... | @@ -847,51 +850,51 @@ QPDF::read_bad_xrefEntry(qpdf_offset_t& f1, int& f2, char& type) |
| 847 | 850 | |
| 848 | 851 | // Skip zero or more spaces. There aren't supposed to be any. |
| 849 | 852 | bool invalid = false; |
| 850 | - while (QUtil::is_space(*p)) { | |
| 853 | + while (util::is_space(*p)) { | |
| 851 | 854 | ++p; |
| 852 | 855 | QTC::TC("qpdf", "QPDF ignore first space in xref entry"); |
| 853 | 856 | invalid = true; |
| 854 | 857 | } |
| 855 | 858 | // Require digit |
| 856 | - if (!QUtil::is_digit(*p)) { | |
| 859 | + if (!util::is_digit(*p)) { | |
| 857 | 860 | return false; |
| 858 | 861 | } |
| 859 | 862 | // Gather digits |
| 860 | 863 | std::string f1_str; |
| 861 | - while (QUtil::is_digit(*p)) { | |
| 864 | + while (util::is_digit(*p)) { | |
| 862 | 865 | f1_str.append(1, *p++); |
| 863 | 866 | } |
| 864 | 867 | // Require space |
| 865 | - if (!QUtil::is_space(*p)) { | |
| 868 | + if (!util::is_space(*p)) { | |
| 866 | 869 | return false; |
| 867 | 870 | } |
| 868 | - if (QUtil::is_space(*(p + 1))) { | |
| 871 | + if (util::is_space(*(p + 1))) { | |
| 869 | 872 | QTC::TC("qpdf", "QPDF ignore first extra space in xref entry"); |
| 870 | 873 | invalid = true; |
| 871 | 874 | } |
| 872 | 875 | // Skip spaces |
| 873 | - while (QUtil::is_space(*p)) { | |
| 876 | + while (util::is_space(*p)) { | |
| 874 | 877 | ++p; |
| 875 | 878 | } |
| 876 | 879 | // Require digit |
| 877 | - if (!QUtil::is_digit(*p)) { | |
| 880 | + if (!util::is_digit(*p)) { | |
| 878 | 881 | return false; |
| 879 | 882 | } |
| 880 | 883 | // Gather digits |
| 881 | 884 | std::string f2_str; |
| 882 | - while (QUtil::is_digit(*p)) { | |
| 885 | + while (util::is_digit(*p)) { | |
| 883 | 886 | f2_str.append(1, *p++); |
| 884 | 887 | } |
| 885 | 888 | // Require space |
| 886 | - if (!QUtil::is_space(*p)) { | |
| 889 | + if (!util::is_space(*p)) { | |
| 887 | 890 | return false; |
| 888 | 891 | } |
| 889 | - if (QUtil::is_space(*(p + 1))) { | |
| 892 | + if (util::is_space(*(p + 1))) { | |
| 890 | 893 | QTC::TC("qpdf", "QPDF ignore second extra space in xref entry"); |
| 891 | 894 | invalid = true; |
| 892 | 895 | } |
| 893 | 896 | // Skip spaces |
| 894 | - while (QUtil::is_space(*p)) { | |
| 897 | + while (util::is_space(*p)) { | |
| 895 | 898 | ++p; |
| 896 | 899 | } |
| 897 | 900 | if ((*p == 'f') || (*p == 'n')) { |
| ... | ... | @@ -938,12 +941,12 @@ QPDF::read_xrefEntry(qpdf_offset_t& f1, int& f2, char& type) |
| 938 | 941 | ++f1_len; |
| 939 | 942 | ++p; |
| 940 | 943 | } |
| 941 | - while (QUtil::is_digit(*p) && f1_len++ < 10) { | |
| 944 | + while (util::is_digit(*p) && f1_len++ < 10) { | |
| 942 | 945 | f1 *= 10; |
| 943 | 946 | f1 += *p++ - '0'; |
| 944 | 947 | } |
| 945 | 948 | // Require space |
| 946 | - if (!QUtil::is_space(*p++)) { | |
| 949 | + if (!util::is_space(*p++)) { | |
| 947 | 950 | // Entry doesn't start with space or digit. |
| 948 | 951 | // C++20: [[unlikely]] |
| 949 | 952 | return false; |
| ... | ... | @@ -953,11 +956,11 @@ QPDF::read_xrefEntry(qpdf_offset_t& f1, int& f2, char& type) |
| 953 | 956 | ++f2_len; |
| 954 | 957 | ++p; |
| 955 | 958 | } |
| 956 | - while (QUtil::is_digit(*p) && f2_len++ < 5) { | |
| 959 | + while (util::is_digit(*p) && f2_len++ < 5) { | |
| 957 | 960 | f2 *= 10; |
| 958 | 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 | 964 | // C++20: [[likely]] |
| 962 | 965 | type = *p; |
| 963 | 966 | // No test for valid line[19]. |
| ... | ... | @@ -1602,7 +1605,7 @@ QPDF::validateStreamLineEnd(QPDFObjectHandle& object, QPDFObjGen og, qpdf_offset |
| 1602 | 1605 | } |
| 1603 | 1606 | return; |
| 1604 | 1607 | } |
| 1605 | - if (!QUtil::is_space(ch)) { | |
| 1608 | + if (!util::is_space(ch)) { | |
| 1606 | 1609 | QTC::TC("qpdf", "QPDF stream without newline"); |
| 1607 | 1610 | m->file->unreadCh(ch); |
| 1608 | 1611 | warn(damagedPDF( | ... | ... |
libqpdf/QPDFArgParser.cc
| ... | ... | @@ -5,10 +5,13 @@ |
| 5 | 5 | #include <qpdf/QPDFUsage.hh> |
| 6 | 6 | #include <qpdf/QTC.hh> |
| 7 | 7 | #include <qpdf/QUtil.hh> |
| 8 | +#include <qpdf/Util.hh> | |
| 9 | + | |
| 8 | 10 | #include <cstdlib> |
| 9 | 11 | #include <cstring> |
| 10 | 12 | #include <iostream> |
| 11 | 13 | |
| 14 | +using namespace qpdf; | |
| 12 | 15 | using namespace std::literals; |
| 13 | 16 | |
| 14 | 17 | QPDFArgParser::Members::Members(int argc, char const* const argv[], char const* progname_env) : |
| ... | ... | @@ -285,7 +288,7 @@ QPDFArgParser::handleBashArguments() |
| 285 | 288 | bool append = false; |
| 286 | 289 | switch (state) { |
| 287 | 290 | case st_top: |
| 288 | - if (QUtil::is_space(ch)) { | |
| 291 | + if (util::is_space(ch)) { | |
| 289 | 292 | if (!arg.empty()) { |
| 290 | 293 | m->bash_argv.push_back(QUtil::make_shared_cstr(arg)); |
| 291 | 294 | arg.clear(); | ... | ... |
libqpdf/QPDFJob.cc
| ... | ... | @@ -29,9 +29,12 @@ |
| 29 | 29 | #include <qpdf/QPDFWriter.hh> |
| 30 | 30 | #include <qpdf/QTC.hh> |
| 31 | 31 | #include <qpdf/QUtil.hh> |
| 32 | +#include <qpdf/Util.hh> | |
| 32 | 33 | |
| 33 | 34 | #include <qpdf/auto_job_schema.hh> // JOB_SCHEMA_DATA |
| 34 | 35 | |
| 36 | +using namespace qpdf; | |
| 37 | + | |
| 35 | 38 | namespace |
| 36 | 39 | { |
| 37 | 40 | class ImageOptimizer: public QPDFObjectHandle::StreamDataProvider |
| ... | ... | @@ -388,7 +391,7 @@ QPDFJob::parseRotationParameter(std::string const& parameter) |
| 388 | 391 | if ((first == '+') || (first == '-')) { |
| 389 | 392 | relative = ((first == '+') ? 1 : -1); |
| 390 | 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 | 395 | angle_str = ""; |
| 393 | 396 | } |
| 394 | 397 | } | ... | ... |
libqpdf/QPDFMatrix.cc
| ... | ... | @@ -138,3 +138,9 @@ QPDFMatrix::operator==(QPDFMatrix const& rhs) const |
| 138 | 138 | (this->a == rhs.a) && (this->b == rhs.b) && (this->c == rhs.c) && (this->d == rhs.d) && |
| 139 | 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 | 15 | #include <qpdf/QIntC.hh> |
| 16 | 16 | #include <qpdf/QTC.hh> |
| 17 | 17 | #include <qpdf/QUtil.hh> |
| 18 | +#include <qpdf/Util.hh> | |
| 18 | 19 | |
| 19 | 20 | #include <algorithm> |
| 20 | 21 | #include <array> |
| ... | ... | @@ -279,7 +280,7 @@ Name::normalize(std::string const& name) |
| 279 | 280 | } else if ( |
| 280 | 281 | ch < 33 || ch == '#' || ch == '/' || ch == '(' || ch == ')' || ch == '{' || ch == '}' || |
| 281 | 282 | ch == '<' || ch == '>' || ch == '[' || ch == ']' || ch == '%' || ch > 126) { |
| 282 | - result += QUtil::hex_encode_char(ch); | |
| 283 | + result += util::hex_encode_char(ch); | |
| 283 | 284 | } else { |
| 284 | 285 | result += ch; |
| 285 | 286 | } |
| ... | ... | @@ -2369,6 +2370,24 @@ QPDFObjectHandle::getObjGen() const |
| 2369 | 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 | 2391 | // Indirect object accessors |
| 2373 | 2392 | QPDF* |
| 2374 | 2393 | QPDFObjectHandle::getOwningQPDF() const | ... | ... |
libqpdf/QPDFObjectHelper.cc
| 1 | 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 | 8 | #include <qpdf/QPDFObjectHandle.hh> |
| 9 | 9 | #include <qpdf/QTC.hh> |
| 10 | 10 | #include <qpdf/QUtil.hh> |
| 11 | +#include <qpdf/Util.hh> | |
| 11 | 12 | |
| 12 | 13 | #include <cstdlib> |
| 13 | 14 | #include <cstring> |
| 14 | 15 | #include <stdexcept> |
| 15 | 16 | |
| 17 | +using namespace qpdf; | |
| 18 | + | |
| 16 | 19 | static inline bool |
| 17 | 20 | is_delimiter(char ch) |
| 18 | 21 | { |
| ... | ... | @@ -123,7 +126,7 @@ QPDFTokenizer::includeIgnorable() |
| 123 | 126 | bool |
| 124 | 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 | 132 | bool |
| ... | ... | @@ -440,7 +443,7 @@ QPDFTokenizer::inNameHex1(char ch) |
| 440 | 443 | { |
| 441 | 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 | 447 | this->char_code = int(hval) << 4; |
| 445 | 448 | this->state = st_name_hex2; |
| 446 | 449 | } else { |
| ... | ... | @@ -456,7 +459,7 @@ QPDFTokenizer::inNameHex1(char ch) |
| 456 | 459 | void |
| 457 | 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 | 463 | this->char_code |= int(hval); |
| 461 | 464 | } else { |
| 462 | 465 | QTC::TC("qpdf", "QPDFTokenizer bad name 2"); |
| ... | ... | @@ -483,7 +486,7 @@ QPDFTokenizer::inNameHex2(char ch) |
| 483 | 486 | void |
| 484 | 487 | QPDFTokenizer::inSign(char ch) |
| 485 | 488 | { |
| 486 | - if (QUtil::is_digit(ch)) { | |
| 489 | + if (util::is_digit(ch)) { | |
| 487 | 490 | this->state = st_number; |
| 488 | 491 | } else if (ch == '.') { |
| 489 | 492 | this->state = st_decimal; |
| ... | ... | @@ -496,7 +499,7 @@ QPDFTokenizer::inSign(char ch) |
| 496 | 499 | void |
| 497 | 500 | QPDFTokenizer::inDecimal(char ch) |
| 498 | 501 | { |
| 499 | - if (QUtil::is_digit(ch)) { | |
| 502 | + if (util::is_digit(ch)) { | |
| 500 | 503 | this->state = st_real; |
| 501 | 504 | } else { |
| 502 | 505 | this->state = st_literal; |
| ... | ... | @@ -507,7 +510,7 @@ QPDFTokenizer::inDecimal(char ch) |
| 507 | 510 | void |
| 508 | 511 | QPDFTokenizer::inNumber(char ch) |
| 509 | 512 | { |
| 510 | - if (QUtil::is_digit(ch)) { | |
| 513 | + if (util::is_digit(ch)) { | |
| 511 | 514 | } else if (ch == '.') { |
| 512 | 515 | this->state = st_real; |
| 513 | 516 | } else if (isDelimiter(ch)) { |
| ... | ... | @@ -523,7 +526,7 @@ QPDFTokenizer::inNumber(char ch) |
| 523 | 526 | void |
| 524 | 527 | QPDFTokenizer::inReal(char ch) |
| 525 | 528 | { |
| 526 | - if (QUtil::is_digit(ch)) { | |
| 529 | + if (util::is_digit(ch)) { | |
| 527 | 530 | } else if (isDelimiter(ch)) { |
| 528 | 531 | this->type = tt_real; |
| 529 | 532 | this->state = st_token_ready; |
| ... | ... | @@ -645,7 +648,7 @@ QPDFTokenizer::inLiteral(char ch) |
| 645 | 648 | void |
| 646 | 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 | 652 | this->char_code = int(hval) << 4; |
| 650 | 653 | this->state = st_in_hexstring_2nd; |
| 651 | 654 | |
| ... | ... | @@ -667,7 +670,7 @@ QPDFTokenizer::inHexstring(char ch) |
| 667 | 670 | void |
| 668 | 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 | 674 | this->val += char(this->char_code) | hval; |
| 672 | 675 | this->state = st_in_hexstring; |
| 673 | 676 | ... | ... |
libqpdf/QPDF_json.cc
| ... | ... | @@ -9,9 +9,13 @@ |
| 9 | 9 | #include <qpdf/QPDFObject_private.hh> |
| 10 | 10 | #include <qpdf/QTC.hh> |
| 11 | 11 | #include <qpdf/QUtil.hh> |
| 12 | +#include <qpdf/Util.hh> | |
| 13 | + | |
| 12 | 14 | #include <algorithm> |
| 13 | 15 | #include <cstring> |
| 14 | 16 | |
| 17 | +using namespace qpdf; | |
| 18 | + | |
| 15 | 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& v, int& obj, int& gen) |
| 67 | 71 | char const* p = v.c_str(); |
| 68 | 72 | std::string o_str; |
| 69 | 73 | std::string g_str; |
| 70 | - if (!QUtil::is_digit(*p)) { | |
| 74 | + if (!util::is_digit(*p)) { | |
| 71 | 75 | return false; |
| 72 | 76 | } |
| 73 | - while (QUtil::is_digit(*p)) { | |
| 77 | + while (util::is_digit(*p)) { | |
| 74 | 78 | o_str.append(1, *p++); |
| 75 | 79 | } |
| 76 | 80 | if (*p != ' ') { |
| ... | ... | @@ -79,10 +83,10 @@ is_indirect_object(std::string const& v, int& obj, int& gen) |
| 79 | 83 | while (*p == ' ') { |
| 80 | 84 | ++p; |
| 81 | 85 | } |
| 82 | - if (!QUtil::is_digit(*p)) { | |
| 86 | + if (!util::is_digit(*p)) { | |
| 83 | 87 | return false; |
| 84 | 88 | } |
| 85 | - while (QUtil::is_digit(*p)) { | |
| 89 | + while (util::is_digit(*p)) { | |
| 86 | 90 | g_str.append(1, *p++); |
| 87 | 91 | } |
| 88 | 92 | if (*p != ' ') { |
| ... | ... | @@ -128,7 +132,7 @@ is_binary_string(std::string const& v, std::string& str) |
| 128 | 132 | str = v.substr(2); |
| 129 | 133 | int count = 0; |
| 130 | 134 | for (char c: str) { |
| 131 | - if (!QUtil::is_hex_digit(c)) { | |
| 135 | + if (!util::is_hex_digit(c)) { | |
| 132 | 136 | return false; |
| 133 | 137 | } |
| 134 | 138 | ++count; | ... | ... |
libqpdf/QPDF_linearization.cc
| ... | ... | @@ -12,11 +12,14 @@ |
| 12 | 12 | #include <qpdf/QPDFWriter_private.hh> |
| 13 | 13 | #include <qpdf/QTC.hh> |
| 14 | 14 | #include <qpdf/QUtil.hh> |
| 15 | +#include <qpdf/Util.hh> | |
| 15 | 16 | |
| 16 | 17 | #include <algorithm> |
| 17 | 18 | #include <cmath> |
| 18 | 19 | #include <cstring> |
| 19 | 20 | |
| 21 | +using namespace qpdf; | |
| 22 | + | |
| 20 | 23 | template <class T, class int_type> |
| 21 | 24 | static void |
| 22 | 25 | load_vector_int( |
| ... | ... | @@ -105,7 +108,7 @@ QPDF::isLinearized() |
| 105 | 108 | char* p = buf; |
| 106 | 109 | while (lindict_obj == -1) { |
| 107 | 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 | 112 | ++p; |
| 110 | 113 | } |
| 111 | 114 | if (p - buf == tbuf_size) { |
| ... | ... | @@ -114,7 +117,7 @@ QPDF::isLinearized() |
| 114 | 117 | // Seek to the digit. Then skip over digits for a potential |
| 115 | 118 | // next iteration. |
| 116 | 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 | 121 | ++p; |
| 119 | 122 | } |
| 120 | 123 | ... | ... |
libqpdf/QUtil.cc
| ... | ... | @@ -8,6 +8,7 @@ |
| 8 | 8 | #include <qpdf/QIntC.hh> |
| 9 | 9 | #include <qpdf/QPDFSystemError.hh> |
| 10 | 10 | #include <qpdf/QTC.hh> |
| 11 | +#include <qpdf/Util.hh> | |
| 11 | 12 | |
| 12 | 13 | #include <cerrno> |
| 13 | 14 | #include <cstdlib> |
| ... | ... | @@ -37,6 +38,8 @@ |
| 37 | 38 | # include <malloc.h> |
| 38 | 39 | #endif |
| 39 | 40 | |
| 41 | +using namespace qpdf; | |
| 42 | + | |
| 40 | 43 | // First element is 24 |
| 41 | 44 | static unsigned short pdf_doc_low_to_unicode[] = { |
| 42 | 45 | 0x02d8, // 0x18 BREVE |
| ... | ... | @@ -396,7 +399,7 @@ unsigned long long |
| 396 | 399 | QUtil::string_to_ull(char const* str) |
| 397 | 400 | { |
| 398 | 401 | char const* p = str; |
| 399 | - while (*p && is_space(*p)) { | |
| 402 | + while (*p && util::is_space(*p)) { | |
| 400 | 403 | ++p; |
| 401 | 404 | } |
| 402 | 405 | if (*p == '-') { |
| ... | ... | @@ -739,7 +742,7 @@ QUtil::hex_decode(std::string const& input) |
| 739 | 742 | bool first = true; |
| 740 | 743 | char decoded; |
| 741 | 744 | for (auto ch: input) { |
| 742 | - ch = hex_decode_char(ch); | |
| 745 | + ch = util::hex_decode_char(ch); | |
| 743 | 746 | if (ch < '\20') { |
| 744 | 747 | if (first) { |
| 745 | 748 | decoded = static_cast<char>(ch << 4); |
| ... | ... | @@ -2002,3 +2005,63 @@ QUtil::get_max_memory_usage() |
| 2002 | 2005 | return 0; |
| 2003 | 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 | 108 | print_size(QPDFNameTreeObjectHelper::iterator); |
| 109 | 109 | print_size(QPDFNumberTreeObjectHelper); |
| 110 | 110 | print_size(QPDFNumberTreeObjectHelper::iterator); |
| 111 | - print_size(QPDFObjGen); | |
| 112 | 111 | print_size(QPDFObjectHandle); |
| 113 | 112 | print_size(QPDFObjectHandle::ParserCallbacks); |
| 114 | 113 | print_size(QPDFObjectHandle::QPDFArrayItems); |
| ... | ... | @@ -117,6 +116,7 @@ main() |
| 117 | 116 | print_size(QPDFObjectHandle::QPDFDictItems::iterator); |
| 118 | 117 | print_size(QPDFObjectHandle::StreamDataProvider); |
| 119 | 118 | print_size(QPDFObjectHandle::TokenFilter); |
| 119 | + print_size(QPDFObjectHelper); | |
| 120 | 120 | print_size(QPDFOutlineDocumentHelper); |
| 121 | 121 | print_size(QPDFOutlineObjectHelper); |
| 122 | 122 | print_size(QPDFPageDocumentHelper); | ... | ... |