mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-02 22:50:20 +00:00
Tidy pdf-count-strings example
Convert loop to use range-based for statement. Remove unnecessary variables.
This commit is contained in:
parent
6dd8465948
commit
33e8195c3a
@ -91,13 +91,9 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
QPDF pdf;
|
QPDF pdf;
|
||||||
pdf.processFile(infilename);
|
pdf.processFile(infilename);
|
||||||
std::vector<QPDFPageObjectHelper> pages =
|
|
||||||
QPDFPageDocumentHelper(pdf).getAllPages();
|
|
||||||
int pageno = 0;
|
int pageno = 0;
|
||||||
for (std::vector<QPDFPageObjectHelper>::iterator iter = pages.begin();
|
for (auto& page : QPDFPageDocumentHelper(pdf).getAllPages())
|
||||||
iter != pages.end(); ++iter)
|
|
||||||
{
|
{
|
||||||
QPDFPageObjectHelper& ph(*iter);
|
|
||||||
++pageno;
|
++pageno;
|
||||||
// Pass the contents of a page through our string counter.
|
// Pass the contents of a page through our string counter.
|
||||||
// If it's an even page, capture the output. This
|
// If it's an even page, capture the output. This
|
||||||
@ -107,14 +103,14 @@ int main(int argc, char* argv[])
|
|||||||
if (pageno % 2)
|
if (pageno % 2)
|
||||||
{
|
{
|
||||||
// Ignore output for odd pages.
|
// Ignore output for odd pages.
|
||||||
ph.filterContents(&counter);
|
page.filterContents(&counter);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Write output to stdout for even pages.
|
// Write output to stdout for even pages.
|
||||||
Pl_StdioFile out("stdout", stdout);
|
Pl_StdioFile out("stdout", stdout);
|
||||||
std::cout << "% Contents of page " << pageno << std::endl;
|
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 << "\n% end " << pageno << std::endl;
|
||||||
}
|
}
|
||||||
std::cout << "Page " << pageno
|
std::cout << "Page " << pageno
|
||||||
|
Loading…
Reference in New Issue
Block a user