summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-01-03 18:16:16 +0100
committerJay Berkenbilt <ejb@ql.org>2022-01-30 19:11:03 +0100
commit1ddf5b4b4bbc3c00c51aba51ff67be47736f6e88 (patch)
treea398b4fd36e20ff7ae9435d9587e9891a1242e85 /include
parent0910e767ad5609c2efcf65ddc80a5b7bede434d0 (diff)
downloadqpdf-1ddf5b4b4bbc3c00c51aba51ff67be47736f6e88.tar.zst
QPDFJob increment: get rid of exit, handle verbose
Remove all calls to exit() from QPDFJob. Handle code that runs in verbose mode to enable it to make use of output streams and message prefix (whoami) from QPDFJob. This removes temporarily duplicated exit code logic and most access to whoami/std::cout outside of QPDFJob proper.
Diffstat (limited to 'include')
-rw-r--r--include/qpdf/QPDFJob.hh25
1 files changed, 22 insertions, 3 deletions
diff --git a/include/qpdf/QPDFJob.hh b/include/qpdf/QPDFJob.hh
index 03b6aa21..89be7c2c 100644
--- a/include/qpdf/QPDFJob.hh
+++ b/include/qpdf/QPDFJob.hh
@@ -33,6 +33,7 @@
#include <set>
#include <map>
#include <iostream>
+#include <functional>
class QPDFWriter;
@@ -42,9 +43,23 @@ class QPDFJob
QPDF_DLL
QPDFJob();
+ // Set name that is used to prefix verbose messages, progress
+ // messages, and other things that the library writes to output
+ // and error streams on the caller's behalf. Defaults to "qpdf".
+ QPDF_DLL
+ void setMessagePrefix(std::string const&);
+
+ // Override streams that errors and output go to. Defaults are
+ // std::cout and std::cerr.
QPDF_DLL
void setOutputStreams(std::ostream* out_stream, std::ostream* err_stream);
+ // If in verbose mode, call the given function, passing in the
+ // output stream and message prefix.
+ QPDF_DLL
+ void doIfVerbose(
+ std::function<void(std::ostream&, std::string const& prefix)> fn);
+
QPDF_DLL
void run();
@@ -63,14 +78,13 @@ class QPDFJob
QPDF_DLL
bool checkIsEncrypted();
-
// Return value is bitwise OR of values from qpdf_encryption_status_e
QPDF_DLL
unsigned long getEncryptionStatus();
- // QXXXQ From here to END-PUBLIC should all be private
+ // QXXXQ From here to END-PUBLIC should all be private or
+ // different somehow
public:
-
QPDF_DLL
static JSON json_schema(std::set<std::string>* keys = 0);
QPDF_DLL
@@ -165,6 +179,10 @@ class QPDFJob
void setWriterOptions(QPDF& pdf, QPDFWriter& w);
void doSplitPages(QPDF& pdf, bool& warnings);
void writeOutfile(QPDF& pdf);
+ void doJSON(QPDF& pdf);
+ void doInspection(QPDF& pdf);
+ void showEncryption(QPDF& pdf);
+ void doCheck(QPDF& pdf);
enum remove_unref_e { re_auto, re_yes, re_no };
@@ -295,6 +313,7 @@ class QPDFJob
Members();
Members(Members const&) = delete;
+ std::string whoami;
bool warnings;
bool creates_output;
std::ostream* out_stream;