
Hi Charles,
One way would be as follows. You'd first have to patch some of the
boost.PO code as detailed here:
https://svn.boost.org/trac/boost/ticket/3265#comment:1
Then, your init file could look like this:
[rectangle]
width= (5 3)
height=(10)
[circle]
diameter = (3 5)
etc. You need to make sure yourself that the vectors are of equal
length. Empty vector would mean no objects of that type of course
Make sure of course that in the options definition used when parsing
the init file, your output variables are vectors:
std::vector<double> rectangle_widths;
po::options_description poInit;
poInit.add_options()
("rectangle.width" ,
po::value
I really like the Boost Program Options library. I’ve used it for one program now with great effect and I’d like to use it for another, but can’t figure out how to structure what I need to do so that Boost PO could handle it.
I am solely interested in the “.ini file” for this – command line is irrelevant.
The problem is “how does a program allow the specification of a variable number of ‘objects’ each of which has parameters of its own?”
Here is a hypothetical program that exemplifies the problem. Suppose a program were going to create multiple geometric shapes of some sort. An ideal (unsupported by PO) .ini file might look like
rectangles=3
rectangle[0].width=5
rectangle[0].height=10
rectangle[1].width=3
etc.
circles=2
circle[0].diameter=4
etc.
Can anyone suggest a way to accomplish this with Boost PO? I’m real flexible on what the .ini file might look like so long as it solves the problem and is reasonably explicable to a user. (No need for it to look almost like the above.)
Thanks,
Charles
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users