boost-program-options

c++ boost program options always giving default value

混江龙づ霸主 提交于 2019-12-12 03:18:27
问题 I'm struggling to get boost program options to work properly. I need to be able to start my program from the terminal window (Linux) with an optional argument that takes a value. No matter what I did, this would not work; no matter what value I typed from the terminal, it just returned the default value. Furthermore, if I did not include the option in my termina command, it returned with terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception

How to use boost program_options to read an integer array?

你。 提交于 2019-12-12 01:56:00
问题 I am using Ubuntu and boost v1.50. Previously I used boost program_options to feed a set of options into a program like so: #!/bin/bash ./prog --arg1 1 --arg2 "2" --arg3 {1,2,3} --arg4 {1,2} --arg5 5 So I am dealing with a mix of single integers, strings and integer arrays. This worked fine. However, after "improving" the code by introducing local variables in bash, I have: #!/bin/bash a1=1 a2="2" a3={1,2,3} a4={1,2} a5=5 ./prog --arg1 $a1 --arg2 $a2 --arg3 $a3 --arg4 $a4 --arg5 $a5 Executing

Visual Studio C++ remote linux debugging add linker options

ぐ巨炮叔叔 提交于 2019-12-11 17:09:56
问题 I am trying to develop a simple program in C++ with the boost library. I develop with Visual Studio 2017 and a remote bash shell of ubuntu to compile and debug. I installed gdb, gdbserver, all the compiler and the boost library on ubuntu. Simple programs without boost compile and run without problem from the shell directly as from Visual Studio ! When I compile the following program directly from the ubuntu bash with the following command : g++ test.cpp -std=c++11 -lboost_program_options -o t

Boost Program Options link error

落爺英雄遲暮 提交于 2019-12-11 05:34:48
问题 I am having trouble with linking -lboost_program_options . I cannot even compile the minimum example first.cpp. Here is the cpp: // Copyright Vladimir Prus 2002-2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) /* The simplest usage of the library. */ #include <boost/program_options.hpp> namespace po = boost::program_options; #include <iostream> #include <iterator> using namespace

boost program_option case insensitive parsing

家住魔仙堡 提交于 2019-12-11 00:29:14
问题 Has anyone worked out how to get boost program options to parse case insensitive argument lists In the boost documentation, it appears that it is supported. See http://www.boost.org/doc/libs/1_53_0/boost/program_options/cmdline.hpp Namely, setting the style_t enum flag such as long_case_insensitive. However, I'm not sure how to do it. Eg how would you get the following code snippet to accept --Help or --help or --HELP po::options_description desc("Allowed options"); desc.add_options() ("help"

How to support commandline syntax “-DEVICE:iphone” in Boost::Program_Options?

人走茶凉 提交于 2019-12-10 14:09:23
问题 The default syntax for Boost::Program_Options is "--DEVICE iphone". How can I support syntax "-DEVICE:iphone" or "-DEVICE=iphone"? 回答1: Boost.Program_Options has a pretty large number of option styles. The particular combination you seem to be going for would be: command_line_style::long_allow_adjacent | command_line_style::short_allow_adjacent | command_line_style::allow_long_disguise These options should be given to the style function of your command line parser: po::store(po::command_line

Parsing unregistered options for config files in Boost program_options?

落爺英雄遲暮 提交于 2019-12-10 13:46:14
问题 With command line options, I can do the following: po::variables_map vm; auto parsedOptions = po::command_line_parser(argc, argv).options(optionsDescription1).allow_unregistered().run(); po::store(parsedOptions, vm); po::notify(vm); auto unregistered = po::collect_unrecognized(parsedOptions.options, po::include_positional); po::variables_map vm2; auto parsedOptions2 = po::command_line_parser(unregistered).options(optionsDescription2).run(); po::store(parsedOptions2, vm2); po::notify(vm2);

boost::program_options: parameters with a fixed and a variable token?

南笙酒味 提交于 2019-12-08 19:21:25
问题 Is it possible to use parameters of this kind with boost::program_options? program -p1 123 -p2 234 -p3 345 -p12 678 i.e., is it possible to specify the parameter name with a first token (e.g. -p ) followed by a number, dynamically? I would like to avoid this: program -p 1 123 -p 2 234 -p 3 345 -p 12 678 回答1: Boost.ProgramOptions does not provide direct support for this. Nevertheless, there are two general solutions that each have their trade-offs: Wildcard options. Custom parser. Wildcard

c++: program settings - boost.PropertyTree or boost.program_options?

偶尔善良 提交于 2019-12-08 15:11:47
问题 I was looking for a solution to store program settings or options or configuration in C++. These could be settings that are exposed in a GUI and need to be saved between runs of my code. In my search I came across boost.PropertyTree which seemed to be a good choice. I know boost is well respected code so I'm comfortable using it and so I started developing using this. Then I come across boost.program_options which seems to allow you to do the same thing but also looks more specialized for the

C++ Boost program options with json file

佐手、 提交于 2019-12-08 01:18:41
问题 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 回答1: 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: