Boost logo

Boost Users :

Subject: Re: [Boost-users] [Program Options] Input information as std::string
From: Charles Mills (charlesm_at_[hidden])
Date: 2012-07-22 12:32:35


Sorry, a little late to the party with this response.

 

The bad news: there is no evidence that Boost::po includes any code to
tokenize a string like what you have below. Boost::po::command_line_parser
takes as input an already-parsed argc and argv.

 

The good news is that I doubt that Boost::po has any "special" code that
"knows" that argc and argv came from the standard command line. If you were
to use any of the parsing techniques suggested by Vladimir (or any other
parsing technique that you prefer) to make your string into a integer count
of char[]'s, and an array of char[] pointers, with the first being "filler,"
then I'll bet that command_line_parser(count, array) would do exactly what
you want.

 

Charles

From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Nicholas Yue
Sent: Saturday, July 14, 2012 5:57 AM
To: boost-users_at_[hidden]
Subject: [Boost-users] [Program Options] Input information as std::string

 

Hi,

    I have a situation where I would like to parse the command line options
not as (int argc, char **argv)

template<typename charT>
  basic_parsed_options< charT >
  parse_command_line(int argc, const charT *const argv,
                     const options_description &, int style = 0,
                     function1< std::pair< std::string, std::string >, const
std::string & > ext = ext_parser());

    but as a std::string.

    The std::string is the equivalent of the command line but obtain either
from reading some file or cut and paste.

    E.g. my input string would be something like "myprog 817382
--lod="lod.cfg" --radius=3.0"

    With such string as the above, I'd like to know how I should pass it to
boost::program_options

Regards

-- 
Nicholas Yue
Graphics - RenderMan, Visualization, OpenGL, HDF5
Custom Dev - C++ porting, OSX, Linux, Windows
Management - Recruitment, career management
http://www.proceduralinsight.com/
http://au.linkedin.com/in/nicholasyue



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