Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Boost.Program_options in modular program

The code I use consists of set of modules, compiled to individual libraries. Libraries in turn, are linked in different combinations to build different binaries.

So for, it's pretty ordinal.

Different modules use different command line arguments and I want to use Boost.Program_options for parsing.

Since the set of command line arguments depends on what libraries are link together, I don't know in advance all arguments and therefore can not add them to program_options::options_description.

How do you enable to each module to add it's command line arguments and later read them?

Thanks

like image 655
dimba Avatar asked Aug 10 '10 19:08

dimba


1 Answers

E.g. by using options_descriptions member function add(const options_description & desc) to collect the options from your modules together in one description:

options_description & add(const options_description & desc) ;
Adds a group of option description. This has the same effect as adding all option_descriptions in desc individually, except that output operator will show a separate group. Returns *this.

Extracting options could be simply done by passing e.g. the variables_map around to the modules.

like image 182
Georg Fritzsche Avatar answered Nov 06 '22 03:11

Georg Fritzsche