diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-01-06 20:26:32 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-01-30 19:11:03 +0100 |
commit | f1d805badc1ea09998fea9427687456717936ff7 (patch) | |
tree | b25a383d8b93c3a2c6dff6eb3a8be1acb39fddeb /libqpdf | |
parent | c3e9b64e7fde8499f8543503bdfeeeb65512dcd7 (diff) | |
download | qpdf-f1d805badc1ea09998fea9427687456717936ff7.tar.zst |
Add QPDFArgParser::copyFromOtherTable
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/QPDFArgParser.cc | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/libqpdf/QPDFArgParser.cc b/libqpdf/QPDFArgParser.cc index 33dbf2e0..a24b00eb 100644 --- a/libqpdf/QPDFArgParser.cc +++ b/libqpdf/QPDFArgParser.cc @@ -154,6 +154,29 @@ QPDFArgParser::addRequiredChoices( } void +QPDFArgParser::copyFromOtherTable(std::string const& arg, + std::string const& other_table) +{ + if (! this->m->option_tables.count(other_table)) + { + QTC::TC("libtests", "QPDFArgParser copy from unknown"); + throw std::logic_error( + "QPDFArgParser: attempt to copy from unknown table " + + other_table); + } + auto& ot = this->m->option_tables[other_table]; + if (! ot.count(arg)) + { + QTC::TC("libtests", "QPDFArgParser copy unknown"); + throw std::logic_error( + "QPDFArgParser: attempt to copy unknown argument " + arg + + " from table " + other_table); + } + OptionEntry& oe = registerArg(arg); + oe = ot[arg]; +} + +void QPDFArgParser::addFinalCheck(bare_arg_handler_t handler) { this->m->final_check_handler = handler; @@ -533,7 +556,8 @@ QPDFArgParser::parseArgs() if (oep == this->m->option_table->end()) { // This is registered automatically, so this can't happen. - throw std::logic_error("ArgParser: -- handler not registered"); + throw std::logic_error( + "QPDFArgParser: -- handler not registered"); } } else if ((arg[0] == '-') && (strcmp(arg, "-") != 0)) |