Commit 03f3369f35b2303166e8d36547c8a0aba6626c1b
1 parent
9013b7ca
QPDFJob: use manually named end functions for Config classes
Use named functions rather than just end() for clarity.
Showing
11 changed files
with
34 additions
and
32 deletions
generate_auto_job
| @@ -72,13 +72,10 @@ class Main: | @@ -72,13 +72,10 @@ class Main: | ||
| 72 | self.config_decls = {} | 72 | self.config_decls = {} |
| 73 | self.declared_configs = set() | 73 | self.declared_configs = set() |
| 74 | for o in data['options']: | 74 | for o in data['options']: |
| 75 | - table = o['table'] | ||
| 76 | config = o.get('config', None) | 75 | config = o.get('config', None) |
| 77 | if config is not None: | 76 | if config is not None: |
| 78 | self.DESTS[config] = f'include/qpdf/auto_job_{config}.hh' | 77 | self.DESTS[config] = f'include/qpdf/auto_job_{config}.hh' |
| 79 | self.config_decls[config] = [] | 78 | self.config_decls[config] = [] |
| 80 | - if table != 'main': | ||
| 81 | - self.config_decls[config].append('QPDF_DLL Config& end();') | ||
| 82 | 79 | ||
| 83 | if self.check_hashes(): | 80 | if self.check_hashes(): |
| 84 | exit(0) | 81 | exit(0) |
| @@ -314,11 +311,11 @@ class Main: | @@ -314,11 +311,11 @@ class Main: | ||
| 314 | 311 | ||
| 315 | # Generate declarations for config methods separately by | 312 | # Generate declarations for config methods separately by |
| 316 | # config object. | 313 | # config object. |
| 317 | - config_class = prefix + 'Config' | 314 | + config_prefix = prefix + 'Config' |
| 318 | arg = '' | 315 | arg = '' |
| 319 | if decl_arg: | 316 | if decl_arg: |
| 320 | arg = 'char const* parameter' | 317 | arg = 'char const* parameter' |
| 321 | - fn = f'{config_class}& {identifier}({arg})' | 318 | + fn = f'{config_prefix}& {identifier}({arg})' |
| 322 | if fn not in self.declared_configs: | 319 | if fn not in self.declared_configs: |
| 323 | self.declared_configs.add(fn) | 320 | self.declared_configs.add(fn) |
| 324 | self.config_decls[cfg].append(f'QPDF_DLL {fn};') | 321 | self.config_decls[cfg].append(f'QPDF_DLL {fn};') |
| @@ -430,7 +427,7 @@ class Main: | @@ -430,7 +427,7 @@ class Main: | ||
| 430 | self.handle_flag(i, identifier, kind, v) | 427 | self.handle_flag(i, identifier, kind, v) |
| 431 | else: | 428 | else: |
| 432 | identifier = self.to_identifier(i, '', False) | 429 | identifier = self.to_identifier(i, '', False) |
| 433 | - prefix = o.get('config_class', table_prefix) | 430 | + prefix = o.get('config_prefix', table_prefix) |
| 434 | self.handle_trivial( | 431 | self.handle_trivial( |
| 435 | i, identifier, config, prefix, kind, v) | 432 | i, identifier, config, prefix, kind, v) |
| 436 | 433 | ||
| @@ -523,7 +520,7 @@ class Main: | @@ -523,7 +520,7 @@ class Main: | ||
| 523 | ['choices', 'options', 'no-json', 'json'])) | 520 | ['choices', 'options', 'no-json', 'json'])) |
| 524 | for o in data['options']: | 521 | for o in data['options']: |
| 525 | self.check_keys('top', o, set( | 522 | self.check_keys('top', o, set( |
| 526 | - ['table', 'prefix', 'config', 'config_class', | 523 | + ['table', 'prefix', 'config', 'config_prefix', |
| 527 | 'manual', 'bare', 'positional', | 524 | 'manual', 'bare', 'positional', |
| 528 | 'optional_parameter', 'required_parameter', | 525 | 'optional_parameter', 'required_parameter', |
| 529 | 'required_choices', 'optional_choices'])) | 526 | 'required_choices', 'optional_choices'])) |
include/qpdf/QPDFJob.hh
| @@ -154,6 +154,8 @@ class QPDFJob | @@ -154,6 +154,8 @@ class QPDFJob | ||
| 154 | friend class Config; | 154 | friend class Config; |
| 155 | public: | 155 | public: |
| 156 | QPDF_DLL | 156 | QPDF_DLL |
| 157 | + Config& endAddAttachment(); | ||
| 158 | + QPDF_DLL | ||
| 157 | AttConfig& path(char const* parameter); | 159 | AttConfig& path(char const* parameter); |
| 158 | 160 | ||
| 159 | # include <qpdf/auto_job_c_att.hh> | 161 | # include <qpdf/auto_job_c_att.hh> |
| @@ -172,6 +174,8 @@ class QPDFJob | @@ -172,6 +174,8 @@ class QPDFJob | ||
| 172 | friend class Config; | 174 | friend class Config; |
| 173 | public: | 175 | public: |
| 174 | QPDF_DLL | 176 | QPDF_DLL |
| 177 | + Config& endCopyAttachmentsFrom(); | ||
| 178 | + QPDF_DLL | ||
| 175 | CopyAttConfig& path(char const* parameter); | 179 | CopyAttConfig& path(char const* parameter); |
| 176 | 180 | ||
| 177 | # include <qpdf/auto_job_c_copy_att.hh> | 181 | # include <qpdf/auto_job_c_copy_att.hh> |
| @@ -190,6 +194,8 @@ class QPDFJob | @@ -190,6 +194,8 @@ class QPDFJob | ||
| 190 | friend class Config; | 194 | friend class Config; |
| 191 | public: | 195 | public: |
| 192 | QPDF_DLL | 196 | QPDF_DLL |
| 197 | + Config& endPages(); | ||
| 198 | + QPDF_DLL | ||
| 193 | PagesConfig& pageSpec(std::string const& filename, | 199 | PagesConfig& pageSpec(std::string const& filename, |
| 194 | std::string const& range, | 200 | std::string const& range, |
| 195 | char const* password = nullptr); | 201 | char const* password = nullptr); |
| @@ -209,6 +215,8 @@ class QPDFJob | @@ -209,6 +215,8 @@ class QPDFJob | ||
| 209 | friend class Config; | 215 | friend class Config; |
| 210 | public: | 216 | public: |
| 211 | QPDF_DLL | 217 | QPDF_DLL |
| 218 | + Config& endUnderlayOverlay(); | ||
| 219 | + QPDF_DLL | ||
| 212 | UOConfig& path(char const* parameter); | 220 | UOConfig& path(char const* parameter); |
| 213 | 221 | ||
| 214 | # include <qpdf/auto_job_c_uo.hh> | 222 | # include <qpdf/auto_job_c_uo.hh> |
| @@ -226,6 +234,8 @@ class QPDFJob | @@ -226,6 +234,8 @@ class QPDFJob | ||
| 226 | friend class Config; | 234 | friend class Config; |
| 227 | public: | 235 | public: |
| 228 | QPDF_DLL | 236 | QPDF_DLL |
| 237 | + Config& endEncrypt(); | ||
| 238 | + QPDF_DLL | ||
| 229 | EncConfig& path(char const* parameter); | 239 | EncConfig& path(char const* parameter); |
| 230 | 240 | ||
| 231 | # include <qpdf/auto_job_c_enc.hh> | 241 | # include <qpdf/auto_job_c_enc.hh> |
include/qpdf/auto_job_c_att.hh
| @@ -3,7 +3,6 @@ | @@ -3,7 +3,6 @@ | ||
| 3 | // Edits will be automatically overwritten if the build is | 3 | // Edits will be automatically overwritten if the build is |
| 4 | // run in maintainer mode. | 4 | // run in maintainer mode. |
| 5 | // | 5 | // |
| 6 | -QPDF_DLL Config& end(); | ||
| 7 | QPDF_DLL AttConfig& replace(); | 6 | QPDF_DLL AttConfig& replace(); |
| 8 | QPDF_DLL AttConfig& key(char const* parameter); | 7 | QPDF_DLL AttConfig& key(char const* parameter); |
| 9 | QPDF_DLL AttConfig& filename(char const* parameter); | 8 | QPDF_DLL AttConfig& filename(char const* parameter); |
include/qpdf/auto_job_c_copy_att.hh
| @@ -3,6 +3,5 @@ | @@ -3,6 +3,5 @@ | ||
| 3 | // Edits will be automatically overwritten if the build is | 3 | // Edits will be automatically overwritten if the build is |
| 4 | // run in maintainer mode. | 4 | // run in maintainer mode. |
| 5 | // | 5 | // |
| 6 | -QPDF_DLL Config& end(); | ||
| 7 | QPDF_DLL CopyAttConfig& prefix(char const* parameter); | 6 | QPDF_DLL CopyAttConfig& prefix(char const* parameter); |
| 8 | QPDF_DLL CopyAttConfig& password(char const* parameter); | 7 | QPDF_DLL CopyAttConfig& password(char const* parameter); |
include/qpdf/auto_job_c_enc.hh
| @@ -3,7 +3,6 @@ | @@ -3,7 +3,6 @@ | ||
| 3 | // Edits will be automatically overwritten if the build is | 3 | // Edits will be automatically overwritten if the build is |
| 4 | // run in maintainer mode. | 4 | // run in maintainer mode. |
| 5 | // | 5 | // |
| 6 | -QPDF_DLL Config& end(); | ||
| 7 | QPDF_DLL EncConfig& extract(char const* parameter); | 6 | QPDF_DLL EncConfig& extract(char const* parameter); |
| 8 | QPDF_DLL EncConfig& annotate(char const* parameter); | 7 | QPDF_DLL EncConfig& annotate(char const* parameter); |
| 9 | QPDF_DLL EncConfig& print(char const* parameter); | 8 | QPDF_DLL EncConfig& print(char const* parameter); |
include/qpdf/auto_job_c_pages.hh
include/qpdf/auto_job_c_uo.hh
| @@ -3,7 +3,6 @@ | @@ -3,7 +3,6 @@ | ||
| 3 | // Edits will be automatically overwritten if the build is | 3 | // Edits will be automatically overwritten if the build is |
| 4 | // run in maintainer mode. | 4 | // run in maintainer mode. |
| 5 | // | 5 | // |
| 6 | -QPDF_DLL Config& end(); | ||
| 7 | QPDF_DLL UOConfig& to(char const* parameter); | 6 | QPDF_DLL UOConfig& to(char const* parameter); |
| 8 | QPDF_DLL UOConfig& from(char const* parameter); | 7 | QPDF_DLL UOConfig& from(char const* parameter); |
| 9 | QPDF_DLL UOConfig& repeat(char const* parameter); | 8 | QPDF_DLL UOConfig& repeat(char const* parameter); |
job.sums
| 1 | # Generated by generate_auto_job | 1 | # Generated by generate_auto_job |
| 2 | -generate_auto_job 207b392d0d199a6cc0e5eb52044e9adbc729323c9a58f9d547605272a0d9b29c | ||
| 3 | -include/qpdf/auto_job_c_att.hh ecc3f8f711b486b491e811176362a90c022eb225ff12157df3a10ca021be87b1 | ||
| 4 | -include/qpdf/auto_job_c_copy_att.hh caffae3d1faf2cd92a07ba77da638cce31da3e074a047918834195c0f3ed508a | ||
| 5 | -include/qpdf/auto_job_c_enc.hh e2e1a163a7ffebbf8af169dc4a28ab00df3b8d229864bca7d203dde8b56f0864 | 2 | +generate_auto_job 3108658e47e17655e761842cd76bab48fdaf5e9792942c8bf1ca03f6f1934809 |
| 3 | +include/qpdf/auto_job_c_att.hh 9d21a86169938a187c55e56e1ef915cd4211d13745c21d85c5c06306fd8ed023 | ||
| 4 | +include/qpdf/auto_job_c_copy_att.hh d954c29ca74ef2e3abf0a0d99446bb974585700750fad8cee31340cbf2304a94 | ||
| 5 | +include/qpdf/auto_job_c_enc.hh 7a64974ba970390f38bcea9c2471e620b92329c71eb7fa428ad0e09844007ca8 | ||
| 6 | include/qpdf/auto_job_c_main.hh e7f23e24ddbd16b5e7cb720c7da9ef76b89c2e23b5c4eecc5d8e10f0c0d60f4e | 6 | include/qpdf/auto_job_c_main.hh e7f23e24ddbd16b5e7cb720c7da9ef76b89c2e23b5c4eecc5d8e10f0c0d60f4e |
| 7 | -include/qpdf/auto_job_c_pages.hh 79ee6e52a36fedfd0e6ca60bd926bc25a3e975ab6fa984a7e798a48791e8ba86 | ||
| 8 | -include/qpdf/auto_job_c_uo.hh 80404376f19fe57d67421ad0c5fb1755811758c73870df96f081f032b196deff | ||
| 9 | -job.yml be8cd97408ab17bc83970c1b512cac3d3d3b502afd40d71ec59f66054525e6b1 | 7 | +include/qpdf/auto_job_c_pages.hh 931840b329a36ca0e41401190e04537b47f2867671a6643bfd8da74014202671 |
| 8 | +include/qpdf/auto_job_c_uo.hh 0fd370c70a1974197804f62c308ca2ec44727bf2f95a89cde48c4284823b6fbc | ||
| 9 | +job.yml 1590fd16fd17ed40db9aa56b6713c844cfd61b3a6d0441a3ccd122b7371c68e9 | ||
| 10 | libqpdf/qpdf/auto_job_decl.hh 9f79396ec459f191be4c5fe34cf88c265cf47355a1a945fa39169d1c94cf04f6 | 10 | libqpdf/qpdf/auto_job_decl.hh 9f79396ec459f191be4c5fe34cf88c265cf47355a1a945fa39169d1c94cf04f6 |
| 11 | libqpdf/qpdf/auto_job_help.hh 383eea80e2c185ef5295fc126246457a7ceeffea759fdb90bb2e6727532ea538 | 11 | libqpdf/qpdf/auto_job_help.hh 383eea80e2c185ef5295fc126246457a7ceeffea759fdb90bb2e6727532ea538 |
| 12 | libqpdf/qpdf/auto_job_init.hh 3b6323189480a7d782563c9d2b5bc29b8dcd19c6dcc89840b207e38cb503d3f1 | 12 | libqpdf/qpdf/auto_job_init.hh 3b6323189480a7d782563c9d2b5bc29b8dcd19c6dcc89840b207e38cb503d3f1 |
job.yml
| @@ -169,7 +169,7 @@ options: | @@ -169,7 +169,7 @@ options: | ||
| 169 | positional: true | 169 | positional: true |
| 170 | - table: 40-bit encryption | 170 | - table: 40-bit encryption |
| 171 | config: c_enc | 171 | config: c_enc |
| 172 | - config_class: Enc | 172 | + config_prefix: Enc |
| 173 | prefix: Enc40 | 173 | prefix: Enc40 |
| 174 | required_choices: | 174 | required_choices: |
| 175 | extract: yn | 175 | extract: yn |
| @@ -178,7 +178,7 @@ options: | @@ -178,7 +178,7 @@ options: | ||
| 178 | modify: yn | 178 | modify: yn |
| 179 | - table: 128-bit encryption | 179 | - table: 128-bit encryption |
| 180 | config: c_enc | 180 | config: c_enc |
| 181 | - config_class: Enc | 181 | + config_prefix: Enc |
| 182 | prefix: Enc128 | 182 | prefix: Enc128 |
| 183 | bare: | 183 | bare: |
| 184 | - cleartext-metadata | 184 | - cleartext-metadata |
| @@ -195,7 +195,7 @@ options: | @@ -195,7 +195,7 @@ options: | ||
| 195 | use-aes: yn | 195 | use-aes: yn |
| 196 | - table: 256-bit encryption | 196 | - table: 256-bit encryption |
| 197 | config: c_enc | 197 | config: c_enc |
| 198 | - config_class: Enc | 198 | + config_prefix: Enc |
| 199 | prefix: Enc256 | 199 | prefix: Enc256 |
| 200 | bare: | 200 | bare: |
| 201 | - cleartext-metadata | 201 | - cleartext-metadata |
libqpdf/QPDFJob_argv.cc
| @@ -365,7 +365,7 @@ void | @@ -365,7 +365,7 @@ void | ||
| 365 | ArgParser::argEndPages() | 365 | ArgParser::argEndPages() |
| 366 | { | 366 | { |
| 367 | argPagesPositional(nullptr); | 367 | argPagesPositional(nullptr); |
| 368 | - c_pages->end(); | 368 | + c_pages->endPages(); |
| 369 | c_pages = nullptr; | 369 | c_pages = nullptr; |
| 370 | } | 370 | } |
| 371 | 371 | ||
| @@ -400,7 +400,7 @@ ArgParser::argCopyAttachmentsFrom() | @@ -400,7 +400,7 @@ ArgParser::argCopyAttachmentsFrom() | ||
| 400 | void | 400 | void |
| 401 | ArgParser::argEndEncryption() | 401 | ArgParser::argEndEncryption() |
| 402 | { | 402 | { |
| 403 | - c_enc->end(); | 403 | + c_enc->endEncrypt(); |
| 404 | c_enc = nullptr; | 404 | c_enc = nullptr; |
| 405 | } | 405 | } |
| 406 | 406 | ||
| @@ -431,7 +431,7 @@ ArgParser::argUOPositional(char* arg) | @@ -431,7 +431,7 @@ ArgParser::argUOPositional(char* arg) | ||
| 431 | void | 431 | void |
| 432 | ArgParser::argEndUnderlayOverlay() | 432 | ArgParser::argEndUnderlayOverlay() |
| 433 | { | 433 | { |
| 434 | - c_uo->end(); | 434 | + c_uo->endUnderlayOverlay(); |
| 435 | c_uo = nullptr; | 435 | c_uo = nullptr; |
| 436 | } | 436 | } |
| 437 | 437 | ||
| @@ -444,7 +444,7 @@ ArgParser::argAttPositional(char* arg) | @@ -444,7 +444,7 @@ ArgParser::argAttPositional(char* arg) | ||
| 444 | void | 444 | void |
| 445 | ArgParser::argEndAttachment() | 445 | ArgParser::argEndAttachment() |
| 446 | { | 446 | { |
| 447 | - c_att->end(); | 447 | + c_att->endAddAttachment(); |
| 448 | c_att = nullptr; | 448 | c_att = nullptr; |
| 449 | } | 449 | } |
| 450 | 450 | ||
| @@ -457,7 +457,7 @@ ArgParser::argCopyAttPositional(char* arg) | @@ -457,7 +457,7 @@ ArgParser::argCopyAttPositional(char* arg) | ||
| 457 | void | 457 | void |
| 458 | ArgParser::argEndCopyAttachment() | 458 | ArgParser::argEndCopyAttachment() |
| 459 | { | 459 | { |
| 460 | - c_copy_att->end(); | 460 | + c_copy_att->endCopyAttachmentsFrom(); |
| 461 | c_copy_att = nullptr; | 461 | c_copy_att = nullptr; |
| 462 | } | 462 | } |
| 463 | 463 |
libqpdf/QPDFJob_config.cc
| @@ -781,7 +781,7 @@ QPDFJob::CopyAttConfig::password(char const* parameter) | @@ -781,7 +781,7 @@ QPDFJob::CopyAttConfig::password(char const* parameter) | ||
| 781 | } | 781 | } |
| 782 | 782 | ||
| 783 | QPDFJob::Config& | 783 | QPDFJob::Config& |
| 784 | -QPDFJob::CopyAttConfig::end() | 784 | +QPDFJob::CopyAttConfig::endCopyAttachmentsFrom() |
| 785 | { | 785 | { |
| 786 | if (this->caf.path.empty()) | 786 | if (this->caf.path.empty()) |
| 787 | { | 787 | { |
| @@ -871,7 +871,7 @@ QPDFJob::AttConfig::replace() | @@ -871,7 +871,7 @@ QPDFJob::AttConfig::replace() | ||
| 871 | } | 871 | } |
| 872 | 872 | ||
| 873 | QPDFJob::Config& | 873 | QPDFJob::Config& |
| 874 | -QPDFJob::AttConfig::end() | 874 | +QPDFJob::AttConfig::endAddAttachment() |
| 875 | { | 875 | { |
| 876 | static std::string now = QUtil::qpdf_time_to_pdf_time( | 876 | static std::string now = QUtil::qpdf_time_to_pdf_time( |
| 877 | QUtil::get_current_qpdf_time()); | 877 | QUtil::get_current_qpdf_time()); |
| @@ -921,7 +921,7 @@ QPDFJob::Config::pages() | @@ -921,7 +921,7 @@ QPDFJob::Config::pages() | ||
| 921 | } | 921 | } |
| 922 | 922 | ||
| 923 | QPDFJob::Config& | 923 | QPDFJob::Config& |
| 924 | -QPDFJob::PagesConfig::end() | 924 | +QPDFJob::PagesConfig::endPages() |
| 925 | { | 925 | { |
| 926 | if (this->config.o.m->page_specs.empty()) | 926 | if (this->config.o.m->page_specs.empty()) |
| 927 | { | 927 | { |
| @@ -960,7 +960,7 @@ QPDFJob::UOConfig::UOConfig(Config& c) : | @@ -960,7 +960,7 @@ QPDFJob::UOConfig::UOConfig(Config& c) : | ||
| 960 | } | 960 | } |
| 961 | 961 | ||
| 962 | QPDFJob::Config& | 962 | QPDFJob::Config& |
| 963 | -QPDFJob::UOConfig::end() | 963 | +QPDFJob::UOConfig::endUnderlayOverlay() |
| 964 | { | 964 | { |
| 965 | if (config.o.m->under_overlay->filename.empty()) | 965 | if (config.o.m->under_overlay->filename.empty()) |
| 966 | { | 966 | { |
| @@ -1042,7 +1042,7 @@ QPDFJob::EncConfig::EncConfig(Config& c) : | @@ -1042,7 +1042,7 @@ QPDFJob::EncConfig::EncConfig(Config& c) : | ||
| 1042 | } | 1042 | } |
| 1043 | 1043 | ||
| 1044 | QPDFJob::Config& | 1044 | QPDFJob::Config& |
| 1045 | -QPDFJob::EncConfig::end() | 1045 | +QPDFJob::EncConfig::endEncrypt() |
| 1046 | { | 1046 | { |
| 1047 | config.o.m->encrypt = true; | 1047 | config.o.m->encrypt = true; |
| 1048 | config.o.m->decrypt = false; | 1048 | config.o.m->decrypt = false; |