aboutsummaryrefslogtreecommitdiffstats
path: root/examples/pdf-split-pages.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-04-02 23:14:10 +0200
committerJay Berkenbilt <ejb@ql.org>2022-04-04 14:10:40 +0200
commit12f1eb15ca3fed6310402847559a7c99d3c77847 (patch)
tree8935675b623c6f3b4914b8b44f7fa5f2816a9241 /examples/pdf-split-pages.cc
parentf20fa61eb4c323eb1642c69c236b3d9a1f8b2cdb (diff)
downloadqpdf-12f1eb15ca3fed6310402847559a7c99d3c77847.tar.zst
Programmatically apply new formatting to code
Run this: for i in **/*.cc **/*.c **/*.h **/*.hh; do clang-format < $i >| $i.new && mv $i.new $i done
Diffstat (limited to 'examples/pdf-split-pages.cc')
-rw-r--r--examples/pdf-split-pages.cc35
1 files changed, 15 insertions, 20 deletions
diff --git a/examples/pdf-split-pages.cc b/examples/pdf-split-pages.cc
index c79177ee..a8e65260 100644
--- a/examples/pdf-split-pages.cc
+++ b/examples/pdf-split-pages.cc
@@ -4,22 +4,21 @@
// does.
//
+#include <qpdf/QIntC.hh>
#include <qpdf/QPDF.hh>
#include <qpdf/QPDFPageDocumentHelper.hh>
#include <qpdf/QPDFWriter.hh>
#include <qpdf/QUtil.hh>
-#include <qpdf/QIntC.hh>
+#include <cstring>
#include <iostream>
#include <stdlib.h>
#include <string>
-#include <cstring>
static bool static_id = false;
-static void process(char const* whoami,
- char const* infile,
- std::string outprefix)
+static void
+process(char const* whoami, char const* infile, std::string outprefix)
{
QPDF inpdf;
inpdf.processFile(infile);
@@ -29,8 +28,8 @@ static void process(char const* whoami,
QIntC::to_int(QUtil::uint_to_string(pages.size()).length());
int pageno = 0;
for (std::vector<QPDFPageObjectHelper>::iterator iter = pages.begin();
- iter != pages.end(); ++iter)
- {
+ iter != pages.end();
+ ++iter) {
QPDFPageObjectHelper& page(*iter);
std::string outfile =
outprefix + QUtil::int_to_string(++pageno, pageno_len) + ".pdf";
@@ -38,8 +37,7 @@ static void process(char const* whoami,
outpdf.emptyPDF();
QPDFPageDocumentHelper(outpdf).addPage(page, false);
QPDFWriter outpdfw(outpdf, outfile.c_str());
- if (static_id)
- {
+ if (static_id) {
// For the test suite, uncompress streams and use static
// IDs.
outpdfw.setStaticID(true); // for testing only
@@ -49,34 +47,31 @@ static void process(char const* whoami,
}
}
-void usage(char const* whoami)
+void
+usage(char const* whoami)
{
std::cerr << "Usage: " << whoami << " infile outprefix" << std::endl;
exit(2);
}
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
char const* whoami = QUtil::getWhoami(argv[0]);
// For test suite
- if ((argc > 1) && (strcmp(argv[1], " --static-id") == 0))
- {
+ if ((argc > 1) && (strcmp(argv[1], " --static-id") == 0)) {
static_id = true;
--argc;
++argv;
}
- if (argc != 3)
- {
+ if (argc != 3) {
usage(whoami);
}
- try
- {
+ try {
process(whoami, argv[1], argv[2]);
- }
- catch (std::exception const& e)
- {
+ } catch (std::exception const& e) {
std::cerr << whoami << ": exception: " << e.what() << std::endl;
return 2;
}