mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-03 15:17:29 +00:00
QPDFJob: begin configuration API with verbose
This commit is contained in:
parent
160e869d1e
commit
79187e585a
@ -97,6 +97,30 @@ class QPDFJob
|
|||||||
QPDF_DLL
|
QPDF_DLL
|
||||||
bool createsOutput() const;
|
bool createsOutput() const;
|
||||||
|
|
||||||
|
// CONFIGURATION
|
||||||
|
// (implemented in QPDFJob_config.cc)
|
||||||
|
|
||||||
|
// Configuration is performed by calling methods XXX QXXXQ document
|
||||||
|
class Config
|
||||||
|
{
|
||||||
|
friend class QPDFJob;
|
||||||
|
public:
|
||||||
|
QPDF_DLL
|
||||||
|
Config& verbose(bool);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Config() = delete;
|
||||||
|
Config(QPDFJob& job) :
|
||||||
|
o(job)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
QPDFJob& o;
|
||||||
|
};
|
||||||
|
friend class Config;
|
||||||
|
|
||||||
|
QPDF_DLL
|
||||||
|
Config config();
|
||||||
|
|
||||||
// QXXXQ set options -- implemented in QPDFJob_options.cc
|
// QXXXQ set options -- implemented in QPDFJob_options.cc
|
||||||
|
|
||||||
// QXXXQ these will not be in the final interface
|
// QXXXQ these will not be in the final interface
|
||||||
@ -220,7 +244,6 @@ class QPDFJob
|
|||||||
bool linearize;
|
bool linearize;
|
||||||
bool decrypt;
|
bool decrypt;
|
||||||
int split_pages;
|
int split_pages;
|
||||||
bool verbose;
|
|
||||||
bool progress;
|
bool progress;
|
||||||
bool suppress_warnings;
|
bool suppress_warnings;
|
||||||
bool warnings_exit_zero;
|
bool warnings_exit_zero;
|
||||||
@ -410,6 +433,7 @@ class QPDFJob
|
|||||||
std::ostream* cout;
|
std::ostream* cout;
|
||||||
std::ostream* cerr;
|
std::ostream* cerr;
|
||||||
unsigned long encryption_status;
|
unsigned long encryption_status;
|
||||||
|
bool verbose;
|
||||||
};
|
};
|
||||||
std::shared_ptr<Members> m;
|
std::shared_ptr<Members> m;
|
||||||
};
|
};
|
||||||
|
@ -324,7 +324,8 @@ QPDFJob::Members::Members() :
|
|||||||
warnings(false),
|
warnings(false),
|
||||||
cout(&std::cout),
|
cout(&std::cout),
|
||||||
cerr(&std::cerr),
|
cerr(&std::cerr),
|
||||||
encryption_status(0)
|
encryption_status(0),
|
||||||
|
verbose(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,7 +334,6 @@ QPDFJob::QPDFJob() :
|
|||||||
linearize(false),
|
linearize(false),
|
||||||
decrypt(false),
|
decrypt(false),
|
||||||
split_pages(0),
|
split_pages(0),
|
||||||
verbose(false),
|
|
||||||
progress(false),
|
progress(false),
|
||||||
suppress_warnings(false),
|
suppress_warnings(false),
|
||||||
warnings_exit_zero(false),
|
warnings_exit_zero(false),
|
||||||
@ -447,12 +447,18 @@ void
|
|||||||
QPDFJob::doIfVerbose(
|
QPDFJob::doIfVerbose(
|
||||||
std::function<void(std::ostream&, std::string const& prefix)> fn)
|
std::function<void(std::ostream&, std::string const& prefix)> fn)
|
||||||
{
|
{
|
||||||
if (this->verbose && (this->m->cout != nullptr))
|
if (this->m->verbose && (this->m->cout != nullptr))
|
||||||
{
|
{
|
||||||
fn(*(this->m->cout), this->m->message_prefix);
|
fn(*(this->m->cout), this->m->message_prefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPDFJob::Config
|
||||||
|
QPDFJob::config()
|
||||||
|
{
|
||||||
|
return Config(*this);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QPDFJob::run()
|
QPDFJob::run()
|
||||||
{
|
{
|
||||||
@ -596,7 +602,7 @@ QPDFJob::checkConfiguration()
|
|||||||
usage("--split-pages may not be used when"
|
usage("--split-pages may not be used when"
|
||||||
" writing to standard output");
|
" writing to standard output");
|
||||||
}
|
}
|
||||||
if (o.verbose)
|
if (this->m->verbose)
|
||||||
{
|
{
|
||||||
usage("--verbose may not be used when"
|
usage("--verbose may not be used when"
|
||||||
" writing to standard output");
|
" writing to standard output");
|
||||||
|
@ -26,7 +26,7 @@ namespace
|
|||||||
class ArgParser
|
class ArgParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ArgParser(QPDFArgParser& ap, QPDFJob& o);
|
ArgParser(QPDFArgParser& ap, QPDFJob::Config& jc, QPDFJob& o);
|
||||||
void parseOptions();
|
void parseOptions();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -42,14 +42,16 @@ namespace
|
|||||||
|
|
||||||
QPDFArgParser ap;
|
QPDFArgParser ap;
|
||||||
QPDFJob& o;
|
QPDFJob& o;
|
||||||
|
QPDFJob::Config& jc;
|
||||||
std::vector<char*> accumulated_args; // points to member in ap
|
std::vector<char*> accumulated_args; // points to member in ap
|
||||||
char* pages_password;
|
char* pages_password;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ArgParser::ArgParser(QPDFArgParser& ap, QPDFJob& o) :
|
ArgParser::ArgParser(QPDFArgParser& ap, QPDFJob::Config& jc, QPDFJob& o) :
|
||||||
ap(ap),
|
ap(ap),
|
||||||
o(o),
|
o(o),
|
||||||
|
jc(jc),
|
||||||
pages_password(nullptr)
|
pages_password(nullptr)
|
||||||
{
|
{
|
||||||
initOptionTables();
|
initOptionTables();
|
||||||
@ -803,7 +805,7 @@ void
|
|||||||
ArgParser::argVerbose()
|
ArgParser::argVerbose()
|
||||||
{
|
{
|
||||||
// QXXXQ @TRIVIAL
|
// QXXXQ @TRIVIAL
|
||||||
o.verbose = true;
|
jc.verbose(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1558,7 +1560,8 @@ QPDFJob::initializeFromArgv(int argc, char* argv[], char const* progname_env)
|
|||||||
}
|
}
|
||||||
QPDFArgParser qap(argc, argv, progname_env);
|
QPDFArgParser qap(argc, argv, progname_env);
|
||||||
setMessagePrefix(qap.getProgname());
|
setMessagePrefix(qap.getProgname());
|
||||||
ArgParser ap(qap, *this);
|
auto jc = config();
|
||||||
|
ArgParser ap(qap, jc, *this);
|
||||||
ap.parseOptions();
|
ap.parseOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +1,8 @@
|
|||||||
#include <qpdf/QPDFJob.hh>
|
#include <qpdf/QPDFJob.hh>
|
||||||
|
|
||||||
|
QPDFJob::Config&
|
||||||
|
QPDFJob::Config::verbose(bool)
|
||||||
|
{
|
||||||
|
o.m->verbose = true;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user