Is there a good class of common goals for C ++?

Every time I write another little toy of mine with C ++ toys, I am faced with the need for a small, user-friendly parameter / parameter class. Here is what he should do:

  • accept at least ints, double, string parameters
  • easy way to add new parameters
  • portable, small and fast
  • is free
  • options for reading from a file and / or command line
  • upper and lower bounds of parameters
  • and all other useful things that I don’t think about right now.

What I want to do is pass a pointer to this class to the builder and all my strategy objects so that they can read the parameters of the algorithm that I run (for example, which algorithm, maximum number of iterations, etc.)

Can someone point me to an implementation that achieves at least some of these things?

+3
source share
2 answers

Boost Program-Options is pretty smooth. I think that he does everything that is on your list, except, perhaps, checking the boundaries. But even then you can easily configure custom validators.

Update: . As @stefan rightly points out in the comment, this also fails on the “small”! It adds a pretty significant chunk to your binary if you statically link it.

+9
source

, JSON. JSON , . , , ..

- JSON ++, ., , . , ( - ), . ( ) ; , .

0

Source: https://habr.com/ru/post/1788361/


All Articles