Each time I write another one of my small c++ toy programs, I come across the need for a small, easy-to-use options/parameter class. Here is what it should be able to do:
- accept at least ints, doubles, string parameters
- easy way to add new options
- portable, small and fast
- free
- read options from a file and/or command line
- upper and lower bounds for parameters
- and all the other neat useful things I am not thinking of right now
What I want to do is pass a pointer to this class to the builder and all of my strategy objects, so they can read the parameters of the algorithm I am running (e.g. which algorithm, maximum number of iterations etc.)
Can someone point me to an implementation that achieves at least some of these things?
Boost Program-Options is pretty slick. I think it does all the things on your list, apart from maybe bounds validation. But even then, you can provide custom validators pretty easily.
Update: As @stefan rightly points out in a comment, this also fails on “small”! It adds quite a significant chunk to your binary if you statically link it in.