[Development] Regular expression libraries for QRegExp

lars.knoll at nokia.com lars.knoll at nokia.com
Wed Nov 23 22:06:36 CET 2011


On 11/23/11 3:30 PM, "ext Thiago Macieira" <thiago at kde.org> wrote:

>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.

You're right, these are not problematic.

>
>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.        

We don't need a compatible API to make this work. Simple template
specialization in the corresponding regexp header file should do the trick.

I'm not saying it's impossible to solve, simply that it requires some work
and thinking to do it properly.

Cheers,
Lars




More information about the Development mailing list