[Development] [Qt5-feedback] Command line parser in QtCore?

Craig.Scott at csiro.au Craig.Scott at csiro.au
Sun Oct 23 00:58:25 CEST 2011


On 23/10/2011, at 1:14 AM, Andre Somers wrote:

Op 22-10-2011 15:52, Dhaivat Pandya schreef:

Craig,

Do have any part of this class implemented? If its, people can test it and see if it actually meets the users needs.
2011/10/22 Thiago Macieira <thiago at kde.org<mailto:thiago at kde.org>>
On Saturday, 22 de October de 2011 11:29:38 Craig.Scott at csiro.au<mailto:Craig.Scott at csiro.au> wrote:
> With that out of the way, I've put the class definition up on pastebin for
> comment. I've withheld the implementation until I've had a chance to clear
> it with our legal people. In the meantime, I think the interface of the
> class is probably enough to get some feedback on whether people think this
> has the potential to be a viable candidate for a command line parser for
> Qt:
>
Seems to me Craigs message was clear: yes, there is an implementation, but no, it is not available to the public for the time being because such a release must go through the companies legal department. Sounds reasonable to me.

I have my doubts on the API. I don't really like the fact that subclassing is needed to use it. I prefer a solution where basic validation is build in, and more extended validation is possible (subclassing is OK to me for that case, but you could also considder a pattern like how QValidator is used.)

What do you mean by basic validation? The code you include in Qt cannot know what each of your flags mean, so only you can implement validation on whether or not the flags and arguments form a sane combination. We started out thinking along a similar line, but it turns out there's not really anything that the base class can validate! Since arguments and flags can be intermingled, you can't even test whether a multi-parameter flag has all required parameters unless it is the last one on the command line (which is about the only thing I think the base class can actually validate for you).

Not sure what your point is with the QValidator approach, since it uses the same approach as the class I proposed. QValidator has a pure virtual validate() function too! If you mean that there are a couple of standardish subclasses of QValidator provided, I come back to my above point that there isn't really much you can pre-build as far as flag/argument validation is concerned. Anything that isn't recognised as a flag is treated as an argument, so there's not much left to validate automatically.


--
Dr Craig Scott
Computational Software Engineering Team Leader, CSIRO (CMIS)
Melbourne, Australia






More information about the Development mailing list