Commit 03f3369f35b2303166e8d36547c8a0aba6626c1b

Authored by Jay Berkenbilt
1 parent 9013b7ca

QPDFJob: use manually named end functions for Config classes

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