mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 19:08:59 +00:00
Reformat code
This commit is contained in:
parent
7836e19747
commit
6c4537885e
@ -88,8 +88,7 @@ main(int argc, char* argv[])
|
|||||||
l, qpdf_log_dest_custom, save_to_file, (void*)outfile, 0);
|
l, qpdf_log_dest_custom, save_to_file, (void*)outfile, 0);
|
||||||
qpdflogger_cleanup(&l);
|
qpdflogger_cleanup(&l);
|
||||||
j = qpdfjob_init();
|
j = qpdfjob_init();
|
||||||
status = (qpdfjob_initialize_from_argv(j, j_argv) ||
|
status = (qpdfjob_initialize_from_argv(j, j_argv) || qpdfjob_run(j));
|
||||||
qpdfjob_run(j));
|
|
||||||
qpdfjob_cleanup(&j);
|
qpdfjob_cleanup(&j);
|
||||||
free(attachment_arg);
|
free(attachment_arg);
|
||||||
fclose(outfile);
|
fclose(outfile);
|
||||||
|
@ -465,7 +465,8 @@ QPDFJob::setOutputStreams(std::ostream* out, std::ostream* err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QPDFJob::registerProgressReporter(std::function<void(int)> handler) {
|
QPDFJob::registerProgressReporter(std::function<void(int)> handler)
|
||||||
|
{
|
||||||
this->m->progress_handler = handler;
|
this->m->progress_handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1239,8 +1240,8 @@ QPDFJob::doJSONPageLabels(Pipeline* p, bool& first, QPDF& pdf)
|
|||||||
{
|
{
|
||||||
JSON j_labels = JSON::makeArray();
|
JSON j_labels = JSON::makeArray();
|
||||||
QPDFPageLabelDocumentHelper pldh(pdf);
|
QPDFPageLabelDocumentHelper pldh(pdf);
|
||||||
long long npages = QIntC::to_longlong(
|
long long npages =
|
||||||
QPDFPageDocumentHelper(pdf).getAllPages().size());
|
QIntC::to_longlong(QPDFPageDocumentHelper(pdf).getAllPages().size());
|
||||||
if (pldh.hasPageLabels()) {
|
if (pldh.hasPageLabels()) {
|
||||||
std::vector<QPDFObjectHandle> labels;
|
std::vector<QPDFObjectHandle> labels;
|
||||||
pldh.getLabelsForPageRange(0, npages - 1, 0, labels);
|
pldh.getLabelsForPageRange(0, npages - 1, 0, labels);
|
||||||
|
@ -85,7 +85,8 @@ qpdfjob_run(qpdfjob_handle j)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static int run_with_handle(std::function<int(qpdfjob_handle)> fn)
|
static int
|
||||||
|
run_with_handle(std::function<int(qpdfjob_handle)> fn)
|
||||||
{
|
{
|
||||||
auto j = qpdfjob_init();
|
auto j = qpdfjob_init();
|
||||||
int status = fn(j);
|
int status = fn(j);
|
||||||
@ -96,7 +97,8 @@ static int run_with_handle(std::function<int(qpdfjob_handle)> fn)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qpdfjob_run_from_argv(char const* const argv[])
|
int
|
||||||
|
qpdfjob_run_from_argv(char const* const argv[])
|
||||||
{
|
{
|
||||||
return run_with_handle([argv](qpdfjob_handle j) {
|
return run_with_handle([argv](qpdfjob_handle j) {
|
||||||
return qpdfjob_initialize_from_argv(j, argv);
|
return qpdfjob_initialize_from_argv(j, argv);
|
||||||
@ -113,7 +115,8 @@ qpdfjob_run_from_wide_argv(wchar_t const* const argv[])
|
|||||||
}
|
}
|
||||||
#endif /* QPDF_NO_WCHAR_T */
|
#endif /* QPDF_NO_WCHAR_T */
|
||||||
|
|
||||||
int qpdfjob_run_from_json(char const* json)
|
int
|
||||||
|
qpdfjob_run_from_json(char const* json)
|
||||||
{
|
{
|
||||||
return run_with_handle([json](qpdfjob_handle j) {
|
return run_with_handle([json](qpdfjob_handle j) {
|
||||||
return qpdfjob_initialize_from_json(j, json);
|
return qpdfjob_initialize_from_json(j, json);
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
#include <qpdf/assert_test.h>
|
#include <qpdf/assert_test.h>
|
||||||
|
|
||||||
|
#include <qpdf/Pl_Base64.hh>
|
||||||
#include <qpdf/Pl_Function.hh>
|
#include <qpdf/Pl_Function.hh>
|
||||||
#include <qpdf/Pl_String.hh>
|
#include <qpdf/Pl_String.hh>
|
||||||
#include <qpdf/Pl_Base64.hh>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char* argv[])
|
main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
Pl_Function p1(
|
Pl_Function p1("p1", nullptr, [](unsigned char const* data, size_t len) {
|
||||||
"p1", nullptr, [](unsigned char const* data, size_t len) {
|
|
||||||
std::cout << "p1: " << len << ": " << data << std::endl;
|
std::cout << "p1: " << len << ": " << data << std::endl;
|
||||||
});
|
});
|
||||||
p1.write(reinterpret_cast<unsigned char const*>("potato"), 6);
|
p1.write(reinterpret_cast<unsigned char const*>("potato"), 6);
|
||||||
@ -17,8 +16,7 @@ main(int argc, char* argv[])
|
|||||||
std::string s;
|
std::string s;
|
||||||
Pl_String ps("string", nullptr, s);
|
Pl_String ps("string", nullptr, s);
|
||||||
Pl_Base64 b("base64", &ps, Pl_Base64::a_encode);
|
Pl_Base64 b("base64", &ps, Pl_Base64::a_encode);
|
||||||
Pl_Function p2(
|
Pl_Function p2("p2", &b, [](unsigned char const* data, size_t len) {
|
||||||
"p2", &b, [](unsigned char const* data, size_t len) {
|
|
||||||
std::cout << "p2: " << len << ": " << data << std::endl;
|
std::cout << "p2: " << len << ": " << data << std::endl;
|
||||||
});
|
});
|
||||||
p2.write(reinterpret_cast<unsigned char const*>("salad"), 5);
|
p2.write(reinterpret_cast<unsigned char const*>("salad"), 5);
|
||||||
|
Loading…
Reference in New Issue
Block a user