mirror of
https://github.com/qpdf/qpdf.git
synced 2024-05-31 17:30:54 +00:00
QPDFJob: de-templatize do_process and do_process_once
This commit is contained in:
parent
2f631997f2
commit
e2975b9ed0
|
@ -1830,11 +1830,9 @@ ImageOptimizer::provideStreamData(int, int, Pipeline* pipeline)
|
||||||
false, false);
|
false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
static PointerHolder<QPDF> do_process_once(
|
static PointerHolder<QPDF> do_process_once(
|
||||||
void (QPDF::*fn)(T, char const*),
|
std::function<void(QPDF*, char const*)> fn,
|
||||||
T item, char const* password,
|
char const* password, QPDFJob& o, bool empty)
|
||||||
QPDFJob& o, bool empty)
|
|
||||||
{
|
{
|
||||||
PointerHolder<QPDF> pdf = new QPDF;
|
PointerHolder<QPDF> pdf = new QPDF;
|
||||||
set_qpdf_options(*pdf, o);
|
set_qpdf_options(*pdf, o);
|
||||||
|
@ -1844,16 +1842,14 @@ static PointerHolder<QPDF> do_process_once(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
((*pdf).*fn)(item, password);
|
fn(pdf.getPointer(), password);
|
||||||
}
|
}
|
||||||
return pdf;
|
return pdf;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
static PointerHolder<QPDF> do_process(
|
static PointerHolder<QPDF> do_process(
|
||||||
void (QPDF::*fn)(T, char const*),
|
std::function<void(QPDF*, char const*)> fn,
|
||||||
T item, char const* password,
|
char const* password, QPDFJob& o, bool empty)
|
||||||
QPDFJob& o, bool empty)
|
|
||||||
{
|
{
|
||||||
// If a password has been specified but doesn't work, try other
|
// If a password has been specified but doesn't work, try other
|
||||||
// passwords that are equivalent in different character encodings.
|
// passwords that are equivalent in different character encodings.
|
||||||
|
@ -1882,7 +1878,7 @@ static PointerHolder<QPDF> do_process(
|
||||||
{
|
{
|
||||||
// There is no password, or we're not doing recovery, so just
|
// There is no password, or we're not doing recovery, so just
|
||||||
// do the normal processing with the supplied password.
|
// do the normal processing with the supplied password.
|
||||||
return do_process_once(fn, item, password, o, empty);
|
return do_process_once(fn, password, o, empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a list of otherwise encoded strings. Keep in scope for this
|
// Get a list of otherwise encoded strings. Keep in scope for this
|
||||||
|
@ -1916,7 +1912,7 @@ static PointerHolder<QPDF> do_process(
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return do_process_once(fn, item, *iter, o, empty);
|
return do_process_once(fn, *iter, o, empty);
|
||||||
}
|
}
|
||||||
catch (QPDFExc& e)
|
catch (QPDFExc& e)
|
||||||
{
|
{
|
||||||
|
@ -1946,14 +1942,19 @@ PointerHolder<QPDF>
|
||||||
QPDFJob::processFile(char const* filename, char const* password)
|
QPDFJob::processFile(char const* filename, char const* password)
|
||||||
{
|
{
|
||||||
QPDFJob& o = *this; // QXXXQ
|
QPDFJob& o = *this; // QXXXQ
|
||||||
return do_process(&QPDF::processFile, filename, password, o,
|
auto f1 = std::mem_fn<void(char const*, char const*)>(&QPDF::processFile);
|
||||||
strcmp(filename, "") == 0);
|
auto fn = std::bind(
|
||||||
|
f1, std::placeholders::_1, filename, std::placeholders::_2);
|
||||||
|
return do_process(fn, password, o, strcmp(filename, "") == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PointerHolder<QPDF> process_input_source(
|
static PointerHolder<QPDF> process_input_source(
|
||||||
PointerHolder<InputSource> is, char const* password, QPDFJob& o)
|
PointerHolder<InputSource> is, char const* password, QPDFJob& o)
|
||||||
{
|
{
|
||||||
return do_process(&QPDF::processInputSource, is, password, o, false);
|
auto f1 = std::mem_fn(&QPDF::processInputSource);
|
||||||
|
auto fn = std::bind(
|
||||||
|
f1, std::placeholders::_1, is, std::placeholders::_2);
|
||||||
|
return do_process(fn, password, o, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue
Block a user