aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/ClosedFileInputSource.cc2
-rw-r--r--libqpdf/InputSource.cc2
-rw-r--r--libqpdf/JSON.cc45
-rw-r--r--libqpdf/JSONHandler.cc65
-rw-r--r--libqpdf/NNTree.cc8
-rw-r--r--libqpdf/Pl_Buffer.cc2
-rw-r--r--libqpdf/Pl_Concatenate.cc2
-rw-r--r--libqpdf/Pl_Count.cc2
-rw-r--r--libqpdf/Pl_DCT.cc2
-rw-r--r--libqpdf/Pl_Discard.cc2
-rw-r--r--libqpdf/Pl_Flate.cc2
-rw-r--r--libqpdf/Pl_Function.cc2
-rw-r--r--libqpdf/Pl_OStream.cc2
-rw-r--r--libqpdf/Pl_QPDFTokenizer.cc2
-rw-r--r--libqpdf/Pl_RunLength.cc2
-rw-r--r--libqpdf/Pl_StdioFile.cc2
-rw-r--r--libqpdf/Pl_String.cc2
-rw-r--r--libqpdf/QPDF.cc28
-rw-r--r--libqpdf/QPDFAcroFormDocumentHelper.cc21
-rw-r--r--libqpdf/QPDFCrypto_openssl.cc2
-rw-r--r--libqpdf/QPDFDocumentHelper.cc2
-rw-r--r--libqpdf/QPDFFormFieldObjectHelper.cc30
-rw-r--r--libqpdf/QPDFJob.cc16
-rw-r--r--libqpdf/QPDFJob_argv.cc11
-rw-r--r--libqpdf/QPDFJob_config.cc2
-rw-r--r--libqpdf/QPDFJob_json.cc3
-rw-r--r--libqpdf/QPDFLogger.cc5
-rw-r--r--libqpdf/QPDFMatrix.cc6
-rw-r--r--libqpdf/QPDFNameTreeObjectHelper.cc15
-rw-r--r--libqpdf/QPDFNumberTreeObjectHelper.cc15
-rw-r--r--libqpdf/QPDFObjectHandle.cc98
-rw-r--r--libqpdf/QPDFObjectHelper.cc2
-rw-r--r--libqpdf/QPDFPageDocumentHelper.cc2
-rw-r--r--libqpdf/QPDFPageObjectHelper.cc27
-rw-r--r--libqpdf/QPDFParser.cc4
-rw-r--r--libqpdf/QPDFWriter.cc39
-rw-r--r--libqpdf/QPDFXRefEntry.cc2
-rw-r--r--libqpdf/QPDF_Array.cc2
-rw-r--r--libqpdf/QPDF_encryption.cc14
-rw-r--r--libqpdf/QPDF_json.cc2
-rw-r--r--libqpdf/QPDF_linearization.cc6
-rw-r--r--libqpdf/QUtil.cc11
-rw-r--r--libqpdf/qpdf-c.cc4
-rw-r--r--libqpdf/qpdf/JSONHandler.hh51
-rw-r--r--libqpdf/qpdf/Pl_LZWDecoder.hh6
-rw-r--r--libqpdf/qpdf/Pl_MD5.hh6
-rw-r--r--libqpdf/qpdf/QPDFArgParser.hh15
-rw-r--r--libqpdf/qpdf/QPDF_Array.hh10
-rw-r--r--libqpdf/qpdf/QPDF_Bool.hh8
-rw-r--r--libqpdf/qpdf/QPDF_Destroyed.hh8
-rw-r--r--libqpdf/qpdf/QPDF_Dictionary.hh10
-rw-r--r--libqpdf/qpdf/QPDF_InlineImage.hh12
-rw-r--r--libqpdf/qpdf/QPDF_Integer.hh8
-rw-r--r--libqpdf/qpdf/QPDF_Name.hh12
-rw-r--r--libqpdf/qpdf/QPDF_Null.hh8
-rw-r--r--libqpdf/qpdf/QPDF_Operator.hh12
-rw-r--r--libqpdf/qpdf/QPDF_Real.hh12
-rw-r--r--libqpdf/qpdf/QPDF_Reserved.hh8
-rw-r--r--libqpdf/qpdf/QPDF_Stream.hh14
-rw-r--r--libqpdf/qpdf/QPDF_String.hh12
-rw-r--r--libqpdf/qpdf/QPDF_Unresolved.hh8
-rw-r--r--libqpdf/qpdf/ResourceFinder.hh2
-rw-r--r--libqpdf/qpdf/SF_ASCII85Decode.hh2
-rw-r--r--libqpdf/qpdf/SF_ASCIIHexDecode.hh2
-rw-r--r--libqpdf/qpdf/SF_DCTDecode.hh2
-rw-r--r--libqpdf/qpdf/SF_FlateLzwDecode.hh6
-rw-r--r--libqpdf/qpdf/SF_RunLengthDecode.hh2
-rw-r--r--libqpdf/qpdf/SecureRandomDataProvider.hh4
68 files changed, 347 insertions, 408 deletions
diff --git a/libqpdf/ClosedFileInputSource.cc b/libqpdf/ClosedFileInputSource.cc
index 5e607a76..2a6cb897 100644
--- a/libqpdf/ClosedFileInputSource.cc
+++ b/libqpdf/ClosedFileInputSource.cc
@@ -9,7 +9,7 @@ ClosedFileInputSource::ClosedFileInputSource(char const* filename) :
{
}
-ClosedFileInputSource::~ClosedFileInputSource()
+ClosedFileInputSource::~ClosedFileInputSource() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
}
diff --git a/libqpdf/InputSource.cc b/libqpdf/InputSource.cc
index f5dc7706..9389c2f5 100644
--- a/libqpdf/InputSource.cc
+++ b/libqpdf/InputSource.cc
@@ -37,7 +37,7 @@ InputSource::readLine(size_t max_line_length)
if (line_length < max_line_length) {
buf[line_length] = '\0';
}
- return std::string(buf);
+ return {buf};
}
bool
diff --git a/libqpdf/JSON.cc b/libqpdf/JSON.cc
index a11d06f2..f6401642 100644
--- a/libqpdf/JSON.cc
+++ b/libqpdf/JSON.cc
@@ -269,7 +269,7 @@ JSON::encode_string(std::string const& str)
JSON
JSON::makeDictionary()
{
- return JSON(std::make_unique<JSON_dictionary>());
+ return {std::make_unique<JSON_dictionary>()};
}
JSON
@@ -299,7 +299,7 @@ JSON::checkDictionaryKeySeen(std::string const& key)
JSON
JSON::makeArray()
{
- return JSON(std::make_unique<JSON_array>());
+ return {std::make_unique<JSON_array>()};
}
JSON
@@ -320,43 +320,43 @@ JSON::addArrayElement(JSON const& val)
JSON
JSON::makeString(std::string const& utf8)
{
- return JSON(std::make_unique<JSON_string>(utf8));
+ return {std::make_unique<JSON_string>(utf8)};
}
JSON
JSON::makeInt(long long int value)
{
- return JSON(std::make_unique<JSON_number>(value));
+ return {std::make_unique<JSON_number>(value)};
}
JSON
JSON::makeReal(double value)
{
- return JSON(std::make_unique<JSON_number>(value));
+ return {std::make_unique<JSON_number>(value)};
}
JSON
JSON::makeNumber(std::string const& encoded)
{
- return JSON(std::make_unique<JSON_number>(encoded));
+ return {std::make_unique<JSON_number>(encoded)};
}
JSON
JSON::makeBool(bool value)
{
- return JSON(std::make_unique<JSON_bool>(value));
+ return {std::make_unique<JSON_bool>(value)};
}
JSON
JSON::makeNull()
{
- return JSON(std::make_unique<JSON_null>());
+ return {std::make_unique<JSON_null>()};
}
JSON
JSON::makeBlob(std::function<void(Pipeline*)> fn)
{
- return JSON(std::make_unique<JSON_blob>(fn));
+ return {std::make_unique<JSON_blob>(fn)};
}
bool
@@ -588,14 +588,7 @@ namespace
JSONParser(InputSource& is, JSON::Reactor* reactor) :
is(is),
reactor(reactor),
- lex_state(ls_top),
- bytes(0),
- p(buf),
- u_count(0),
- offset(0),
- done(false),
- parser_state(ps_top),
- dict_key_offset(0)
+ p(buf)
{
}
@@ -665,20 +658,20 @@ namespace
InputSource& is;
JSON::Reactor* reactor;
- lex_state_e lex_state;
+ lex_state_e lex_state{ls_top};
char buf[16384];
- size_t bytes;
+ size_t bytes{0};
char const* p;
- qpdf_offset_t u_count;
+ qpdf_offset_t u_count{0};
unsigned long u_value{0};
- qpdf_offset_t offset;
- bool done;
+ qpdf_offset_t offset{0};
+ bool done{false};
std::string token;
qpdf_offset_t token_start{0};
- parser_state_e parser_state;
+ parser_state_e parser_state{ps_top};
std::vector<StackFrame> stack;
std::string dict_key;
- qpdf_offset_t dict_key_offset;
+ qpdf_offset_t dict_key_offset{0};
};
} // namespace
@@ -1282,7 +1275,7 @@ JSONParser::handleToken()
case ps_top:
if (!(item.isDictionary() || item.isArray())) {
- stack.push_back({ps_done, item});
+ stack.emplace_back(ps_done, item);
parser_state = ps_done;
return;
}
@@ -1311,7 +1304,7 @@ JSONParser::handleToken()
}
if (item.isDictionary() || item.isArray()) {
- stack.push_back({parser_state, item});
+ stack.emplace_back(parser_state, item);
// Calling container start method is postponed until after adding the containers to their
// parent containers, if any. This makes it much easier to keep track of the current nesting
// level.
diff --git a/libqpdf/JSONHandler.cc b/libqpdf/JSONHandler.cc
index b5c7c35d..4a69fd60 100644
--- a/libqpdf/JSONHandler.cc
+++ b/libqpdf/JSONHandler.cc
@@ -4,11 +4,48 @@
#include <qpdf/QTC.hh>
#include <qpdf/QUtil.hh>
+struct Handlers
+{
+ Handlers() = default;
+
+ JSONHandler::json_handler_t any_handler{nullptr};
+ JSONHandler::void_handler_t null_handler{nullptr};
+ JSONHandler::string_handler_t string_handler{nullptr};
+ JSONHandler::string_handler_t number_handler{nullptr};
+ JSONHandler::bool_handler_t bool_handler{nullptr};
+ JSONHandler::json_handler_t dict_start_handler{nullptr};
+ JSONHandler::void_handler_t dict_end_handler{nullptr};
+ JSONHandler::json_handler_t array_start_handler{nullptr};
+ JSONHandler::void_handler_t array_end_handler{nullptr};
+ JSONHandler::void_handler_t final_handler{nullptr};
+ std::map<std::string, std::shared_ptr<JSONHandler>> dict_handlers;
+ std::shared_ptr<JSONHandler> fallback_dict_handler;
+ std::shared_ptr<JSONHandler> array_item_handler;
+};
+
+class JSONHandler::Members
+{
+ friend class JSONHandler;
+
+ public:
+ ~Members() = default;
+
+ private:
+ Members() = default;
+ Members(Members const&) = delete;
+
+ Handlers h;
+};
+
JSONHandler::JSONHandler() :
m(new Members())
{
}
+JSONHandler::~JSONHandler()
+{
+}
+
void
JSONHandler::usage(std::string const& msg)
{
@@ -80,24 +117,24 @@ JSONHandler::handle(std::string const& path, JSON j)
m->h.any_handler(path, j);
return;
}
- bool handled = false;
+
bool bvalue = false;
std::string s_value;
if (m->h.null_handler && j.isNull()) {
m->h.null_handler(path);
- handled = true;
+ return;
}
if (m->h.string_handler && j.getString(s_value)) {
m->h.string_handler(path, s_value);
- handled = true;
+ return;
}
if (m->h.number_handler && j.getNumber(s_value)) {
m->h.number_handler(path, s_value);
- handled = true;
+ return;
}
if (m->h.bool_handler && j.getBool(bvalue)) {
m->h.bool_handler(path, bvalue);
- handled = true;
+ return;
}
if (m->h.dict_start_handler && j.isDictionary()) {
m->h.dict_start_handler(path, j);
@@ -119,7 +156,7 @@ JSONHandler::handle(std::string const& path, JSON j)
}
});
m->h.dict_end_handler(path);
- handled = true;
+ return;
}
if (m->h.array_start_handler && j.isArray()) {
m->h.array_start_handler(path, j);
@@ -129,15 +166,13 @@ JSONHandler::handle(std::string const& path, JSON j)
++i;
});
m->h.array_end_handler(path);
- handled = true;
+ return;
}
- if (!handled) {
- // It would be nice to include information about what type the object was and what types
- // were allowed, but we're relying on schema validation to make sure input is properly
- // structured before calling the handlers. It would be different if this code were trying to
- // be part of a general-purpose JSON package.
- QTC::TC("libtests", "JSONHandler unhandled value");
- usage("JSON handler: value at " + path + " is not of expected type");
- }
+ // It would be nice to include information about what type the object was and what types were
+ // allowed, but we're relying on schema validation to make sure input is properly structured
+ // before calling the handlers. It would be different if this code were trying to be part of a
+ // general-purpose JSON package.
+ QTC::TC("libtests", "JSONHandler unhandled value");
+ usage("JSON handler: value at " + path + " is not of expected type");
}
diff --git a/libqpdf/NNTree.cc b/libqpdf/NNTree.cc
index a584ff8d..fa054794 100644
--- a/libqpdf/NNTree.cc
+++ b/libqpdf/NNTree.cc
@@ -319,7 +319,7 @@ NNTreeIterator::split(QPDFObjectHandle to_split, std::list<PathElement>::iterato
auto next = this->path.begin();
next->node = first_node;
}
- this->path.push_front(PathElement(to_split, 0));
+ this->path.emplace_front(to_split, 0);
parent = this->path.begin();
to_split = first_node;
}
@@ -578,7 +578,7 @@ NNTreeIterator::setItemNumber(QPDFObjectHandle const& node, int n)
void
NNTreeIterator::addPathElement(QPDFObjectHandle const& node, int kid_number)
{
- this->path.push_back(PathElement(node, kid_number));
+ this->path.emplace_back(node, kid_number);
}
bool
@@ -591,7 +591,7 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
bool failed = false;
QPDFObjGen::set seen;
- for (auto i: this->path) {
+ for (auto const& i: this->path) {
seen.add(i.node);
}
while (!failed) {
@@ -689,7 +689,7 @@ NNTreeImpl::begin()
NNTreeImpl::iterator
NNTreeImpl::end()
{
- return iterator(*this);
+ return {*this};
}
NNTreeImpl::iterator
diff --git a/libqpdf/Pl_Buffer.cc b/libqpdf/Pl_Buffer.cc
index c3184104..b10cf544 100644
--- a/libqpdf/Pl_Buffer.cc
+++ b/libqpdf/Pl_Buffer.cc
@@ -11,7 +11,7 @@ Pl_Buffer::Pl_Buffer(char const* identifier, Pipeline* next) :
{
}
-Pl_Buffer::~Pl_Buffer()
+Pl_Buffer::~Pl_Buffer() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
}
diff --git a/libqpdf/Pl_Concatenate.cc b/libqpdf/Pl_Concatenate.cc
index 8f974c05..82ec0bd4 100644
--- a/libqpdf/Pl_Concatenate.cc
+++ b/libqpdf/Pl_Concatenate.cc
@@ -5,7 +5,7 @@ Pl_Concatenate::Pl_Concatenate(char const* identifier, Pipeline* next) :
{
}
-Pl_Concatenate::~Pl_Concatenate()
+Pl_Concatenate::~Pl_Concatenate() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
}
diff --git a/libqpdf/Pl_Count.cc b/libqpdf/Pl_Count.cc
index 07bb2654..4a0d6cef 100644
--- a/libqpdf/Pl_Count.cc
+++ b/libqpdf/Pl_Count.cc
@@ -14,7 +14,7 @@ Pl_Count::Pl_Count(char const* identifier, Pipeline* next) :
{
}
-Pl_Count::~Pl_Count()
+Pl_Count::~Pl_Count() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
}
diff --git a/libqpdf/Pl_DCT.cc b/libqpdf/Pl_DCT.cc
index f82fc2aa..042d3977 100644
--- a/libqpdf/Pl_DCT.cc
+++ b/libqpdf/Pl_DCT.cc
@@ -75,7 +75,7 @@ Pl_DCT::Pl_DCT(
{
}
-Pl_DCT::~Pl_DCT()
+Pl_DCT::~Pl_DCT() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
}
diff --git a/libqpdf/Pl_Discard.cc b/libqpdf/Pl_Discard.cc
index d9ddaef3..643d3e4f 100644
--- a/libqpdf/Pl_Discard.cc
+++ b/libqpdf/Pl_Discard.cc
@@ -7,7 +7,7 @@ Pl_Discard::Pl_Discard() :
{
}
-Pl_Discard::~Pl_Discard()
+Pl_Discard::~Pl_Discard() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
}
diff --git a/libqpdf/Pl_Flate.cc b/libqpdf/Pl_Flate.cc
index f43c0b7f..d332e635 100644
--- a/libqpdf/Pl_Flate.cc
+++ b/libqpdf/Pl_Flate.cc
@@ -58,7 +58,7 @@ Pl_Flate::Pl_Flate(
{
}
-Pl_Flate::~Pl_Flate()
+Pl_Flate::~Pl_Flate() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
}
diff --git a/libqpdf/Pl_Function.cc b/libqpdf/Pl_Function.cc
index c75df2a4..00d7f5b0 100644
--- a/libqpdf/Pl_Function.cc
+++ b/libqpdf/Pl_Function.cc
@@ -39,7 +39,7 @@ Pl_Function::Pl_Function(char const* identifier, Pipeline* next, writer_c_char_t
};
}
-Pl_Function::~Pl_Function()
+Pl_Function::~Pl_Function() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
}
diff --git a/libqpdf/Pl_OStream.cc b/libqpdf/Pl_OStream.cc
index 73fbad21..9b1995a4 100644
--- a/libqpdf/Pl_OStream.cc
+++ b/libqpdf/Pl_OStream.cc
@@ -13,7 +13,7 @@ Pl_OStream::Pl_OStream(char const* identifier, std::ostream& os) :
{
}
-Pl_OStream::~Pl_OStream()
+Pl_OStream::~Pl_OStream() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
}
diff --git a/libqpdf/Pl_QPDFTokenizer.cc b/libqpdf/Pl_QPDFTokenizer.cc
index 576c2bfb..7bb86d5f 100644
--- a/libqpdf/Pl_QPDFTokenizer.cc
+++ b/libqpdf/Pl_QPDFTokenizer.cc
@@ -21,7 +21,7 @@ Pl_QPDFTokenizer::Pl_QPDFTokenizer(
m->tokenizer.includeIgnorable();
}
-Pl_QPDFTokenizer::~Pl_QPDFTokenizer()
+Pl_QPDFTokenizer::~Pl_QPDFTokenizer() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
}
diff --git a/libqpdf/Pl_RunLength.cc b/libqpdf/Pl_RunLength.cc
index d1a5e318..0d3bba2c 100644
--- a/libqpdf/Pl_RunLength.cc
+++ b/libqpdf/Pl_RunLength.cc
@@ -16,7 +16,7 @@ Pl_RunLength::Pl_RunLength(char const* identifier, Pipeline* next, action_e acti
{
}
-Pl_RunLength::~Pl_RunLength()
+Pl_RunLength::~Pl_RunLength() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
}
diff --git a/libqpdf/Pl_StdioFile.cc b/libqpdf/Pl_StdioFile.cc
index a95d4898..24e11244 100644
--- a/libqpdf/Pl_StdioFile.cc
+++ b/libqpdf/Pl_StdioFile.cc
@@ -17,7 +17,7 @@ Pl_StdioFile::Pl_StdioFile(char const* identifier, FILE* f) :
{
}
-Pl_StdioFile::~Pl_StdioFile()
+Pl_StdioFile::~Pl_StdioFile() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
}
diff --git a/libqpdf/Pl_String.cc b/libqpdf/Pl_String.cc
index 40c4b56f..9009268a 100644
--- a/libqpdf/Pl_String.cc
+++ b/libqpdf/Pl_String.cc
@@ -13,7 +13,7 @@ Pl_String::Pl_String(char const* identifier, Pipeline* next, std::string& s) :
{
}
-Pl_String::~Pl_String()
+Pl_String::~Pl_String() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
}
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index 6f718742..396dfe8f 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -840,7 +840,7 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset)
}
if (type == 'f') {
// Save deleted items until after we've checked the XRefStm, if any.
- deleted_items.push_back(QPDFObjGen(toI(i), f2));
+ deleted_items.emplace_back(toI(i), f2);
} else {
insertXrefEntry(toI(i), 1, f1, f2);
}
@@ -1343,21 +1343,16 @@ QPDF::readObject(
size_t length = 0;
try {
- std::map<std::string, QPDFObjectHandle> dict = object.getDictAsMap();
+ auto length_obj = object.getKey("/Length");
- if (dict.count("/Length") == 0) {
- QTC::TC("qpdf", "QPDF stream without length");
- throw damagedPDF(input, offset, "stream dictionary lacks /Length key");
- }
-
- QPDFObjectHandle length_obj = dict["/Length"];
if (!length_obj.isInteger()) {
+ if (length_obj.isNull()) {
+ QTC::TC("qpdf", "QPDF stream without length");
+ throw damagedPDF(input, offset, "stream dictionary lacks /Length key");
+ }
QTC::TC("qpdf", "QPDF stream length not integer");
throw damagedPDF(
- input,
- offset,
- "/Length key in stream dictionary is not "
- "an integer");
+ input, offset, "/Length key in stream dictionary is not an integer");
}
length = toS(length_obj.getUIntValue());
@@ -1487,7 +1482,8 @@ QPDF::readObjectAtOffset(
// Special case: if offset is 0, just return null. Some PDF writers, in particular
// "Mac OS X 10.7.5 Quartz PDFContext", may store deleted objects in the xref table as
- // "0000000000 00000 n", which is not correct, but it won't hurt anything for to ignore these.
+ // "0000000000 00000 n", which is not correct, but it won't hurt anything for us to ignore
+ // these.
if (offset == 0) {
QTC::TC("qpdf", "QPDF bogus 0 offset", 0);
warn(damagedPDF(0, "object has offset 0"));
@@ -2212,7 +2208,7 @@ QPDF::getVersionAsPDFVersion()
minor = QUtil::string_to_int(match[2].str().c_str());
}
- return PDFVersion(major, minor, extension_level);
+ return {major, minor, extension_level};
}
std::string
@@ -2483,7 +2479,7 @@ QPDF::damagedPDF(
qpdf_offset_t offset,
std::string const& message)
{
- return QPDFExc(qpdf_e_damaged_pdf, input->getName(), object, offset, message);
+ return {qpdf_e_damaged_pdf, input->getName(), object, offset, message};
}
// Return an exception of type qpdf_e_damaged_pdf. The object is taken from
@@ -2499,7 +2495,7 @@ QPDF::damagedPDF(
QPDFExc
QPDF::damagedPDF(std::string const& object, qpdf_offset_t offset, std::string const& message)
{
- return QPDFExc(qpdf_e_damaged_pdf, m->file->getName(), object, offset, message);
+ return {qpdf_e_damaged_pdf, m->file->getName(), object, offset, message};
}
// Return an exception of type qpdf_e_damaged_pdf. The filename is taken from m->file and the
diff --git a/libqpdf/QPDFAcroFormDocumentHelper.cc b/libqpdf/QPDFAcroFormDocumentHelper.cc
index aca4bf1f..5a54bf75 100644
--- a/libqpdf/QPDFAcroFormDocumentHelper.cc
+++ b/libqpdf/QPDFAcroFormDocumentHelper.cc
@@ -70,7 +70,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(std::vector<QPDFObjectHandle>
if (seen.add(obj)) {
auto kids = obj.getKey("/Kids");
if (kids.isArray()) {
- for (auto kid: kids.aitems()) {
+ for (auto const& kid: kids.aitems()) {
queue.push_back(kid);
}
}
@@ -104,7 +104,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(std::vector<QPDFObjectHandle>
}
}
- for (auto i: fields) {
+ for (auto const& i: fields) {
addFormField(i);
}
}
@@ -165,7 +165,7 @@ QPDFAcroFormDocumentHelper::getFormFields()
analyze();
std::vector<QPDFFormFieldObjectHelper> result;
for (auto const& iter: m->field_to_annotations) {
- result.push_back(this->qpdf.getObject(iter.first));
+ result.emplace_back(this->qpdf.getObject(iter.first));
}
return result;
}
@@ -279,7 +279,7 @@ QPDFAcroFormDocumentHelper::analyze()
annot.warnIfPossible("this widget annotation is not"
" reachable from /AcroForm in the document catalog");
m->annotation_to_field[og] = QPDFFormFieldObjectHelper(annot);
- m->field_to_annotations[og].push_back(QPDFAnnotationObjectHelper(annot));
+ m->field_to_annotations[og].emplace_back(annot);
}
}
}
@@ -342,7 +342,7 @@ QPDFAcroFormDocumentHelper::traverseField(
if (is_annotation) {
QPDFObjectHandle our_field = (is_field ? field : parent);
- m->field_to_annotations[our_field.getObjGen()].push_back(QPDFAnnotationObjectHelper(field));
+ m->field_to_annotations[our_field.getObjGen()].emplace_back(field);
m->annotation_to_field[og] = QPDFFormFieldObjectHelper(our_field);
}
@@ -469,19 +469,18 @@ namespace
ResourceReplacer(
std::map<std::string, std::map<std::string, std::string>> const& dr_map,
std::map<std::string, std::map<std::string, std::set<size_t>>> const& rnames);
- virtual ~ResourceReplacer() = default;
- virtual void handleToken(QPDFTokenizer::Token const&) override;
+ ~ResourceReplacer() override = default;
+ void handleToken(QPDFTokenizer::Token const&) override;
private:
- size_t offset;
+ size_t offset{0};
std::map<std::string, std::map<size_t, std::string>> to_replace;
};
} // namespace
ResourceReplacer::ResourceReplacer(
std::map<std::string, std::map<std::string, std::string>> const& dr_map,
- std::map<std::string, std::map<std::string, std::set<size_t>>> const& rnames) :
- offset(0)
+ std::map<std::string, std::map<std::string, std::set<size_t>>> const& rnames)
{
// We have:
// * dr_map[resource_type][key] == new_key
@@ -1019,7 +1018,7 @@ QPDFAcroFormDocumentHelper::fixCopiedAnnotations(
to_page.replaceKey("/Annots", QPDFObjectHandle::newArray(new_annots));
addAndRenameFormFields(new_fields);
if (added_fields) {
- for (auto f: new_fields) {
+ for (auto const& f: new_fields) {
added_fields->insert(f.getObjGen());
}
}
diff --git a/libqpdf/QPDFCrypto_openssl.cc b/libqpdf/QPDFCrypto_openssl.cc
index f82230be..92125b45 100644
--- a/libqpdf/QPDFCrypto_openssl.cc
+++ b/libqpdf/QPDFCrypto_openssl.cc
@@ -194,7 +194,7 @@ QPDFCrypto_openssl::MD5_digest(MD5_Digest d)
std::string
QPDFCrypto_openssl::SHA2_digest()
{
- return std::string(reinterpret_cast<char*>(md_out), sha2_bits / 8);
+ return {reinterpret_cast<char*>(md_out), sha2_bits / 8};
}
void
diff --git a/libqpdf/QPDFDocumentHelper.cc b/libqpdf/QPDFDocumentHelper.cc
index cdafc5fb..9bda5b52 100644
--- a/libqpdf/QPDFDocumentHelper.cc
+++ b/libqpdf/QPDFDocumentHelper.cc
@@ -1,6 +1,6 @@
#include <qpdf/QPDFDocumentHelper.hh>
-QPDFDocumentHelper::~QPDFDocumentHelper()
+QPDFDocumentHelper::~QPDFDocumentHelper() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
}
diff --git a/libqpdf/QPDFFormFieldObjectHelper.cc b/libqpdf/QPDFFormFieldObjectHelper.cc
index 67975451..4f7ca0e1 100644
--- a/libqpdf/QPDFFormFieldObjectHelper.cc
+++ b/libqpdf/QPDFFormFieldObjectHelper.cc
@@ -481,8 +481,8 @@ namespace
std::vector<std::string> opt;
double tf;
QPDFObjectHandle::Rectangle bbox;
- enum { st_top, st_bmc, st_emc, st_end } state;
- bool replaced;
+ enum { st_top, st_bmc, st_emc, st_end } state{st_top};
+ bool replaced{false};
};
} // namespace
@@ -496,9 +496,7 @@ ValueSetter::ValueSetter(
V(V),
opt(opt),
tf(tf),
- bbox(bbox),
- state(st_top),
- replaced(false)
+ bbox(bbox)
{
}
@@ -649,34 +647,24 @@ namespace
class TfFinder: public QPDFObjectHandle::TokenFilter
{
public:
- TfFinder();
- ~TfFinder() override
- {
- }
+ TfFinder() = default;
+ ~TfFinder() override = default;
void handleToken(QPDFTokenizer::Token const&) override;
double getTf();
std::string getFontName();
std::string getDA();
private:
- double tf;
- int tf_idx;
+ double tf{11.0};
+ int tf_idx{-1};
std::string font_name;
- double last_num;
- int last_num_idx;
+ double last_num{0.0};
+ int last_num_idx{-1};
std::string last_name;
std::vector<std::string> DA;
};
} // namespace
-TfFinder::TfFinder() :
- tf(11.0),
- tf_idx(-1),
- last_num(0.0),
- last_num_idx(-1)
-{
-}
-
void
TfFinder::handleToken(QPDFTokenizer::Token const& token)
{
diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc
index 4c7fdd04..3f3bcbb1 100644
--- a/libqpdf/QPDFJob.cc
+++ b/libqpdf/QPDFJob.cc
@@ -428,7 +428,7 @@ QPDFJob::parseNumrange(char const* range, int max)
} catch (std::runtime_error& e) {
usage(e.what());
}
- return std::vector<int>();
+ return {};
}
std::unique_ptr<QPDF>
@@ -894,7 +894,7 @@ QPDFJob::doListAttachments(QPDF& pdf)
v << " " << i2.first << " -> " << i2.second << "\n";
}
v << " all data streams:\n";
- for (auto i2: efoh->getEmbeddedFileStreams().ditems()) {
+ for (auto const& i2: efoh->getEmbeddedFileStreams().ditems()) {
auto efs = QPDFEFStreamObjectHelper(i2.second);
v << " " << i2.first << " -> "
<< efs.getObjectHandle().getObjGen().unparse(',') << "\n";
@@ -1329,7 +1329,7 @@ QPDFJob::doJSONAttachments(Pipeline* p, bool& first, QPDF& pdf)
j_names.addDictionaryMember(i2.first, JSON::makeString(i2.second));
}
auto j_streams = j_details.addDictionaryMember("streams", JSON::makeDictionary());
- for (auto i2: fsoh->getEmbeddedFileStreams().ditems()) {
+ for (auto const& i2: fsoh->getEmbeddedFileStreams().ditems()) {
auto efs = QPDFEFStreamObjectHelper(i2.second);
auto j_stream = j_streams.addDictionaryMember(i2.first, JSON::makeDictionary());
j_stream.addDictionaryMember(
@@ -2376,9 +2376,8 @@ QPDFJob::handlePageSpecs(QPDF& pdf, std::vector<std::unique_ptr<QPDF>>& page_hea
// Read original pages from the PDF, and parse the page range associated with this
// occurrence of the file.
- parsed_specs.push_back(
- // line-break
- QPDFPageData(page_spec.filename, page_spec_qpdfs[page_spec.filename], page_spec.range));
+ parsed_specs.emplace_back(
+ page_spec.filename, page_spec_qpdfs[page_spec.filename], page_spec.range);
}
std::map<unsigned long long, bool> remove_unreferenced;
@@ -2427,9 +2426,8 @@ QPDFJob::handlePageSpecs(QPDF& pdf, std::vector<std::unique_ptr<QPDF>>& page_hea
for (size_t j = 0; j < m->collate; ++j) {
if (cur_page + j < page_data.selected_pages.size()) {
got_pages = true;
- new_parsed_specs.push_back(
- // line-break
- QPDFPageData(page_data, page_data.selected_pages.at(cur_page + j)));
+ new_parsed_specs.emplace_back(
+ page_data, page_data.selected_pages.at(cur_page + j));
}
}
}
diff --git a/libqpdf/QPDFJob_argv.cc b/libqpdf/QPDFJob_argv.cc
index 4a9addbd..aade34cd 100644
--- a/libqpdf/QPDFJob_argv.cc
+++ b/libqpdf/QPDFJob_argv.cc
@@ -40,18 +40,15 @@ namespace
std::shared_ptr<QPDFJob::UOConfig> c_uo;
std::shared_ptr<QPDFJob::EncConfig> c_enc;
std::vector<std::string> accumulated_args;
- std::shared_ptr<char> pages_password;
- bool gave_input;
- bool gave_output;
+ std::shared_ptr<char> pages_password{nullptr};
+ bool gave_input{false};
+ bool gave_output{false};
};
} // namespace
ArgParser::ArgParser(QPDFArgParser& ap, std::shared_ptr<QPDFJob::Config> c_main) :
ap(ap),
- c_main(c_main),
- pages_password(nullptr),
- gave_input(false),
- gave_output(false)
+ c_main(c_main)
{
initOptionTables();
}
diff --git a/libqpdf/QPDFJob_config.cc b/libqpdf/QPDFJob_config.cc
index e847bcd4..834de9ab 100644
--- a/libqpdf/QPDFJob_config.cc
+++ b/libqpdf/QPDFJob_config.cc
@@ -942,7 +942,7 @@ QPDFJob::PagesConfig*
QPDFJob::PagesConfig::pageSpec(
std::string const& filename, std::string const& range, char const* password)
{
- this->config->o.m->page_specs.push_back(QPDFJob::PageSpec(filename, password, range));
+ this->config->o.m->page_specs.emplace_back(filename, password, range);
return this;
}
diff --git a/libqpdf/QPDFJob_json.cc b/libqpdf/QPDFJob_json.cc
index 92488df1..95622f36 100644
--- a/libqpdf/QPDFJob_json.cc
+++ b/libqpdf/QPDFJob_json.cc
@@ -59,7 +59,7 @@ namespace
std::list<std::shared_ptr<JSONHandler>> json_handlers;
bool partial;
- JSONHandler* jh; // points to last of json_handlers
+ JSONHandler* jh{nullptr}; // points to last of json_handlers
std::shared_ptr<QPDFJob::Config> c_main;
std::shared_ptr<QPDFJob::CopyAttConfig> c_copy_att;
std::shared_ptr<QPDFJob::AttConfig> c_att;
@@ -71,7 +71,6 @@ namespace
Handlers::Handlers(bool partial, std::shared_ptr<QPDFJob::Config> c_main) :
partial(partial),
- jh(nullptr),
c_main(c_main)
{
initHandlers();
diff --git a/libqpdf/QPDFLogger.cc b/libqpdf/QPDFLogger.cc
index 76c3c70c..a704ea75 100644
--- a/libqpdf/QPDFLogger.cc
+++ b/libqpdf/QPDFLogger.cc
@@ -12,8 +12,7 @@ namespace
{
public:
Pl_Track(char const* identifier, Pipeline* next) :
- Pipeline(identifier, next),
- used(false)
+ Pipeline(identifier, next)
{
}
@@ -37,7 +36,7 @@ namespace
}
private:
- bool used;
+ bool used{false};
};
}; // namespace
diff --git a/libqpdf/QPDFMatrix.cc b/libqpdf/QPDFMatrix.cc
index a54b4370..f38d7644 100644
--- a/libqpdf/QPDFMatrix.cc
+++ b/libqpdf/QPDFMatrix.cc
@@ -57,7 +57,7 @@ QPDFMatrix::unparse() const
QPDFObjectHandle::Matrix
QPDFMatrix::getAsMatrix() const
{
- return QPDFObjectHandle::Matrix(a, b, c, d, e, f);
+ return {a, b, c, d, e, f};
}
void
@@ -124,11 +124,11 @@ QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r) const
transform(r.llx, r.ury, tx.at(1), ty.at(1));
transform(r.urx, r.lly, tx.at(2), ty.at(2));
transform(r.urx, r.ury, tx.at(3), ty.at(3));
- return QPDFObjectHandle::Rectangle(
+ return {
*std::min_element(tx.begin(), tx.end()),
*std::min_element(ty.begin(), ty.end()),
*std::max_element(tx.begin(), tx.end()),
- *std::max_element(ty.begin(), ty.end()));
+ *std::max_element(ty.begin(), ty.end())};
}
bool
diff --git a/libqpdf/QPDFNameTreeObjectHelper.cc b/libqpdf/QPDFNameTreeObjectHelper.cc
index 5a9992fb..9a2a6284 100644
--- a/libqpdf/QPDFNameTreeObjectHelper.cc
+++ b/libqpdf/QPDFNameTreeObjectHelper.cc
@@ -34,7 +34,7 @@ namespace
static NameTreeDetails name_tree_details;
-QPDFNameTreeObjectHelper::~QPDFNameTreeObjectHelper()
+QPDFNameTreeObjectHelper::~QPDFNameTreeObjectHelper() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer. For this specific
// class, see github issue #745.
@@ -54,8 +54,7 @@ QPDFNameTreeObjectHelper::QPDFNameTreeObjectHelper(QPDFObjectHandle oh, QPDF& q,
QPDFNameTreeObjectHelper
QPDFNameTreeObjectHelper::newEmpty(QPDF& qpdf, bool auto_repair)
{
- return QPDFNameTreeObjectHelper(
- qpdf.makeIndirectObject("<< /Names [] >>"_qpdf), qpdf, auto_repair);
+ return {qpdf.makeIndirectObject("<< /Names [] >>"_qpdf), qpdf, auto_repair};
}
QPDFNameTreeObjectHelper::iterator::iterator(std::shared_ptr<NNTreeIterator> const& i) :
@@ -135,33 +134,33 @@ QPDFNameTreeObjectHelper::iterator::remove()
QPDFNameTreeObjectHelper::iterator
QPDFNameTreeObjectHelper::begin() const
{
- return iterator(std::make_shared<NNTreeIterator>(m->impl->begin()));
+ return {std::make_shared<NNTreeIterator>(m->impl->begin())};
}
QPDFNameTreeObjectHelper::iterator
QPDFNameTreeObjectHelper::end() const
{
- return iterator(std::make_shared<NNTreeIterator>(m->impl->end()));
+ return {std::make_shared<NNTreeIterator>(m->impl->end())};
}
QPDFNameTreeObjectHelper::iterator
QPDFNameTreeObjectHelper::last() const
{
- return iterator(std::make_shared<NNTreeIterator>(m->impl->last()));
+ return {std::make_shared<NNTreeIterator>(m->impl->last())};
}
QPDFNameTreeObjectHelper::iterator
QPDFNameTreeObjectHelper::find(std::string const& key, bool return_prev_if_not_found)
{
auto i = m->impl->find(QPDFObjectHandle::newUnicodeString(key), return_prev_if_not_found);
- return iterator(std::make_shared<NNTreeIterator>(i));
+ return {std::make_shared<NNTreeIterator>(i)};
}
QPDFNameTreeObjectHelper::iterator
QPDFNameTreeObjectHelper::insert(std::string const& key, QPDFObjectHandle value)
{
auto i = m->impl->insert(QPDFObjectHandle::newUnicodeString(key), value);
- return iterator(std::make_shared<NNTreeIterator>(i));
+ return {std::make_shared<NNTreeIterator>(i)};
}
bool
diff --git a/libqpdf/QPDFNumberTreeObjectHelper.cc b/libqpdf/QPDFNumberTreeObjectHelper.cc
index 95cee9c8..478a1884 100644
--- a/libqpdf/QPDFNumberTreeObjectHelper.cc
+++ b/libqpdf/QPDFNumberTreeObjectHelper.cc
@@ -35,7 +35,7 @@ namespace
static NumberTreeDetails number_tree_details;
-QPDFNumberTreeObjectHelper::~QPDFNumberTreeObjectHelper()
+QPDFNumberTreeObjectHelper::~QPDFNumberTreeObjectHelper() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer. For this specific
// class, see github issue #745.
@@ -56,8 +56,7 @@ QPDFNumberTreeObjectHelper::QPDFNumberTreeObjectHelper(
QPDFNumberTreeObjectHelper
QPDFNumberTreeObjectHelper::newEmpty(QPDF& qpdf, bool auto_repair)
{
- return QPDFNumberTreeObjectHelper(
- qpdf.makeIndirectObject("<< /Nums [] >>"_qpdf), qpdf, auto_repair);
+ return {qpdf.makeIndirectObject("<< /Nums [] >>"_qpdf), qpdf, auto_repair};
}
QPDFNumberTreeObjectHelper::iterator::iterator(std::shared_ptr<NNTreeIterator> const& i) :
@@ -137,33 +136,33 @@ QPDFNumberTreeObjectHelper::iterator::remove()
QPDFNumberTreeObjectHelper::iterator
QPDFNumberTreeObjectHelper::begin() const
{
- return iterator(std::make_shared<NNTreeIterator>(m->impl->begin()));
+ return {std::make_shared<NNTreeIterator>(m->impl->begin())};
}
QPDFNumberTreeObjectHelper::iterator
QPDFNumberTreeObjectHelper::end() const
{
- return iterator(std::make_shared<NNTreeIterator>(m->impl->end()));
+ return {std::make_shared<NNTreeIterator>(m->impl->end())};
}
QPDFNumberTreeObjectHelper::iterator
QPDFNumberTreeObjectHelper::last() const
{
- return iterator(std::make_shared<NNTreeIterator>(m->impl->last()));
+ return {std::make_shared<NNTreeIterator>(m->impl->last())};
}
QPDFNumberTreeObjectHelper::iterator
QPDFNumberTreeObjectHelper::find(numtree_number key, bool return_prev_if_not_found)
{
auto i = m->impl->find(QPDFObjectHandle::newInteger(key), return_prev_if_not_found);
- return iterator(std::make_shared<NNTreeIterator>(i));
+ return {std::make_shared<NNTreeIterator>(i)};
}
QPDFNumberTreeObjectHelper::iterator
QPDFNumberTreeObjectHelper::insert(numtree_number key, QPDFObjectHandle value)
{
auto i = m->impl->insert(QPDFObjectHandle::newInteger(key), value);
- return iterator(std::make_shared<NNTreeIterator>(i));
+ return {std::make_shared<NNTreeIterator>(i)};
}
bool
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc
index 3797ad12..3ce748b0 100644
--- a/libqpdf/QPDFObjectHandle.cc
+++ b/libqpdf/QPDFObjectHandle.cc
@@ -49,7 +49,7 @@ QPDFObjectHandle::StreamDataProvider::StreamDataProvider(bool supports_retry) :
{
}
-QPDFObjectHandle::StreamDataProvider::~StreamDataProvider()
+QPDFObjectHandle::StreamDataProvider::~StreamDataProvider() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
}
@@ -189,13 +189,12 @@ namespace
unsigned char getLastChar();
private:
- unsigned char last_char;
+ unsigned char last_char{0};
};
} // namespace
LastChar::LastChar(Pipeline* next) :
- Pipeline("lastchar", next),
- last_char(0)
+ Pipeline("lastchar", next)
{
}
@@ -752,7 +751,7 @@ QPDFObjectHandle::getValueAsInlineImage(std::string& value)
QPDFObjectHandle::QPDFArrayItems
QPDFObjectHandle::aitems()
{
- return QPDFArrayItems(*this);
+ return *this;
}
int
@@ -826,11 +825,11 @@ QPDFObjectHandle::getArrayAsRectangle()
return {};
}
}
- return Rectangle(
+ return {
std::min(items[0], items[2]),
std::min(items[1], items[3]),
std::max(items[0], items[2]),
- std::max(items[1], items[3]));
+ std::max(items[1], items[3])};
}
return {};
}
@@ -848,7 +847,7 @@ QPDFObjectHandle::getArrayAsMatrix()
return {};
}
}
- return Matrix(items[0], items[1], items[2], items[3], items[4], items[5]);
+ return {items[0], items[1], items[2], items[3], items[4], items[5]};
}
return {};
}
@@ -959,7 +958,7 @@ QPDFObjectHandle::eraseItemAndGetOld(int at)
QPDFObjectHandle::QPDFDictItems
QPDFObjectHandle::ditems()
{
- return QPDFDictItems(*this);
+ return {*this};
}
bool
@@ -1049,7 +1048,7 @@ QPDFObjectHandle::makeResourcesIndirect(QPDF& owning_qpdf)
if (!sub.isDictionary()) {
continue;
}
- for (auto i2: sub.ditems()) {
+ for (auto const& i2: sub.ditems()) {
std::string const& key = i2.first;
QPDFObjectHandle val = i2.second;
if (!val.isIndirect()) {
@@ -1070,7 +1069,7 @@ QPDFObjectHandle::mergeResources(
auto make_og_to_name = [](QPDFObjectHandle& dict,
std::map<QPDFObjGen, std::string>& og_to_name) {
- for (auto i: dict.ditems()) {
+ for (auto const& i: dict.ditems()) {
if (i.second.isIndirect()) {
og_to_name[i.second.getObjGen()] = i.first;
}
@@ -1079,7 +1078,7 @@ QPDFObjectHandle::mergeResources(
// This algorithm is described in comments in QPDFObjectHandle.hh
// above the declaration of mergeResources.
- for (auto o_top: other.ditems()) {
+ for (auto const& o_top: other.ditems()) {
std::string const& rtype = o_top.first;
QPDFObjectHandle other_val = o_top.second;
if (hasKey(rtype)) {
@@ -1096,7 +1095,7 @@ QPDFObjectHandle::mergeResources(
std::set<std::string> rnames;
int min_suffix = 1;
bool initialized_maps = false;
- for (auto ov_iter: other_val.ditems()) {
+ for (auto const& ov_iter: other_val.ditems()) {
std::string const& key = ov_iter.first;
QPDFObjectHandle rval = ov_iter.second;
if (!this_val.hasKey(key)) {
@@ -1862,61 +1861,61 @@ QPDFObjectHandle::getParsedOffset()
QPDFObjectHandle
QPDFObjectHandle::newBool(bool value)
{
- return QPDFObjectHandle(QPDF_Bool::create(value));
+ return {QPDF_Bool::create(value)};
}
QPDFObjectHandle
QPDFObjectHandle::newNull()
{
- return QPDFObjectHandle(QPDF_Null::create());
+ return {QPDF_Null::create()};
}
QPDFObjectHandle
QPDFObjectHandle::newInteger(long long value)
{
- return QPDFObjectHandle(QPDF_Integer::create(value));
+ return {QPDF_Integer::create(value)};
}
QPDFObjectHandle
QPDFObjectHandle::newReal(std::string const& value)
{
- return QPDFObjectHandle(QPDF_Real::create(value));
+ return {QPDF_Real::create(value)};
}
QPDFObjectHandle
QPDFObjectHandle::newReal(double value, int decimal_places, bool trim_trailing_zeroes)
{
- return QPDFObjectHandle(QPDF_Real::create(value, decimal_places, trim_trailing_zeroes));
+ return {QPDF_Real::create(value, decimal_places, trim_trailing_zeroes)};
}
QPDFObjectHandle
QPDFObjectHandle::newName(std::string const& name)
{
- return QPDFObjectHandle(QPDF_Name::create(name));
+ return {QPDF_Name::create(name)};
}
QPDFObjectHandle
QPDFObjectHandle::newString(std::string const& str)
{
- return QPDFObjectHandle(QPDF_String::create(str));
+ return {QPDF_String::create(str)};
}
QPDFObjectHandle
QPDFObjectHandle::newUnicodeString(std::string const& utf8_str)
{
- return QPDFObjectHandle(QPDF_String::create_utf16(utf8_str));
+ return {QPDF_String::create_utf16(utf8_str)};
}
QPDFObjectHandle
QPDFObjectHandle::newOperator(std::string const& value)
{
- return QPDFObjectHandle(QPDF_Operator::create(value));
+ return {QPDF_Operator::create(value)};
}
QPDFObjectHandle
QPDFObjectHandle::newInlineImage(std::string const& value)
{
- return QPDFObjectHandle(QPDF_InlineImage::create(value));
+ return {QPDF_InlineImage::create(value)};
}
QPDFObjectHandle
@@ -1928,44 +1927,37 @@ QPDFObjectHandle::newArray()
QPDFObjectHandle
QPDFObjectHandle::newArray(std::vector<QPDFObjectHandle> const& items)
{
- return QPDFObjectHandle(QPDF_Array::create(items));
+ return {QPDF_Array::create(items)};
}
QPDFObjectHandle
QPDFObjectHandle::newArray(Rectangle const& rect)
{
- std::vector<QPDFObjectHandle> items;
- items.push_back(newReal(rect.llx));
- items.push_back(newReal(rect.lly));
- items.push_back(newReal(rect.urx));
- items.push_back(newReal(rect.ury));
- return newArray(items);
+ return newArray({newReal(rect.llx), newReal(rect.lly), newReal(rect.urx), newReal(rect.ury)});
}
QPDFObjectHandle
QPDFObjectHandle::newArray(Matrix const& matrix)
{
- std::vector<QPDFObjectHandle> items;
- items.push_back(newReal(matrix.a));
- items.push_back(newReal(matrix.b));
- items.push_back(newReal(matrix.c));
- items.push_back(newReal(matrix.d));
- items.push_back(newReal(matrix.e));
- items.push_back(newReal(matrix.f));
- return newArray(items);
+ return newArray(
+ {newReal(matrix.a),
+ newReal(matrix.b),
+ newReal(matrix.c),
+ newReal(matrix.d),
+ newReal(matrix.e),
+ newReal(matrix.f)});
}
QPDFObjectHandle
QPDFObjectHandle::newArray(QPDFMatrix const& matrix)
{
- std::vector<QPDFObjectHandle> items;
- items.push_back(newReal(matrix.a));
- items.push_back(newReal(matrix.b));
- items.push_back(newReal(matrix.c));
- items.push_back(newReal(matrix.d));
- items.push_back(newReal(matrix.e));
- items.push_back(newReal(matrix.f));
- return newArray(items);
+ return newArray(
+ {newReal(matrix.a),
+ newReal(matrix.b),
+ newReal(matrix.c),
+ newReal(matrix.d),
+ newReal(matrix.e),
+ newReal(matrix.f)});
}
QPDFObjectHandle
@@ -1995,7 +1987,7 @@ QPDFObjectHandle::newDictionary()
QPDFObjectHandle
QPDFObjectHandle::newDictionary(std::map<std::string, QPDFObjectHandle> const& items)
{
- return QPDFObjectHandle(QPDF_Dictionary::create(items));
+ return {QPDF_Dictionary::create(items)};
}
QPDFObjectHandle
@@ -2060,7 +2052,7 @@ QPDFObjectHandle::shallowCopy()
if (!dereference()) {
throw std::logic_error("operation attempted on uninitialized QPDFObjectHandle");
}
- return QPDFObjectHandle(obj->copy());
+ return {obj->copy()};
}
QPDFObjectHandle
@@ -2069,7 +2061,7 @@ QPDFObjectHandle::unsafeShallowCopy()
if (!dereference()) {
throw std::logic_error("operation attempted on uninitialized QPDFObjectHandle");
}
- return QPDFObjectHandle(obj->copy(true));
+ return {obj->copy(true)};
}
void
@@ -2471,13 +2463,13 @@ QPDFObjectHandle::QPDFDictItems::iterator::Members::Members(QPDFObjectHandle& oh
QPDFObjectHandle::QPDFDictItems::iterator
QPDFObjectHandle::QPDFDictItems::begin()
{
- return iterator(oh, true);
+ return {oh, true};
}
QPDFObjectHandle::QPDFDictItems::iterator
QPDFObjectHandle::QPDFDictItems::end()
{
- return iterator(oh, false);
+ return {oh, false};
}
QPDFObjectHandle::QPDFArrayItems::QPDFArrayItems(QPDFObjectHandle const& oh) :
@@ -2551,13 +2543,13 @@ QPDFObjectHandle::QPDFArrayItems::iterator::Members::Members(QPDFObjectHandle& o
QPDFObjectHandle::QPDFArrayItems::iterator
QPDFObjectHandle::QPDFArrayItems::begin()
{
- return iterator(oh, true);
+ return {oh, true};
}
QPDFObjectHandle::QPDFArrayItems::iterator
QPDFObjectHandle::QPDFArrayItems::end()
{
- return iterator(oh, false);
+ return {oh, false};
}
QPDFObjGen
diff --git a/libqpdf/QPDFObjectHelper.cc b/libqpdf/QPDFObjectHelper.cc
index eb7de06e..cbd54f3d 100644
--- a/libqpdf/QPDFObjectHelper.cc
+++ b/libqpdf/QPDFObjectHelper.cc
@@ -1,6 +1,6 @@
#include <qpdf/QPDFObjectHelper.hh>
-QPDFObjectHelper::~QPDFObjectHelper()
+QPDFObjectHelper::~QPDFObjectHelper() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
}
diff --git a/libqpdf/QPDFPageDocumentHelper.cc b/libqpdf/QPDFPageDocumentHelper.cc
index 3811d7dd..c9c2cf52 100644
--- a/libqpdf/QPDFPageDocumentHelper.cc
+++ b/libqpdf/QPDFPageDocumentHelper.cc
@@ -14,7 +14,7 @@ QPDFPageDocumentHelper::getAllPages()
{
std::vector<QPDFPageObjectHelper> pages;
for (auto const& iter: this->qpdf.getAllPages()) {
- pages.push_back(QPDFPageObjectHelper(iter));
+ pages.emplace_back(iter);
}
return pages;
}
diff --git a/libqpdf/QPDFPageObjectHelper.cc b/libqpdf/QPDFPageObjectHelper.cc
index 608254e4..fd6e5215 100644
--- a/libqpdf/QPDFPageObjectHelper.cc
+++ b/libqpdf/QPDFPageObjectHelper.cc
@@ -20,8 +20,8 @@ namespace
from_page(from_page)
{
}
- virtual ~ContentProvider() = default;
- virtual void provideStreamData(QPDFObjGen const&, Pipeline* pipeline);
+ ~ContentProvider() override = default;
+ void provideStreamData(QPDFObjGen const&, Pipeline* pipeline) override;
private:
QPDFObjectHandle from_page;
@@ -44,8 +44,8 @@ namespace
{
public:
InlineImageTracker(QPDF*, size_t min_size, QPDFObjectHandle resources);
- virtual ~InlineImageTracker() = default;
- virtual void handleToken(QPDFTokenizer::Token const&);
+ ~InlineImageTracker() override = default;
+ void handleToken(QPDFTokenizer::Token const&) override;
QPDFObjectHandle convertIIDict(QPDFObjectHandle odict);
QPDF* qpdf;
@@ -53,19 +53,16 @@ namespace
QPDFObjectHandle resources;
std::string dict_str;
std::string bi_str;
- int min_suffix;
- bool any_images;
- enum { st_top, st_bi } state;
+ int min_suffix{1};
+ bool any_images{false};
+ enum { st_top, st_bi } state{st_top};
};
} // namespace
InlineImageTracker::InlineImageTracker(QPDF* qpdf, size_t min_size, QPDFObjectHandle resources) :
qpdf(qpdf),
min_size(min_size),
- resources(resources),
- min_suffix(1),
- any_images(false),
- state(st_top)
+ resources(resources)
{
}
@@ -451,7 +448,7 @@ QPDFPageObjectHelper::getAnnotations(std::string const& only_subtype)
for (int i = 0; i < nannots; ++i) {
QPDFObjectHandle annot = annots.getArrayItem(i);
if (annot.isDictionaryOfType("", only_subtype)) {
- result.push_back(QPDFAnnotationObjectHelper(annot));
+ result.emplace_back(annot);
}
}
}
@@ -662,7 +659,7 @@ QPDFPageObjectHelper::shallowCopyPage()
QPDF& qpdf =
this->oh.getQPDF("QPDFPageObjectHelper::shallowCopyPage called with a direct object");
QPDFObjectHandle new_page = this->oh.shallowCopy();
- return QPDFPageObjectHelper(qpdf.makeIndirectObject(new_page));
+ return {qpdf.makeIndirectObject(new_page)};
}
QPDFObjectHandle::Matrix
@@ -758,7 +755,7 @@ QPDFPageObjectHelper::getMatrixForFormXObjectPlacement(
QPDFObjectHandle fdict = fo.getDict();
QPDFObjectHandle bbox_obj = fdict.getKey("/BBox");
if (!bbox_obj.isRectangle()) {
- return QPDFMatrix();
+ return {};
}
QPDFMatrix wmatrix; // work matrix
@@ -793,7 +790,7 @@ QPDFPageObjectHelper::getMatrixForFormXObjectPlacement(
// Calculate a scale factor, if needed. Shrink or expand if needed and allowed.
if ((T.urx == T.llx) || (T.ury == T.lly)) {
// avoid division by zero
- return QPDFMatrix();
+ return {};
}
double rect_w = rect.urx - rect.llx;
double rect_h = rect.ury - rect.lly;
diff --git a/libqpdf/QPDFParser.cc b/libqpdf/QPDFParser.cc
index 48227e55..6dcbddb5 100644
--- a/libqpdf/QPDFParser.cc
+++ b/libqpdf/QPDFParser.cc
@@ -55,7 +55,7 @@ QPDFParser::parse(bool& empty, bool content_stream)
bool set_offset = false;
std::vector<StackFrame> stack;
- stack.push_back(StackFrame(input));
+ stack.emplace_back(input);
std::vector<parser_state_e> state_stack;
state_stack.push_back(st_top);
qpdf_offset_t offset;
@@ -141,7 +141,7 @@ QPDFParser::parse(bool& empty, bool content_stream)
(tokenizer.getType() == QPDFTokenizer::tt_array_open) ? st_array
: st_dictionary);
b_contents = false;
- stack.push_back(StackFrame(input));
+ stack.emplace_back(input);
}
break;
diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc
index 50594a09..db3b42e0 100644
--- a/libqpdf/QPDFWriter.cc
+++ b/libqpdf/QPDFWriter.cc
@@ -26,7 +26,7 @@
#include <cstdlib>
#include <stdexcept>
-QPDFWriter::ProgressReporter::~ProgressReporter()
+QPDFWriter::ProgressReporter::~ProgressReporter() // NOLINT (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
}
@@ -36,7 +36,8 @@ QPDFWriter::FunctionProgressReporter::FunctionProgressReporter(std::function<voi
{
}
-QPDFWriter::FunctionProgressReporter::~FunctionProgressReporter()
+QPDFWriter::FunctionProgressReporter::~FunctionProgressReporter() // NOLINT
+ // (modernize-use-equals-default)
{
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
}
@@ -2034,29 +2035,25 @@ QPDFWriter::getTrimmedTrailer()
return trailer;
}
+// Make document extension level information direct as required by the spec.
void
QPDFWriter::prepareFileForWrite()
{
- // Make document extension level information direct as required by the spec.
-
m->pdf.fixDanglingReferences();
- QPDFObjectHandle root = m->pdf.getRoot();
- for (auto const& key: root.getKeys()) {
- QPDFObjectHandle oh = root.getKey(key);
- if ((key == "/Extensions") && (oh.isDictionary())) {
- bool extensions_indirect = false;
- if (oh.isIndirect()) {
- QTC::TC("qpdf", "QPDFWriter make Extensions direct");
- extensions_indirect = true;
- oh = root.replaceKeyAndGetNew(key, oh.shallowCopy());
- }
- if (oh.hasKey("/ADBE")) {
- QPDFObjectHandle adbe = oh.getKey("/ADBE");
- if (adbe.isIndirect()) {
- QTC::TC("qpdf", "QPDFWriter make ADBE direct", extensions_indirect ? 0 : 1);
- adbe.makeDirect();
- oh.replaceKey("/ADBE", adbe);
- }
+ auto root = m->pdf.getRoot();
+ auto oh = root.getKey("/Extensions");
+ if (oh.isDictionary()) {
+ const bool extensions_indirect = oh.isIndirect();
+ if (extensions_indirect) {
+ QTC::TC("qpdf", "QPDFWriter make Extensions direct");
+ oh = root.replaceKeyAndGetNew("/Extensions", oh.shallowCopy());
+ }
+ if (oh.hasKey("/ADBE")) {
+ auto adbe = oh.getKey("/ADBE");
+ if (adbe.isIndirect()) {
+ QTC::TC("qpdf", "QPDFWriter make ADBE direct", extensions_indirect ? 0 : 1);
+ adbe.makeDirect();
+ oh.replaceKey("/ADBE", adbe);
}
}
}
diff --git a/libqpdf/QPDFXRefEntry.cc b/libqpdf/QPDFXRefEntry.cc
index 7be98b2a..731ad405 100644
--- a/libqpdf/QPDFXRefEntry.cc
+++ b/libqpdf/QPDFXRefEntry.cc
@@ -3,7 +3,7 @@
#include <qpdf/QIntC.hh>
#include <qpdf/QPDFExc.hh>
-QPDFXRefEntry::QPDFXRefEntry()
+QPDFXRefEntry::QPDFXRefEntry() // NOLINT (modernize-use-equals-default)
{
}
diff --git a/libqpdf/QPDF_Array.cc b/libqpdf/QPDF_Array.cc
index 1b78e078..b5b182af 100644
--- a/libqpdf/QPDF_Array.cc
+++ b/libqpdf/QPDF_Array.cc
@@ -201,7 +201,7 @@ QPDF_Array::getAsVector() const
v.reserve(size_t(size()));
for (auto const& item: sp_elements) {
v.resize(size_t(item.first), null_oh);
- v.push_back(item.second);
+ v.emplace_back(item.second);
}
v.resize(size_t(size()), null_oh);
return v;
diff --git a/libqpdf/QPDF_encryption.cc b/libqpdf/QPDF_encryption.cc
index 26044500..b5cc44ee 100644
--- a/libqpdf/QPDF_encryption.cc
+++ b/libqpdf/QPDF_encryption.cc
@@ -164,7 +164,7 @@ pad_or_truncate_password_V4(std::string const& password)
{
char k1[key_bytes];
pad_or_truncate_password_V4(password, k1);
- return std::string(k1, key_bytes);
+ return {k1, key_bytes};
}
static std::string
@@ -235,7 +235,7 @@ process_with_aes(
} else {
outlength = std::min(outlength, bufp->getSize());
}
- return std::string(reinterpret_cast<char*>(bufp->getBuffer()), outlength);
+ return {reinterpret_cast<char*>(bufp->getBuffer()), outlength};
}
static std::string
@@ -355,7 +355,7 @@ QPDF::compute_data_key(
md5.encodeDataIncrementally(result.c_str(), result.length());
MD5::Digest digest;
md5.digest(digest);
- return std::string(reinterpret_cast<char*>(digest), std::min(result.length(), toS(16)));
+ return {reinterpret_cast<char*>(digest), std::min(result.length(), toS(16))};
}
std::string
@@ -401,7 +401,7 @@ QPDF::compute_encryption_key_from_password(std::string const& password, Encrypti
MD5::Digest digest;
int key_len = std::min(toI(sizeof(digest)), data.getLengthBytes());
iterate_md5_digest(md5, digest, ((data.getR() >= 3) ? 50 : 0), key_len);
- return std::string(reinterpret_cast<char*>(digest), toS(key_len));
+ return {reinterpret_cast<char*>(digest), toS(key_len)};
}
static void
@@ -448,7 +448,7 @@ compute_O_value(
data.getLengthBytes(),
(data.getR() >= 3) ? 20 : 1,
false);
- return std::string(upass, key_bytes);
+ return {upass, key_bytes};
}
static std::string
@@ -467,7 +467,7 @@ compute_U_value_R2(std::string const& user_password, QPDF::EncryptionData const&
data.getLengthBytes(),
1,
false);
- return std::string(udata, key_bytes);
+ return {udata, key_bytes};
}
static std::string
@@ -496,7 +496,7 @@ compute_U_value_R3(std::string const& user_password, QPDF::EncryptionData const&
for (unsigned int i = sizeof(MD5::Digest); i < key_bytes; ++i) {
result[i] = static_cast<char>((i * i) % 0xff);
}
- return std::string(result, key_bytes);
+ return {result, key_bytes};
}
static std::string
diff --git a/libqpdf/QPDF_json.cc b/libqpdf/QPDF_json.cc
index c74cf4f7..f8fd689a 100644
--- a/libqpdf/QPDF_json.cc
+++ b/libqpdf/QPDF_json.cc
@@ -238,7 +238,7 @@ class QPDF::JSONReactor: public JSON::Reactor
}
}
}
- virtual ~JSONReactor() = default;
+ ~JSONReactor() override = default;
void dictionaryStart() override;
void arrayStart() override;
void containerEnd(JSON const& value) override;
diff --git a/libqpdf/QPDF_linearization.cc b/libqpdf/QPDF_linearization.cc
index faebf5b6..fe25c6d9 100644
--- a/libqpdf/QPDF_linearization.cc
+++ b/libqpdf/QPDF_linearization.cc
@@ -1367,7 +1367,7 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
for (auto& oh: m->part6) {
int obj = oh.getObjectID();
obj_to_index[obj] = toI(shared.size());
- shared.push_back(CHSharedObjectEntry(obj));
+ shared.emplace_back(obj);
}
QTC::TC("qpdf", "QPDF lin part 8 empty", m->part8.empty() ? 1 : 0);
if (!m->part8.empty()) {
@@ -1375,7 +1375,7 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
for (auto& oh: m->part8) {
int obj = oh.getObjectID();
obj_to_index[obj] = toI(shared.size());
- shared.push_back(CHSharedObjectEntry(obj));
+ shared.emplace_back(obj);
}
}
if (static_cast<size_t>(m->c_shared_object_data.nshared_total) !=
@@ -1585,7 +1585,7 @@ QPDF::calculateHSharedObject(
int length = outputLengthNextN(csoe.at(i).object, 1, lengths, obj_renumber);
min_length = std::min(min_length, length);
max_length = std::max(max_length, length);
- soe.push_back(HSharedObjectEntry());
+ soe.emplace_back();
soe.at(i).delta_group_length = length;
}
if (soe.size() != toS(cso.nshared_total)) {
diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc
index 76d6bfd5..0fb03579 100644
--- a/libqpdf/QUtil.cc
+++ b/libqpdf/QUtil.cc
@@ -903,14 +903,14 @@ QUtil::get_current_qpdf_time()
// Don't know how to get timezone on this platform
int tzoff = 0;
# endif
- return QPDFTime(
+ return {
static_cast<int>(ltime.tm_year + 1900),
static_cast<int>(ltime.tm_mon + 1),
static_cast<int>(ltime.tm_mday),
static_cast<int>(ltime.tm_hour),
static_cast<int>(ltime.tm_min),
static_cast<int>(ltime.tm_sec),
- tzoff);
+ tzoff};
#endif
}
@@ -1082,13 +1082,12 @@ namespace
private:
RandomDataProvider* default_provider;
- RandomDataProvider* current_provider;
+ RandomDataProvider* current_provider{nullptr};
};
} // namespace
RandomDataProviderProvider::RandomDataProviderProvider() :
- default_provider(CryptoRandomDataProvider::getInstance()),
- current_provider(nullptr)
+ default_provider(CryptoRandomDataProvider::getInstance())
{
this->current_provider = default_provider;
}
@@ -1246,7 +1245,7 @@ QUtil::read_lines_from_file(
char c;
while (next_char(c)) {
if (buf == nullptr) {
- lines.push_back("");
+ lines.emplace_back("");
buf = &(lines.back());
buf->reserve(80);
}
diff --git a/libqpdf/qpdf-c.cc b/libqpdf/qpdf-c.cc
index fe2a608e..1f7b85cb 100644
--- a/libqpdf/qpdf-c.cc
+++ b/libqpdf/qpdf-c.cc
@@ -813,13 +813,13 @@ trap_oh_errors(qpdf_data qpdf, std::function<RET()> fallback, std::function<RET(
if (!qpdf->silence_errors) {
QTC::TC("qpdf", "qpdf-c warn about oh error", qpdf->oh_error_occurred ? 0 : 1);
if (!qpdf->oh_error_occurred) {
- qpdf->warnings.push_back(QPDFExc(
+ qpdf->warnings.emplace_back(
qpdf_e_internal,
qpdf->qpdf->getFilename(),
"",
0,
"C API function caught an exception that it isn't returning; please point the "
- "application developer to ERROR HANDLING in qpdf-c.h"));
+ "application developer to ERROR HANDLING in qpdf-c.h");
qpdf->oh_error_occurred = true;
}
*QPDFLogger::defaultLogger()->getError() << qpdf->error->what() << "\n";
diff --git a/libqpdf/qpdf/JSONHandler.hh b/libqpdf/qpdf/JSONHandler.hh
index 8fdcaee6..653924f6 100644
--- a/libqpdf/qpdf/JSONHandler.hh
+++ b/libqpdf/qpdf/JSONHandler.hh
@@ -16,7 +16,7 @@ class JSONHandler
public:
// A QPDFUsage exception is thrown if there are any errors validating the JSON object.
JSONHandler();
- ~JSONHandler() = default;
+ ~JSONHandler();
// Based on the type of handler, expect the object to be of a certain type. QPDFUsage is thrown
// otherwise. Multiple handlers may be registered, which allows the object to be of various
@@ -53,51 +53,10 @@ class JSONHandler
static void usage(std::string const& msg);
- struct Handlers
- {
- Handlers() :
- any_handler(nullptr),
- null_handler(nullptr),
- string_handler(nullptr),
- number_handler(nullptr),
- bool_handler(nullptr),
- dict_start_handler(nullptr),
- dict_end_handler(nullptr),
- array_start_handler(nullptr),
- array_end_handler(nullptr),
- final_handler(nullptr)
- {
- }
-
- json_handler_t any_handler;
- void_handler_t null_handler;
- string_handler_t string_handler;
- string_handler_t number_handler;
- bool_handler_t bool_handler;
- json_handler_t dict_start_handler;
- void_handler_t dict_end_handler;
- json_handler_t array_start_handler;
- void_handler_t array_end_handler;
- void_handler_t final_handler;
- std::map<std::string, std::shared_ptr<JSONHandler>> dict_handlers;
- std::shared_ptr<JSONHandler> fallback_dict_handler;
- std::shared_ptr<JSONHandler> array_item_handler;
- };
-
- class Members
- {
- friend class JSONHandler;
-
- public:
- ~Members() = default;
-
- private:
- Members() = default;
- Members(Members const&) = delete;
-
- Handlers h;
- };
- std::shared_ptr<Members> m;
+
+ class Members;
+
+ std::unique_ptr<Members> m;
};
#endif // JSONHANDLER_HH
diff --git a/libqpdf/qpdf/Pl_LZWDecoder.hh b/libqpdf/qpdf/Pl_LZWDecoder.hh
index b2135aa9..792fa8ef 100644
--- a/libqpdf/qpdf/Pl_LZWDecoder.hh
+++ b/libqpdf/qpdf/Pl_LZWDecoder.hh
@@ -10,9 +10,9 @@ class Pl_LZWDecoder: public Pipeline
{
public:
Pl_LZWDecoder(char const* identifier, Pipeline* next, bool early_code_change);
- virtual ~Pl_LZWDecoder() = default;
- virtual void write(unsigned char const* buf, size_t len);
- virtual void finish();
+ ~Pl_LZWDecoder() override = default;
+ void write(unsigned char const* buf, size_t len) override;
+ void finish() override;
private:
void sendNextCode();
diff --git a/libqpdf/qpdf/Pl_MD5.hh b/libqpdf/qpdf/Pl_MD5.hh
index 5763d6eb..fb9a2184 100644
--- a/libqpdf/qpdf/Pl_MD5.hh
+++ b/libqpdf/qpdf/Pl_MD5.hh
@@ -14,9 +14,9 @@ class Pl_MD5: public Pipeline
{
public:
Pl_MD5(char const* identifier, Pipeline* next);
- virtual ~Pl_MD5() = default;
- virtual void write(unsigned char const*, size_t);
- virtual void finish();
+ ~Pl_MD5() override = default;
+ void write(unsigned char const*, size_t) override;
+ void finish() override;
std::string getHexDigest();
// Enable/disable. Disabling the pipeline causes it to become a pass-through. This makes it
// possible to stick an MD5 pipeline in a pipeline when it may or may not be required. Disabling
diff --git a/libqpdf/qpdf/QPDFArgParser.hh b/libqpdf/qpdf/QPDFArgParser.hh
index 3b22a805..ed161d53 100644
--- a/libqpdf/qpdf/QPDFArgParser.hh
+++ b/libqpdf/qpdf/QPDFArgParser.hh
@@ -145,19 +145,12 @@ class QPDFArgParser
private:
struct OptionEntry
{
- OptionEntry() :
- parameter_needed(false),
- bare_arg_handler(nullptr),
- param_arg_handler(nullptr),
- invalid_choice_handler(nullptr)
- {
- }
- bool parameter_needed;
+ bool parameter_needed{false};
std::string parameter_name;
std::set<std::string> choices;
- bare_arg_handler_t bare_arg_handler;
- param_arg_handler_t param_arg_handler;
- param_arg_handler_t invalid_choice_handler;
+ bare_arg_handler_t bare_arg_handler{nullptr};
+ param_arg_handler_t param_arg_handler{nullptr};
+ param_arg_handler_t invalid_choice_handler{nullptr};
};
typedef std::map<std::string, OptionEntry> option_table_t;
diff --git a/libqpdf/qpdf/QPDF_Array.hh b/libqpdf/qpdf/QPDF_Array.hh
index 51a366a6..10ac9f8c 100644
--- a/libqpdf/qpdf/QPDF_Array.hh
+++ b/libqpdf/qpdf/QPDF_Array.hh
@@ -9,14 +9,14 @@
class QPDF_Array: public QPDFValue
{
public:
- virtual ~QPDF_Array() = default;
+ ~QPDF_Array() override = default;
static std::shared_ptr<QPDFObject> create(std::vector<QPDFObjectHandle> const& items);
static std::shared_ptr<QPDFObject>
create(std::vector<std::shared_ptr<QPDFObject>>&& items, bool sparse);
- virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
- virtual std::string unparse();
- virtual JSON getJSON(int json_version);
- virtual void disconnect();
+ std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
+ std::string unparse() override;
+ JSON getJSON(int json_version) override;
+ void disconnect() override;
int
size() const noexcept
diff --git a/libqpdf/qpdf/QPDF_Bool.hh b/libqpdf/qpdf/QPDF_Bool.hh
index 215d359a..0b4a71fd 100644
--- a/libqpdf/qpdf/QPDF_Bool.hh
+++ b/libqpdf/qpdf/QPDF_Bool.hh
@@ -6,11 +6,11 @@
class QPDF_Bool: public QPDFValue
{
public:
- virtual ~QPDF_Bool() = default;
+ ~QPDF_Bool() override = default;
static std::shared_ptr<QPDFObject> create(bool val);
- virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
- virtual std::string unparse();
- virtual JSON getJSON(int json_version);
+ std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
+ std::string unparse() override;
+ JSON getJSON(int json_version) override;
bool getVal() const;
private:
diff --git a/libqpdf/qpdf/QPDF_Destroyed.hh b/libqpdf/qpdf/QPDF_Destroyed.hh
index c8e35557..72e9130a 100644
--- a/libqpdf/qpdf/QPDF_Destroyed.hh
+++ b/libqpdf/qpdf/QPDF_Destroyed.hh
@@ -6,10 +6,10 @@
class QPDF_Destroyed: public QPDFValue
{
public:
- virtual ~QPDF_Destroyed() = default;
- virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
- virtual std::string unparse();
- virtual JSON getJSON(int json_version);
+ ~QPDF_Destroyed() override = default;
+ std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
+ std::string unparse() override;
+ JSON getJSON(int json_version) override;
static std::shared_ptr<QPDFValue> getInstance();
private:
diff --git a/libqpdf/qpdf/QPDF_Dictionary.hh b/libqpdf/qpdf/QPDF_Dictionary.hh
index da38db7a..0fb6636e 100644
--- a/libqpdf/qpdf/QPDF_Dictionary.hh
+++ b/libqpdf/qpdf/QPDF_Dictionary.hh
@@ -11,13 +11,13 @@
class QPDF_Dictionary: public QPDFValue
{
public:
- virtual ~QPDF_Dictionary() = default;
+ ~QPDF_Dictionary() override = default;
static std::shared_ptr<QPDFObject> create(std::map<std::string, QPDFObjectHandle> const& items);
static std::shared_ptr<QPDFObject> create(std::map<std::string, QPDFObjectHandle>&& items);
- virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
- virtual std::string unparse();
- virtual JSON getJSON(int json_version);
- virtual void disconnect();
+ std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
+ std::string unparse() override;
+ JSON getJSON(int json_version) override;
+ void disconnect() override;
// hasKey() and getKeys() treat keys with null values as if they aren't there. getKey() returns
// null for the value of a non-existent key. This is as per the PDF spec.
diff --git a/libqpdf/qpdf/QPDF_InlineImage.hh b/libqpdf/qpdf/QPDF_InlineImage.hh
index 553d1d71..bee12354 100644
--- a/libqpdf/qpdf/QPDF_InlineImage.hh
+++ b/libqpdf/qpdf/QPDF_InlineImage.hh
@@ -6,13 +6,13 @@
class QPDF_InlineImage: public QPDFValue
{
public:
- virtual ~QPDF_InlineImage() = default;
+ ~QPDF_InlineImage() override = default;
static std::shared_ptr<QPDFObject> create(std::string const& val);
- virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
- virtual std::string unparse();
- virtual JSON getJSON(int json_version);
- virtual std::string
- getStringValue() const
+ std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
+ std::string unparse() override;
+ JSON getJSON(int json_version) override;
+ std::string
+ getStringValue() const override
{
return val;
}
diff --git a/libqpdf/qpdf/QPDF_Integer.hh b/libqpdf/qpdf/QPDF_Integer.hh
index 180bb48a..2c2cf2f9 100644
--- a/libqpdf/qpdf/QPDF_Integer.hh
+++ b/libqpdf/qpdf/QPDF_Integer.hh
@@ -6,11 +6,11 @@
class QPDF_Integer: public QPDFValue
{
public:
- virtual ~QPDF_Integer() = default;
+ ~QPDF_Integer() override = default;
static std::shared_ptr<QPDFObject> create(long long value);
- virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
- virtual std::string unparse();
- virtual JSON getJSON(int json_version);
+ std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
+ std::string unparse() override;
+ JSON getJSON(int json_version) override;
long long getVal() const;
private:
diff --git a/libqpdf/qpdf/QPDF_Name.hh b/libqpdf/qpdf/QPDF_Name.hh
index 136ad5cb..c14d8659 100644
--- a/libqpdf/qpdf/QPDF_Name.hh
+++ b/libqpdf/qpdf/QPDF_Name.hh
@@ -6,16 +6,16 @@
class QPDF_Name: public QPDFValue
{
public:
- virtual ~QPDF_Name() = default;
+ ~QPDF_Name() override = default;
static std::shared_ptr<QPDFObject> create(std::string const& name);
- virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
- virtual std::string unparse();
- virtual JSON getJSON(int json_version);
+ std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
+ std::string unparse() override;
+ JSON getJSON(int json_version) override;
// Put # into strings with characters unsuitable for name token
static std::string normalizeName(std::string const& name);
- virtual std::string
- getStringValue() const
+ std::string
+ getStringValue() const override
{
return name;
}
diff --git a/libqpdf/qpdf/QPDF_Null.hh b/libqpdf/qpdf/QPDF_Null.hh
index 2bbb3db5..a59b7509 100644
--- a/libqpdf/qpdf/QPDF_Null.hh
+++ b/libqpdf/qpdf/QPDF_Null.hh
@@ -6,7 +6,7 @@
class QPDF_Null: public QPDFValue
{
public:
- virtual ~QPDF_Null() = default;
+ ~QPDF_Null() override = default;
static std::shared_ptr<QPDFObject> create();
static std::shared_ptr<QPDFObject> create(
std::shared_ptr<QPDFObject> parent,
@@ -16,9 +16,9 @@ class QPDF_Null: public QPDFValue
std::shared_ptr<QPDFValue> parent,
std::string_view const& static_descr,
std::string var_descr);
- virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
- virtual std::string unparse();
- virtual JSON getJSON(int json_version);
+ std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
+ std::string unparse() override;
+ JSON getJSON(int json_version) override;
private:
QPDF_Null();
diff --git a/libqpdf/qpdf/QPDF_Operator.hh b/libqpdf/qpdf/QPDF_Operator.hh
index 4fedb808..77aa5a17 100644
--- a/libqpdf/qpdf/QPDF_Operator.hh
+++ b/libqpdf/qpdf/QPDF_Operator.hh
@@ -6,13 +6,13 @@
class QPDF_Operator: public QPDFValue
{
public:
- virtual ~QPDF_Operator() = default;
+ ~QPDF_Operator() override = default;
static std::shared_ptr<QPDFObject> create(std::string const& val);
- virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
- virtual std::string unparse();
- virtual JSON getJSON(int json_version);
- virtual std::string
- getStringValue() const
+ std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
+ std::string unparse() override;
+ JSON getJSON(int json_version) override;
+ std::string
+ getStringValue() const override
{
return val;
}
diff --git a/libqpdf/qpdf/QPDF_Real.hh b/libqpdf/qpdf/QPDF_Real.hh
index f470e1a6..db5e0940 100644
--- a/libqpdf/qpdf/QPDF_Real.hh
+++ b/libqpdf/qpdf/QPDF_Real.hh
@@ -6,15 +6,15 @@
class QPDF_Real: public QPDFValue
{
public:
- virtual ~QPDF_Real() = default;
+ ~QPDF_Real() override = default;
static std::shared_ptr<QPDFObject> create(std::string const& val);
static std::shared_ptr<QPDFObject>
create(double value, int decimal_places, bool trim_trailing_zeroes);
- virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
- virtual std::string unparse();
- virtual JSON getJSON(int json_version);
- virtual std::string
- getStringValue() const
+ std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
+ std::string unparse() override;
+ JSON getJSON(int json_version) override;
+ std::string
+ getStringValue() const override
{
return val;
}
diff --git a/libqpdf/qpdf/QPDF_Reserved.hh b/libqpdf/qpdf/QPDF_Reserved.hh
index 8d6c74f8..9ba855b7 100644
--- a/libqpdf/qpdf/QPDF_Reserved.hh
+++ b/libqpdf/qpdf/QPDF_Reserved.hh
@@ -6,11 +6,11 @@
class QPDF_Reserved: public QPDFValue
{
public:
- virtual ~QPDF_Reserved() = default;
+ ~QPDF_Reserved() override = default;
static std::shared_ptr<QPDFObject> create();
- virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
- virtual std::string unparse();
- virtual JSON getJSON(int json_version);
+ std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
+ std::string unparse() override;
+ JSON getJSON(int json_version) override;
private:
QPDF_Reserved();
diff --git a/libqpdf/qpdf/QPDF_Stream.hh b/libqpdf/qpdf/QPDF_Stream.hh
index 88331201..8488e157 100644
--- a/libqpdf/qpdf/QPDF_Stream.hh
+++ b/libqpdf/qpdf/QPDF_Stream.hh
@@ -16,19 +16,19 @@ class QPDF;
class QPDF_Stream: public QPDFValue
{
public:
- virtual ~QPDF_Stream() = default;
+ ~QPDF_Stream() override = default;
static std::shared_ptr<QPDFObject> create(
QPDF*,
QPDFObjGen const& og,
QPDFObjectHandle stream_dict,
qpdf_offset_t offset,
size_t length);
- virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
- virtual std::string unparse();
- virtual JSON getJSON(int json_version);
- virtual void setDescription(
- QPDF*, std::shared_ptr<QPDFValue::Description>& description, qpdf_offset_t offset);
- virtual void disconnect();
+ std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
+ std::string unparse() override;
+ JSON getJSON(int json_version) override;
+ void setDescription(
+ QPDF*, std::shared_ptr<QPDFValue::Description>& description, qpdf_offset_t offset) override;
+ void disconnect() override;
QPDFObjectHandle getDict() const;
bool isDataModified() const;
void setFilterOnWrite(bool);
diff --git a/libqpdf/qpdf/QPDF_String.hh b/libqpdf/qpdf/QPDF_String.hh
index d4a1bfd4..c34cafef 100644
--- a/libqpdf/qpdf/QPDF_String.hh
+++ b/libqpdf/qpdf/QPDF_String.hh
@@ -10,16 +10,16 @@ class QPDF_String: public QPDFValue
friend class QPDFWriter;
public:
- virtual ~QPDF_String() = default;
+ ~QPDF_String() override = default;
static std::shared_ptr<QPDFObject> create(std::string const& val);
static std::shared_ptr<QPDFObject> create_utf16(std::string const& utf8_val);
- virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
- virtual std::string unparse();
+ std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
+ std::string unparse() override;
std::string unparse(bool force_binary);
- virtual JSON getJSON(int json_version);
+ JSON getJSON(int json_version) override;
std::string getUTF8Val() const;
- virtual std::string
- getStringValue() const
+ std::string
+ getStringValue() const override
{
return val;
}
diff --git a/libqpdf/qpdf/QPDF_Unresolved.hh b/libqpdf/qpdf/QPDF_Unresolved.hh
index 43d2af31..0a1fa9a5 100644
--- a/libqpdf/qpdf/QPDF_Unresolved.hh
+++ b/libqpdf/qpdf/QPDF_Unresolved.hh
@@ -6,11 +6,11 @@
class QPDF_Unresolved: public QPDFValue
{
public:
- virtual ~QPDF_Unresolved() = default;
+ ~QPDF_Unresolved() override = default;
static std::shared_ptr<QPDFObject> create(QPDF* qpdf, QPDFObjGen const& og);
- virtual std::shared_ptr<QPDFObject> copy(bool shallow = false);
- virtual std::string unparse();
- virtual JSON getJSON(int json_version);
+ std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
+ std::string unparse() override;
+ JSON getJSON(int json_version) override;
private:
QPDF_Unresolved(QPDF* qpdf, QPDFObjGen const& og);
diff --git a/libqpdf/qpdf/ResourceFinder.hh b/libqpdf/qpdf/ResourceFinder.hh
index d8cb32e6..1c4c59a7 100644
--- a/libqpdf/qpdf/ResourceFinder.hh
+++ b/libqpdf/qpdf/ResourceFinder.hh
@@ -7,7 +7,7 @@ class ResourceFinder: public QPDFObjectHandle::ParserCallbacks
{
public:
ResourceFinder();
- virtual ~ResourceFinder() = default;
+ ~ResourceFinder() override = default;
void handleObject(QPDFObjectHandle, size_t, size_t) override;
void handleEOF() override;
std::set<std::string> const& getNames() const;
diff --git a/libqpdf/qpdf/SF_ASCII85Decode.hh b/libqpdf/qpdf/SF_ASCII85Decode.hh
index 8cf85e66..d474904c 100644
--- a/libqpdf/qpdf/SF_ASCII85Decode.hh
+++ b/libqpdf/qpdf/SF_ASCII85Decode.hh
@@ -9,7 +9,7 @@ class SF_ASCII85Decode: public QPDFStreamFilter
{
public:
SF_ASCII85Decode() = default;
- virtual ~SF_ASCII85Decode() = default;
+ ~SF_ASCII85Decode() override = default;
Pipeline*
getDecodePipeline(Pipeline* next) override
diff --git a/libqpdf/qpdf/SF_ASCIIHexDecode.hh b/libqpdf/qpdf/SF_ASCIIHexDecode.hh
index cd87761e..bb21ede6 100644
--- a/libqpdf/qpdf/SF_ASCIIHexDecode.hh
+++ b/libqpdf/qpdf/SF_ASCIIHexDecode.hh
@@ -9,7 +9,7 @@ class SF_ASCIIHexDecode: public QPDFStreamFilter
{
public:
SF_ASCIIHexDecode() = default;
- virtual ~SF_ASCIIHexDecode() = default;
+ ~SF_ASCIIHexDecode() override = default;
Pipeline*
getDecodePipeline(Pipeline* next) override
diff --git a/libqpdf/qpdf/SF_DCTDecode.hh b/libqpdf/qpdf/SF_DCTDecode.hh
index 997ba89a..619cf9c4 100644
--- a/libqpdf/qpdf/SF_DCTDecode.hh
+++ b/libqpdf/qpdf/SF_DCTDecode.hh
@@ -9,7 +9,7 @@ class SF_DCTDecode: public QPDFStreamFilter
{
public:
SF_DCTDecode() = default;
- virtual ~SF_DCTDecode() = default;
+ ~SF_DCTDecode() override = default;
Pipeline*
getDecodePipeline(Pipeline* next) override
diff --git a/libqpdf/qpdf/SF_FlateLzwDecode.hh b/libqpdf/qpdf/SF_FlateLzwDecode.hh
index 2230ec58..203d893b 100644
--- a/libqpdf/qpdf/SF_FlateLzwDecode.hh
+++ b/libqpdf/qpdf/SF_FlateLzwDecode.hh
@@ -9,10 +9,10 @@ class SF_FlateLzwDecode: public QPDFStreamFilter
{
public:
SF_FlateLzwDecode(bool lzw);
- virtual ~SF_FlateLzwDecode() = default;
+ ~SF_FlateLzwDecode() override = default;
- virtual bool setDecodeParms(QPDFObjectHandle decode_parms);
- virtual Pipeline* getDecodePipeline(Pipeline* next);
+ bool setDecodeParms(QPDFObjectHandle decode_parms) override;
+ Pipeline* getDecodePipeline(Pipeline* next) override;
static std::shared_ptr<QPDFStreamFilter> flate_factory();
static std::shared_ptr<QPDFStreamFilter> lzw_factory();
diff --git a/libqpdf/qpdf/SF_RunLengthDecode.hh b/libqpdf/qpdf/SF_RunLengthDecode.hh
index 83c498dc..4a51cf6f 100644
--- a/libqpdf/qpdf/SF_RunLengthDecode.hh
+++ b/libqpdf/qpdf/SF_RunLengthDecode.hh
@@ -9,7 +9,7 @@ class SF_RunLengthDecode: public QPDFStreamFilter
{
public:
SF_RunLengthDecode() = default;
- virtual ~SF_RunLengthDecode() = default;
+ ~SF_RunLengthDecode() override = default;
Pipeline*
getDecodePipeline(Pipeline* next) override
diff --git a/libqpdf/qpdf/SecureRandomDataProvider.hh b/libqpdf/qpdf/SecureRandomDataProvider.hh
index d701a905..f6a29b76 100644
--- a/libqpdf/qpdf/SecureRandomDataProvider.hh
+++ b/libqpdf/qpdf/SecureRandomDataProvider.hh
@@ -7,8 +7,8 @@ class SecureRandomDataProvider: public RandomDataProvider
{
public:
SecureRandomDataProvider() = default;
- virtual ~SecureRandomDataProvider() = default;
- virtual void provideRandomData(unsigned char* data, size_t len);
+ ~SecureRandomDataProvider() override = default;
+ void provideRandomData(unsigned char* data, size_t len) override;
static RandomDataProvider* getInstance();
};