[Development] Regular expression libraries for QRegExp

Thiago Macieira thiago at kde.org
Wed Nov 23 15:30:41 CET 2011


On Monday, 21 de November de 2011 21:25:07 lars.knoll at nokia.com wrote:
> One interesting piece will be how we continue with this. We will most
> likely need one regexp engine in QtCore (as regexp's are being used
> internally in Qt in a couple of places). If we move QRegExp out, we still
> need to consider how to keep source compatibility. For inline code we can
> use some template magic to solve this, but it's a bit harder for stuff
> living in .cpp files (e.g. QDir and QDirIterator).

All problems in C++ can be solved by another level of indirection.

In this case, the indirection is *already* present: nowhere in the QDir and 
QDirIterator APIs are QRegExps used. It's used only internally for wildcard 
matching, so we can replace that with other suitable RE or actual globbing 
functions.

For QString, we can do:


template <class RegExp>
inline bool contains(const RegExp &rx, QEnableIf<some construct here>)
{
    return rx.indexIn(*this) != 0;
}

We don't even have to mark this one deprecated. If the new engine's API is 
compatible, it could be used for both.

Note: I'm not saying the new engine needs to be API-compatible with QRegExp.        

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20111123/0b7eaecc/attachment.sig>


More information about the Development mailing list