| Trolltech Home | Qt4-preview-feedback Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 1 | |
I've just started playing with the new XML streaming code in Qt4.3 snapshot
for the XML Paper Specification code in okular, and I thought I'd offer some
initial thoughts. These might be tempered with some more experience.
Overall, it looks friendly and very useful.
QStringRef is unwelcome, and makes for uglier code. I trust it is a huge
performance win to justify its existence. As an alternative, it would be nice
to have some of the QString API available, so I don't end up with code that
looks like:
m_pageSize.setWidth( attributes.value( "Width" ).toString().toInt() );
It would nice to be able to dump an attribute list or a QStringRef to
qDebug().
It isn't clear to me the best way to use the class. The inline docs suggest a
"has-a" QXmlStreamReader, but the XBEL example uses "is-a" (same for
QXmlStreamWrite). At this stage I'm doing "has-a", because it was less
disruptive for my existing code. Any thoughts/suggestions?
Thanks again for this welcome addition.
Brad
Attachment:
Attachment:
pgphK0l7n7ptQ.pgp
Attachment:
Attachment:
pgpM6HAZsW8Lo.pgp
Description: PGP signature
Message 2 in thread
On Monday 05 March 2007 12:00, Brad Hards wrote:
> I've just started playing with the new XML streaming code in Qt4.3 snapshot
> for the XML Paper Specification code in okular, and I thought I'd offer
> some initial thoughts. These might be tempered with some more experience.
>
> Overall, it looks friendly and very useful.
Thanks.
>
> QStringRef is unwelcome, and makes for uglier code. I trust it is a huge
> performance win to justify its existence. As an alternative, it would be
> nice to have some of the QString API available, so I don't end up with code
> that looks like:
> m_pageSize.setWidth( attributes.value( "Width" ).toString().toInt()
> );
>
> It would nice to be able to dump an attribute list or a QStringRef to
> qDebug().
Yep, the current direct use of QStringRef is a bit limiting.
>
> It isn't clear to me the best way to use the class. The inline docs suggest
> a "has-a" QXmlStreamReader, but the XBEL example uses "is-a" (same for
> QXmlStreamWrite). At this stage I'm doing "has-a", because it was less
> disruptive for my existing code. Any thoughts/suggestions?
I only considered has-a initially, but when I ported the XBEL example from
QDom to the stream classes, it felt natural to use the is-a approach, mainly
because the code that called the writer class wanted to know the error state,
and thus inheritance saved duplicating the error() and errorString()
functions.
A matter of taste, I'd say. I'd probably go with has-a in most cases.
Matthias
To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx
Message 3 in thread
On Tuesday 06 March 2007 07:26, Matthias Ettrich wrote:
> > QStringRef is unwelcome, and makes for uglier code. I trust it is a huge
> > performance win to justify its existence. As an alternative, it would be
> > nice to have some of the QString API available, so I don't end up with
> > code that looks like:
> > Â Â Â Â m_pageSize.setWidth( attributes.value( "Width"
> > ).toString().toInt() );
> >
> > It would nice to be able to dump an attribute list or a QStringRef to
> > qDebug().
>
> Yep, the current direct use of QStringRef is a bit limiting.
I thought about this a bit more. Would it be possible to hide QStringRef
entirely? That is, use it as an internal representation, but (somehow)
convert to a (possibly cached) QString automagically when the user accesses
the value?
Brad
Description: PGP signature
Message 4 in thread
On Monday 05 March 2007 12:00, Brad Hards wrote:
> I've just started playing with the new XML streaming code in Qt4.3 snapshot
> for the XML Paper Specification code in okular, and I thought I'd offer
> some initial thoughts. These might be tempered with some more experience.
>
> Overall, it looks friendly and very useful.
I agree. A small naming nuisance which I noticed: the values of the
QXmlStreamReader::Error enum all end in 'Error', which I like. However, the
values of the QXmlStreamReader::TokenType don't have a common suffix,
something like 'Token' maybe.
I think something like
if ( reader.tokenType() == CommentToken )
is a bit nicer than
if ( reader.tokenType() == Comment )
- Frerich
To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx