From b42f3e1d15203927776a5b0954782287c901300f Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Tue, 1 Feb 2022 07:28:26 -0500 Subject: Move more code from qpdf.cc into QPDFJob --- include/qpdf/QPDFJob.hh | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/qpdf/QPDFJob.hh b/include/qpdf/QPDFJob.hh index 64075bc1..e16e5ca1 100644 --- a/include/qpdf/QPDFJob.hh +++ b/include/qpdf/QPDFJob.hh @@ -43,6 +43,13 @@ class QPDFWriter; class QPDFJob { public: + // Exit codes -- returned by getExitCode() after calling run() + static int constexpr EXIT_ERROR = 2; + static int constexpr EXIT_WARNING = 3; + // For is-encrypted and requires-password + static int constexpr EXIT_IS_NOT_ENCRYPTED = 2; + static int constexpr EXIT_CORRECT_PASSWORD = 3; + // QPDFUsage is thrown if there are any usage-like errors when // calling Config methods. QPDF_DLL @@ -345,17 +352,6 @@ class QPDFJob QPDF_DLL std::shared_ptr config(); - // Options for helping the qpdf CLI use the correct edit code and - // properly report warnings. - QPDF_DLL - bool suppressWarnings(); - QPDF_DLL - bool warningsExitZero(); - QPDF_DLL - bool checkRequiresPassword(); - QPDF_DLL - bool checkIsEncrypted(); - // Execute the job QPDF_DLL void run(); @@ -364,7 +360,17 @@ class QPDFJob // run() is called. QPDF_DLL - bool hasWarnings(); + bool hasWarnings() const; + + // Return one of the EXIT_* constants defined at the top of the + // class declaration. This may be called after run() when run() + // did not throw an exception. Takes into consideration whether + // isEncrypted or requiresPassword was called. Note that this + // function does not know whether run() threw an exception, so + // code that uses this to determine how to exit should explicitly + // use EXIT_ERROR if run() threw an exception. + QPDF_DLL + int getExitCode() const; // Return value is bitwise OR of values from qpdf_encryption_status_e QPDF_DLL -- cgit v1.2.3-54-g00ecf