开发者

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 diffe开发者_开发技巧rent 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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜