Commit 6020af9f91009e4413aeaef781a1f537e41b4a26
1 parent
9cb220a4
Update `unparseChild` and `unparseObject` in `QPDFWriter` to use `size_t` for `l…
…evel` and add `const&` to `child` parameter.
Showing
2 changed files
with
5 additions
and
8 deletions
include/qpdf/QPDFWriter.hh
| ... | ... | @@ -485,12 +485,12 @@ class QPDFWriter |
| 485 | 485 | std::string* stream_data); |
| 486 | 486 | void unparseObject( |
| 487 | 487 | QPDFObjectHandle object, |
| 488 | - int level, | |
| 488 | + size_t level, | |
| 489 | 489 | int flags, |
| 490 | 490 | // for stream dictionaries |
| 491 | 491 | size_t stream_length = 0, |
| 492 | 492 | bool compress = false); |
| 493 | - void unparseChild(QPDFObjectHandle child, int level, int flags); | |
| 493 | + void unparseChild(QPDFObjectHandle const& child, size_t level, int flags); | |
| 494 | 494 | void initializeSpecialStreams(); |
| 495 | 495 | void preserveObjectStreams(); |
| 496 | 496 | void generateObjectStreams(); | ... | ... |
libqpdf/QPDFWriter.cc
| ... | ... | @@ -1237,7 +1237,7 @@ QPDFWriter::enqueueObject(QPDFObjectHandle object) |
| 1237 | 1237 | } |
| 1238 | 1238 | |
| 1239 | 1239 | void |
| 1240 | -QPDFWriter::unparseChild(QPDFObjectHandle child, int level, int flags) | |
| 1240 | +QPDFWriter::unparseChild(QPDFObjectHandle const& child, size_t level, int flags) | |
| 1241 | 1241 | { |
| 1242 | 1242 | if (!m->linearized) { |
| 1243 | 1243 | enqueueObject(child); |
| ... | ... | @@ -1417,18 +1417,15 @@ QPDFWriter::willFilterStream( |
| 1417 | 1417 | |
| 1418 | 1418 | void |
| 1419 | 1419 | QPDFWriter::unparseObject( |
| 1420 | - QPDFObjectHandle object, int level, int flags, size_t stream_length, bool compress) | |
| 1420 | + QPDFObjectHandle object, size_t level, int flags, size_t stream_length, bool compress) | |
| 1421 | 1421 | { |
| 1422 | 1422 | QPDFObjGen old_og = object.getObjGen(); |
| 1423 | 1423 | int child_flags = flags & ~f_stream; |
| 1424 | - if (level < 0) { | |
| 1425 | - throw std::logic_error("invalid level in QPDFWriter::unparseObject"); | |
| 1426 | - } | |
| 1427 | 1424 | // For non-qdf, "indent" and "indent_large" are a single space between tokens. For qdf, they |
| 1428 | 1425 | // include the preceding newline. |
| 1429 | 1426 | std::string indent_large = " "; |
| 1430 | 1427 | if (m->qdf_mode) { |
| 1431 | - indent_large.append(static_cast<size_t>(2 * (level + 1)), ' '); | |
| 1428 | + indent_large.append(2 * (level + 1), ' '); | |
| 1432 | 1429 | indent_large[0] = '\n'; |
| 1433 | 1430 | } |
| 1434 | 1431 | std::string_view indent{indent_large.data(), m->qdf_mode ? indent_large.size() - 2 : 1}; | ... | ... |