Hi, On Tue, 25 Oct 2011 23:01:43 +0200, Thiago Macieira <[email protected]> wrote:
> QVariant has toBool just like it has toDouble and toInt, so I think it > makes sense to have it in QString and in QByteArray. It makes sense from an equal-API point of view. On the other hand, QVariant has a significantly different task than QString does -- QString is, AFAIK, not a union replacement like QVariant is. Does it make sense to add QString::toBool() from a basic task perspective? > 1) document very well what is true and what isn't Restricting the use to e.g. English only, would not be really useful when parsing (localized) user input, although I don't think this would happen a lot. I only know of a few cases where an end-user is expected to explicitly type yes or no into an input field, and those are command line tools. Wouldn't that be pretty much the only use case? I might have overlooked things. It's getting late anyway. > 2) make sure all three classes work the same way. If not, change them so > that they all have toBool() const and they all operate equally. > > 3) add unit tests > > 4) ensure that QVariant::toBool calls into QString::toBool and > QByteArray::toBool, as applicable. Note pending the commits by Jędrzej > that are refactoring the QVariant internals. If QString::toBool() is added, would there also be a need for something like static QString::boolean(bool value, char format = 't')? Cheers, Frans _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
