[boost::program_options] Different usage

Hello, I'm wondering if I should use boost::program_options and I got some
questions about it.
All examples that I found are using std::string and std::ostream everytime
they're dealing with values being some kind of text...
so to display the "usage" of their program they would do something like...
cout << desc;
'desc' being a boost::program_options::options_description.
or...
when adding options to their command line...
desc.add_options()
...
("opt",
boost::program_options::valuestd::string, "desc")
...
What I want to know is, if I didn't want to use std::string nor std::ostream
nor std anything in my specific code (I know boost uses it).
Is there a not-so-time-expensive way to do it? If there's could someone show
me (there's no need for the real code, pseudo is more than OK) if it's
supported?
something like this for example...
desc.add_options() ("opt", bpo::value

Everton Patitucci wrote:
Hello, I'm wondering if I should use boost::program_options and I got some questions about it.
All examples that I found are using std::string and std::ostream everytime they're dealing with values being some kind of text...
so to display the "usage" of their program they would do something like...
cout << desc;
'desc' being a boost::program_options::options_description.
or...
when adding options to their command line...
desc.add_options() ... ("opt", boost::program_options::valuestd::string, "desc") ...
What I want to know is, if I didn't want to use std::string nor std::ostream nor std anything in my specific code (I know boost uses it).
Is there a not-so-time-expensive way to do it? If there's could someone show me (there's no need for the real code, pseudo is more than OK) if it's supported?
Values of the option can be of any type, it is not necessary to use std::anything. You might need to 'validate' function for the custom types.
something like this for example...
desc.add_options() ("opt", bpo::value
, "blabla") and in usage()-like:
I don't know if this works, I looked in doc... std::vector< shared_ptrpo::option_description > opts = desc.options(); std::vector< shared_ptrpo::option_description >::iterator it = opts.begin(); for (; it != opts.end(); ++it) { shared_ptrpo::option_description opt = *it; printf("%s\n", opt->format_parameter().c_str()); }
There's nothing preventing code like this from working. - Volodya
participants (2)
-
Everton Patitucci
-
Vladimir Prus