I currently use some old C library for getting program options and would like to replace that with some proper C++ (mainly to become independent of that library, which is a real burden). I was looking into using boost.program_options, but am not sure it can support all I want. Some things I want is:
-
allow the following command-line syntax:
myprogram option=value(in particular, I don’t really want the--option valuesyntax) -
use a default value if no value is provided (obviously this can be done in my program, but support in the options library would be nice)
-
allow default options (which are always present even if I don’t give them) and an automatic help output consisting of all the options and their descriptions
-
allow mathematical parsing, i.e. (command line)
myprogram option1=Pi option2=3/5 option3=sqrt(2)to give 3.1415…, 0.6, and 1.415… in my program -
allow single values to be expanded. Let
option_3Dpointcorrespond to anstd::array<double,3>, I want bothmyprogram option_3Dpoint=0,0,0andmyprogram option_3Dpoint=0(expanding to0,0,0) to work
Which of these can be supported by boost.program_options? Are there any alternatives?
boost.program_options is very good library. You can use to parse config files aswell. Answers:
3DPointobject from string like0,0,0