|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
QCStringList and QCString complications...I picked a random target in the "Programme for Tedium" porting effort, and
zoomed in on QCString. We seem to use this in a number of contexts where we need to deal with data the old fashioned way, like writing a binary MIDI file. It has been replaced with QByteArray, and a compatibility class Q3CString based on QByteArray: QCString In Qt 3, QCString inherited from QByteArray. The main drawback of this approach is that the user had the responsibility of ensuring that the string is '\0'-terminated. Another important issue was that conversions between QCString and QByteArray often gave confusing results.... Qt 4 solves that problem by merging the QByteArray and QCString classes into one class called QByteArray. Most functions that were in QCString previously have been moved to QByteArray. The '\0' issue is handled by having QByteArray allocate one extra byte that it always sets to '\0'. For example: QByteArray ba("Hello"); ba.size(); // returns 5 (the '\0' is not counted) ba.length(); // returns 5 ba.data()[5]; // returns '\0' The Qt3Support library contains a class called Q3CString that inherits from the new QByteArray class and that extends it to provide an API that is as close to the old QCString class as possible. Note that the following functions aren't provided by Q3CString: * QCString::find(const QRegExp &, int) * QCString::findRev(const QRegExp &, int) * QCString::contains(const QRegExp &) * QCString::replace(const QRegExp &, const char *) This description isn't so helpful for getting a quick idea of what we're looking at, because it talks about what's missing from a compatibility class we're going to try to avoid anyway, rather than talking directly and obviously about how much of a 1:1 correspondence there is between the old QT3 QCString and the new QT4 QByteArray. We know "most functions" have been merged, but without particle by particle investigation of each method of QCString we use in what context, it's hard to get an overview of what we're looking at. I figured I'd try a simple swap, and maybe we'd get lucky and not use any methods of the old QCString that don't have functionally identical equivalents in the new QByteArray. Without a lot of deep digging, it's hard to evaluate how successful that effort was. However, there is definitely a snag. We also use QCStringList, which my swap now converts to QByteArrayList. Well, there's no QByteArrayList in QT4, so my swap isn't quite robust enough to actually work anyway without more refinement. However, whats more troubling is the complete lack of documentation anywhere about QCStringList. I can guess what it's supposed to do, but where are the damn API docs for it? All I can find are uses of it in KDE code, with several of them seeming to be related to DCOP code. Google turns up nothing but code snippets in an assortment of contexts. No API anywhere. Not even for QT2 or something. Some of our QCStringLists look like they will have to be totally replaced with something else anyway (as they relate to DCOP) but I don't think we're lucky enough that all of them are going to disappear. So we really need to build some kind of equivalent, and without even knowing what the bloody hell that even used to do, this is an irritating snag. Well, anyway, on a positive note, I just busted my regex cherry and figured out how to replace QCString but not QCStringList. I'm definitely not enough of a regex champ, nor am I aspiring to be one, to do a good job with most of the really tricky nonsense like what Yves just spent five years on to accomplish 1/10,000,000th of our job, but this should make me marginally less useless for the porting effort. Bully for me. Huzzah. I'm going to bed now. Porting is EVIL! -- D. Michael McIntyre ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Rosegarden-devel mailing list Rosegarden-devel@... - use the link below to unsubscribe https://lists.sourceforge.net/lists/listinfo/rosegarden-devel |
|
|
Re: QCStringList and QCString complications...On Fri, Jul 18, 2008 at 6:00 AM, D. Michael McIntyre
<michael.mcintyre@...> wrote: > I figured I'd try a simple swap, and maybe we'd get lucky and not use any > methods of the old QCString that don't have functionally identical > equivalents in the new QByteArray. I think that has a good chance of working. And I think anything it misses will probably show up in compile errors rather than subtle bugs. > However, there is definitely a snag. We also use QCStringList, which my swap > now converts to QByteArrayList. Well, there's no QByteArrayList in QT4, so > my swap isn't quite robust enough to actually work anyway without more > refinement. However, whats more troubling is the complete lack of > documentation anywhere about QCStringList. A few greps later and I can tell you why -- it's just an opportunistic typedef in the KDE headers. Actually, it's so opportunistic that the typedef appears several times in several different headers. Fortunately, it's the same each time... Anyway, it's typedef QValueList<QCString> QCStringList; QValueList is just QList in Qt4-speak, so I think you should just be able to directly replace QCStringList with QList<QByteArray> throughout, and that will probably work. Chris ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Rosegarden-devel mailing list Rosegarden-devel@... - use the link below to unsubscribe https://lists.sourceforge.net/lists/listinfo/rosegarden-devel |
|
|
|
| Free Forum Powered by Nabble | Forum Help |