22.10.2011, в 13:00, <[email protected]> написал(а):

> Number of parameters for flag is controlled by the last parameter to 
> addSupportedFlag(), which is of type QStringList. If this string list is 
> empty, the flag accepts no parameters. If it is non-empty, then the flag 
> accepts the same number of parameters as there are items in the string list. 
> The string list merely specifies the names to give the parameters in the 
> usage/help message.

How can add option of type StringList? Can i add names to "positional options" 
- i.e. options after option list: "app.exe value1 value2 value3" ?

> Type checking could be added easily by the client where it is needed. If your 
> subclass wants to operate on specific types, then the neat way to do it would 
> be to add a member function to your subclass to encapsulate that conversion. 
> Your validate() function would normally handle checking whether parameters 
> that need to be convertible to a specific type can indeed be converted. For 
> example, if there was a flag that was expected to have one parameter that was 
> convertible to int, it could fairly trivially be implemented something like 
> this:
> 

No it can't be easily added, if you work with options from different modules - 
all of them will require access to Parser (static classes, foo); if something 
will go wrong, you will get headache with supporting that (most  common, you 
will need to terminate program and print help, but imagine what pain it will be 
if half of program initialized properly and other suddenly sees that user just 
passed "123bla" instead of "123")

In my program, i had options in an xml file that describes plugin - program 
simply read all files, add options to parser, checks types and then quits if 
something is wrong, or loads plugins and passes them QVariantMap with options 
of concrete plugin
Here's a link for my class; but it is a private class and never designed to 
have public and easy API. http://pastebin.com/gJLhzyTt

In boost, everything exists that anyone will ever need for cmd parsing, just 
make API more "qt-ish" and everyone will be happy.

_______________________________________________
Qt5-feedback mailing list
[email protected]<mailto:[email protected]>
http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback

_______________________________________________
Qt5-feedback mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback

Reply via email to