|
Boost : |
From: Gary Powell (Gary.Powell_at_[hidden])
Date: 2001-05-11 14:21:44
>>
> > A question comes to mind and that is how to you control the parsing? As
> in
> > does each handler tell the parser how much of the line it just ate?
>
> Oh, I'm relying on a parser that does the entire job: Process the options
> according to fixed rules, i.e. the result is a bunch of data structures
> like
> this:
>
> struct option {
> optflag denom; // how the option was given on the cmdline
> string arg; // argument (if any - "" otherwise)
> };
>
> The processor takes all those and passes each on to the corresponding
> handler
> object. The handler object than processes the argument and passes the
> resulting value on to its function.
<<
The question was more of should we be able to handle things like
-IntegerRangeValues 0 99999
where I would need the parser to grab the next two integer arguments.
I could live with
-IntegerRangeValues (0,9999)
As it does a space denote the end of an argument or does the flag "-"
constrain it.
Also I've seen arguments that used a "+" (Not that I'm advocating it but, it
might make it more general purpose if the flag character was user definable.
On the otherside my KISS is kicking me to say no, you get "-" and that's it.
> > Also formatting of the help string, do you embed <cr>'s?
>
> Oh, I didn't think about that. I embed '\n'. Wasn't it that \n expands to
> CRLF
> on MS-DOS and friends?
'\n' should be ok, as I last remember.
The issue was whether we should provide an interface which allows the
programmer to query the help list, as in
int mfNumberOfFlags() const;
string mfGetHelpDescription(int) const;
which would let the user do the help output.
Also is "help" a fixed keyword? Or is it necessary to register it?
option_processor op;
op.reg(bind(op, &option_processor::info), "this help", '?', "help");
Also in the option struct, it would probably be a good idea to return a
pointer to the help message, so that if the argument is in error, the
programmer could use the help message to help the user correct it.
Yours,
-gary-
gary.powell_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk