aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qpdf-job.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/qpdf-job.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/qpdf-job.cc')
-rw-r--r--examples/qpdf-job.cc50
1 files changed, 19 insertions, 31 deletions
diff --git a/examples/qpdf-job.cc b/examples/qpdf-job.cc
index ecebca3b..b71b612a 100644
--- a/examples/qpdf-job.cc
+++ b/examples/qpdf-job.cc
@@ -1,34 +1,32 @@
+#include <qpdf/QIntC.hh>
#include <qpdf/QPDFJob.hh>
#include <qpdf/QUtil.hh>
-#include <qpdf/QIntC.hh>
-#include <iostream>
#include <cstring>
+#include <iostream>
// This program is a simple demonstration of different ways to use the
// QPDFJob API.
static char const* whoami = 0;
-static void usage()
+static void
+usage()
{
- std::cerr
- << "Usage: " << whoami << std::endl
- << "This program linearizes the first page of in.pdf to out1.pdf,"
- << " out2.pdf, and"
- << std::endl
- << " out3.pdf, each demonstrating a different way to use the"
- << " QPDFJob API"
- << std::endl;
+ std::cerr << "Usage: " << whoami << std::endl
+ << "This program linearizes the first page of in.pdf to out1.pdf,"
+ << " out2.pdf, and" << std::endl
+ << " out3.pdf, each demonstrating a different way to use the"
+ << " QPDFJob API" << std::endl;
exit(2);
}
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
whoami = QUtil::getWhoami(argv[0]);
- if (argc != 1)
- {
+ if (argc != 1) {
usage();
}
@@ -39,8 +37,7 @@ int main(int argc, char* argv[])
// Note that staticId is used for testing only.
- try
- {
+ try {
// Use the config API
QPDFJob j;
j.config()
@@ -54,15 +51,12 @@ int main(int argc, char* argv[])
->checkConfiguration();
j.run();
std::cout << "out1 status: " << j.getExitCode() << std::endl;
- }
- catch (std::exception& e)
- {
+ } catch (std::exception& e) {
std::cerr << "exception: " << e.what() << std::endl;
return 2;
}
- try
- {
+ try {
char const* new_argv[] = {
whoami,
"in.pdf",
@@ -73,21 +67,17 @@ int main(int argc, char* argv[])
"1",
"--",
"--static-id",
- nullptr
- };
+ nullptr};
QPDFJob j;
j.initializeFromArgv(new_argv);
j.run();
std::cout << "out2 status: " << j.getExitCode() << std::endl;
- }
- catch (std::exception& e)
- {
+ } catch (std::exception& e) {
std::cerr << "exception: " << e.what() << std::endl;
return 2;
}
- try
- {
+ try {
// Use the JSON API
QPDFJob j;
j.initializeFromJson(R"({
@@ -105,9 +95,7 @@ int main(int argc, char* argv[])
)");
j.run();
std::cout << "out3 status: " << j.getExitCode() << std::endl;
- }
- catch (std::exception& e)
- {
+ } catch (std::exception& e) {
std::cerr << "exception: " << e.what() << std::endl;
return 2;
}