diff options
author | m-holger <m-holger@kubitscheck.org> | 2022-02-20 17:49:31 +0100 |
---|---|---|
committer | Jay Berkenbilt <jberkenbilt@users.noreply.github.com> | 2022-02-26 18:46:13 +0100 |
commit | 33e8195c3af99f73e09ec88eae004330fc0480dc (patch) | |
tree | e1b08b334ccf8b768b61e7e6b50fd31f6eb82a50 | |
parent | 6dd84659489e49a10a3671ffbaf2d2b0681d99fc (diff) | |
download | qpdf-33e8195c3af99f73e09ec88eae004330fc0480dc.tar.zst |
Tidy pdf-count-strings example
Convert loop to use range-based for statement.
Remove unnecessary variables.
-rw-r--r-- | examples/pdf-count-strings.cc | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/examples/pdf-count-strings.cc b/examples/pdf-count-strings.cc index 600042f7..4c21bc58 100644 --- a/examples/pdf-count-strings.cc +++ b/examples/pdf-count-strings.cc @@ -91,13 +91,9 @@ int main(int argc, char* argv[]) { QPDF pdf; pdf.processFile(infilename); - std::vector<QPDFPageObjectHelper> pages = - QPDFPageDocumentHelper(pdf).getAllPages(); int pageno = 0; - for (std::vector<QPDFPageObjectHelper>::iterator iter = pages.begin(); - iter != pages.end(); ++iter) + for (auto& page : QPDFPageDocumentHelper(pdf).getAllPages()) { - QPDFPageObjectHelper& ph(*iter); ++pageno; // Pass the contents of a page through our string counter. // If it's an even page, capture the output. This @@ -107,14 +103,14 @@ int main(int argc, char* argv[]) if (pageno % 2) { // Ignore output for odd pages. - ph.filterContents(&counter); + page.filterContents(&counter); } else { // Write output to stdout for even pages. Pl_StdioFile out("stdout", stdout); std::cout << "% Contents of page " << pageno << std::endl; - ph.filterContents(&counter, &out); + page.filterContents(&counter, &out); std::cout << "\n% end " << pageno << std::endl; } std::cout << "Page " << pageno |