Commit 33e8195c3af99f73e09ec88eae004330fc0480dc
Committed by
Jay Berkenbilt
1 parent
6dd84659
Tidy pdf-count-strings example
Convert loop to use range-based for statement. Remove unnecessary variables.
Showing
1 changed file
with
3 additions
and
7 deletions
examples/pdf-count-strings.cc
| ... | ... | @@ -91,13 +91,9 @@ int main(int argc, char* argv[]) |
| 91 | 91 | { |
| 92 | 92 | QPDF pdf; |
| 93 | 93 | pdf.processFile(infilename); |
| 94 | - std::vector<QPDFPageObjectHelper> pages = | |
| 95 | - QPDFPageDocumentHelper(pdf).getAllPages(); | |
| 96 | 94 | int pageno = 0; |
| 97 | - for (std::vector<QPDFPageObjectHelper>::iterator iter = pages.begin(); | |
| 98 | - iter != pages.end(); ++iter) | |
| 95 | + for (auto& page : QPDFPageDocumentHelper(pdf).getAllPages()) | |
| 99 | 96 | { |
| 100 | - QPDFPageObjectHelper& ph(*iter); | |
| 101 | 97 | ++pageno; |
| 102 | 98 | // Pass the contents of a page through our string counter. |
| 103 | 99 | // If it's an even page, capture the output. This |
| ... | ... | @@ -107,14 +103,14 @@ int main(int argc, char* argv[]) |
| 107 | 103 | if (pageno % 2) |
| 108 | 104 | { |
| 109 | 105 | // Ignore output for odd pages. |
| 110 | - ph.filterContents(&counter); | |
| 106 | + page.filterContents(&counter); | |
| 111 | 107 | } |
| 112 | 108 | else |
| 113 | 109 | { |
| 114 | 110 | // Write output to stdout for even pages. |
| 115 | 111 | Pl_StdioFile out("stdout", stdout); |
| 116 | 112 | std::cout << "% Contents of page " << pageno << std::endl; |
| 117 | - ph.filterContents(&counter, &out); | |
| 113 | + page.filterContents(&counter, &out); | |
| 118 | 114 | std::cout << "\n% end " << pageno << std::endl; |
| 119 | 115 | } |
| 120 | 116 | std::cout << "Page " << pageno | ... | ... |