boost-program-options

Boost program_options with composing() and implicit_value() are not “composed”

微笑、不失礼 提交于 2019-12-07 13:40:32
问题 I am having a problem with boost program_options (v1_49) in the case of an option defined as composing() and also implicit(). My intent is to implement a -D option similar to the way perl does, so that you can do -D or -Dname and use it multiple times. My options_description is: ( "debug,D", bpo::value<vector<string> >() ->composing() ->implicit_value(vector<string>(1,"1")), "Set debug level." ), This seems to work OK in most cases, but whenever -D with no value appears on the command line,

How does one extract the sequence of parsed options using Boost Program Options?

我是研究僧i 提交于 2019-12-07 05:37:11
问题 I'm building a graph generator using Boost Graph and Program Options. There are, for example, two types of components C and W, each with 1 source, 1 sink and some additional parameters to specify topology in between. I'd like to be able to stitch them together in the sequence provided by the order of the command line arguments. For example: ./bin/make_graph -c4,5,1 -w3,3 -c3,1,2 Should create a graph resembling the following: C -- W -- C But: ./bin/make_graph -c4,5,1 -c3,1,2 -w3,3 Should

Boost Program Options won't work with GLIBCXX_DEBUG

时光毁灭记忆、已成空白 提交于 2019-12-06 20:09:40
问题 I have the following sample code: #include <iostream> #include <boost/program_options.hpp> int main ( int ac, char *av[] ) { // Declare the supported options. boost::program_options::options_description desc("Allowed options"); desc.add_options()("help", "produce help message"); boost::program_options::variables_map vm; boost::program_options::store(boost::program_options::parse_command_line(ac, av, desc), vm); return 0; } It compiles fine using e.g. g++ test.cpp -lboost_program_options .

Boost program options with default values always present when using vm.count()

ぐ巨炮叔叔 提交于 2019-12-06 17:48:19
问题 I've been trying to validate my passed options with boost::program_options. My command has several modes, each of which have associated params that can be specified. What I'm trying to do is ensure these associated params are passed with the mode, i.e. unicorn --fly --magic-wings-threshold Where --fly is the mode and --magic-wings-threshold is an associated param. What I've noticed is if --magic-wings-threshold has a default value, e.g. ("magic-wings-threshold,w", po::value<double>(&wings

Can Boost Program_options separate comma separated argument values

邮差的信 提交于 2019-12-06 09:57:32
问题 If my command line is: > prog --mylist=a,b,c Can Boost's program_options be setup to see three distinct argument values for the mylist argument? I have configured program_options as: namespace po = boost::program_options; po::options_description opts("blah") opts.add_options() ("mylist", std::vector<std::string>>()->multitoken, "description"); po::variables_map vm; po::store(po::parse_command_line(argc, argv, opts), vm); po::notify(vm); When I check the value of the mylist argument, I see one

skipping unknown options without throwing with boost program options

戏子无情 提交于 2019-12-06 06:28:48
问题 These days I am playing with Boost program options for reading INI files. The code I have throws an exception once in the file there is a line with an unknown option. Do you know whether is possible and how to let the code below read the whole file? I want to skip the unknown options without throwing so that I can read all possible values. Thanks a lot AFG namespace pod = boost::program_options; pod::options_description options("Options"); std::string myArgValue; options.add_options() ("SECT

C++ Boost program options with json file

家住魔仙堡 提交于 2019-12-06 06:00:50
It is possible with boost program options library: http://www.boost.org/doc/libs/1_64_0/doc/html/program_options.html to read json formatted file as an input file here? Or if I have some config in json like file, I need to parse it myself, with for example: http://www.boost.org/doc/libs/1_64_0/doc/html/property_tree.html I've met the same problem. Here is my implementation of JSON parser for program_options library, based on property_tree: template <class charT> void parseChildren(std::string prefix, boost::property_tree::ptree& tree, boost::program_options::parsed_options& options) { if (tree

In Boost::Program_Options, how to set default value for wstring?

前提是你 提交于 2019-12-06 01:38:19
问题 My code below did not work: wstring config_file; // Declare a group of options that will be // allowed only on command line po::options_description generic("Generic options"); generic.add_options() ("help,h", "produce help message") ("config,c", po::wvalue<wstring>(&config_file)->default_value(L"DXDrv.cfg"), "name of a file of a configuration.") ; The compilation failed with error: d:\repo\a4x_ext\minidxdriver\testapp\configparser\boost\lexical_cast.hpp(1096) : error C2039: 'setg' : is not a

Specifying levels (e.g. --verbose) using Boost program_options

£可爱£侵袭症+ 提交于 2019-12-06 00:52:27
Some of my options have multiple levels, e.g. of "verbosity". I would like my users to choose between the following two equivalent styles: // no argument: verbosity of 1 my_program -v // count the 'v's: verbosity of 4 my_program -vv --something_else XYZ -vv // specify the value: verbosity of 4 my_program --verbose 3 What is the easiest way of doing this with the Boost program_options library? This is how I envisage the code being used. We use level_value in place of the normal program_options::value pass option_level<CHAR>(your_value) where CHAR is the short option letter, and your_value is

Boost program_options with composing() and implicit_value() are not “composed”

夙愿已清 提交于 2019-12-05 20:15:52
I am having a problem with boost program_options (v1_49) in the case of an option defined as composing() and also implicit(). My intent is to implement a -D option similar to the way perl does, so that you can do -D or -Dname and use it multiple times. My options_description is: ( "debug,D", bpo::value<vector<string> >() ->composing() ->implicit_value(vector<string>(1,"1")), "Set debug level." ), This seems to work OK in most cases, but whenever -D with no value appears on the command line, all earlier values are erased, e.g.: $ ./a.out -D abc -D 255 -D xyz variables_map["debug"] = {"abc",