Hi,

We have an executable that uses the program_options library to process command line options like this:

$ ./hilbert.x -h
  -b [ --hilbert ] arg (=1)             enable hilbert matrix
  -e [ --epsilon ] arg (=0.001)         roundoff epsilon
  -h [ --help ]                         help message
  -i [ --input-file ] arg               process input file
  -r [ --rank ] arg                     rank of matrix to construct
  -t [ --tolerance ] arg (=1e-13)       linear tolerance
  -v [ --inverse ] arg (=0)             enable inverse hilbert matrix
  -w [ --wordsize ] arg (=8)            floating-point word size (bytes)

and it works great.  Now we’re trying to automate some testing and we test our executable with an input file that has hundreds of lines like this:

--inverse 1 --tolerance 1e-15 --rank 2
--inverse 1 --tolerance 1e-15 --rank 3
--inverse 1 --tolerance 1e-15 --rank 4

where each line is a separate test case that we run with the specified options.  I was looking for a program options parser that can parse a string, so I can read one line of input from this file into a string, and run that test case, that is something like this:

  // read one line of input from file
  ifstream ifp;
  string buffer;
  while (!ifp.eof() && ifp.good()) {
    getline(ifp, buffer);
    // load a set of command line options from this string
    po::parse_config_file<char>(buffer.c_str(), desc);
  }

The only program option parsers I see are parse_command_line, parse_config_file, and parse_environment.  Is there an easy way (without having to construct an argc/argv data structure) to parse a file of program options?

— Noel Belcourt