what can and can't I do with boost.program_options?
-
03-07-2021 - |
Pregunta
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 value
syntax)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 programallow single values to be expanded. Let
option_3Dpoint
correspond to anstd::array<double,3>
, I want bothmyprogram option_3Dpoint=0,0,0
andmyprogram option_3Dpoint=0
(expanding to0,0,0
) to work
Which of these can be supported by boost.program_options? Are there any alternatives?
Solución
boost.program_options is very good library. You can use to parse config files aswell. Answers:
- Dont know but seems no builtin support.
- Yes.
- Yes.
- No unless you make your own expression evaluation handler or use some other boost libs to do this.
- Yes, you will need to write your own handler which creates
3DPoint
object from string like0,0,0