Boost logo

Boost Users :

Subject: [Boost-users] [boost::program_options] Different usage
From: Everton Patitucci (patucci_at_[hidden])
Date: 2009-03-05 10:31:21


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::value<std::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<char*>, "blabla")

and in usage()-like:

I don't know if this works, I looked in doc...
std::vector< shared_ptr<po::option_description> > opts = desc.options();
std::vector< shared_ptr<po::option_description> >::iterator it =
opts.begin();
for (; it != opts.end(); ++it)
{
     shared_ptr<po::option_description> opt = *it;
     printf("%s\n", opt->format_parameter().c_str());
}

Patuti



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net