Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/corelib/xml/qxmlstream.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    56**
    67** This file is part of the QtCore module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5353#include "qxmlutils_p.h"
    5454#include <qdebug.h>
    55 #include <QFile>
     55#include <>
    5656#include <stdio.h>
    5757#include <qtextcodec.h>
     
    5959#include <qbuffer.h>
    6060#ifndef QT_BOOTSTRAPPED
    61 #include <QCoreApplication>
     61#include <>
    6262#else
    6363// This specialization of Q_DECLARE_TR_FUNCTIONS is not in qcoreapplication.h,
     
    130130
    131131/*!
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
    132147    \enum QXmlStreamReader::Error
    133148
     
    245260  well-formed XML via a simple streaming API.
    246261
    247   \mainclass
     262
    248263  \ingroup xml-tools
    249264
     
    299314
    300315  The \l{QXmlStream Bookmarks Example} illustrates how to use the
    301   recursive descent technique with a subclassed stream reader to read
    302   an XML bookmark file (XBEL).
     316  recursive descent technique
     317  a.
    303318
    304319  \section1 Namespaces
     
    335350  new data with the next call to readNext().
    336351
    337   For example, if you read data from the network using QHttp, you
    338   would connect its \l{QHttp::readyRead()}{readyRead()} signal to a
    339   custom slot. In this slot, you read all available data with
    340   \l{QHttp::readAll()}{readAll()} and pass it to the XML stream reader
    341   using addData(). Then you call your custom parsing function that
    342   reads the XML events from the reader.
     352  For example, if your application reads data from the network using a
     353  \l{QNetworkAccessManager} {network access manager}, you would issue
     354  a \l{QNetworkRequest} {network request} to the manager and receive a
     355  \l{QNetworkReply} {network reply} in return. Since a QNetworkReply
     356  is a QIODevice, you connect its \l{QNetworkReply::readyRead()}
     357  {readyRead()} signal to a custom slot, e.g. \c{slotReadyRead()} in
     358  the code snippet shown in the discussion for QNetworkAccessManager.
     359  In this slot, you read all available data with
     360  \l{QNetworkReply::readAll()} {readAll()} and pass it to the XML
     361  stream reader using addData(). Then you call your custom parsing
     362  function that reads the XML events from the reader.
    343363
    344364  \section1 Performance and memory consumption
     
    430450    if (d->deleteDevice)
    431451        delete d->device;
    432     delete d;
    433452}
    434453
     
    569588  QXmlStreamReader::Invalid.
    570589
    571   The exception is when error() return PrematureEndOfDocumentError.
     590  The exception is when error() return PrematureEndOfDocumentError.
    572591  This error is reported when the end of an otherwise well-formed
    573592  chunk of XML is reached, but the chunk doesn't represent a complete
     
    618637}
    619638
     639
     640
     641
     642
     643
     644
     645
     646
     647
     648
     649
     650
     651
     652
     653
     654
     655
     656
     657
     658
     659
     660
     661
     662
     663
     664
     665
     666
     667
     668
     669
     670
     671
     672
     673
     674
     675
     676
     677
     678
     679
     680
     681
     682
     683
     684
     685
     686
     687
     688
    620689/*
    621690 * Use the following Perl script to generate the error string index list:
     
    630699    $counter += length 1 + $_;
    631700}
    632 print "    \"\\0\";\n\nstatic const int QXmlStreamReader_tokenTypeString_indices[] = {\n    ";
     701print "    \"\\0\";\n\nstatic const t QXmlStreamReader_tokenTypeString_indices[] = {\n    ";
    633702for ($j = 0; $j < $i; ++$j) {
    634703    printf "$sizes[$j], ";
     
    661730    "DTD\0"
    662731    "EntityReference\0"
    663     "ProcessingInstruction\0"
    664     "\0";
    665 
    666 static const int QXmlStreamReader_tokenTypeString_indices[] = {
     732    "ProcessingInstruction\0";
     733
     734static const short QXmlStreamReader_tokenTypeString_indices[] = {
    667735    0, 8, 16, 30, 42, 55, 66, 77, 85, 89, 105, 0
    668736};
     
    820888    stack_size <<= 1;
    821889    sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value)));
     890
    822891    state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
     892
    823893}
    824894
     
    20182088  The function concatenates text() when it reads either \l Characters
    20192089  or EntityReference tokens, but skips ProcessingInstruction and \l
    2020   Comment. In case anything else is read before reaching EndElement,
    2021   the function returns what it read so far and raises an
    2022   UnexpectedElementError. If the current token is not StartElement, an
    2023   empty string is returned.
    2024  */
    2025 QString QXmlStreamReader::readElementText()
     2090  Comment. If the current token is not StartElement, an empty string is
     2091  returned.
     2092
     2093  The \a behaviour defines what happens in case anything else is
     2094  read before reaching EndElement. The function can include the text from
     2095  child elements (useful for example for HTML), ignore child elements, or
     2096  raise an UnexpectedElementError and return what was read so far.
     2097
     2098  \since 4.6
     2099 */
     2100QString QXmlStreamReader::readElementText(ReadElementTextBehaviour behaviour)
    20262101{
    20272102    Q_D(QXmlStreamReader);
     
    20392114            case Comment:
    20402115                break;
     2116
     2117
     2118
     2119
     2120
     2121
     2122
     2123
     2124
    20412125            default:
    2042                 if (!d->error)
    2043                     d->raiseError(UnexpectedElementError, QXmlStream::tr("Expected character data."));
    2044                 return result;
     2126                if (d->error || behaviour == ErrorOnUnexpectedElement) {
     2127                    if (!d->error)
     2128                        d->raiseError(UnexpectedElementError, QXmlStream::tr("Expected character data."));
     2129                    return result;
     2130                }
    20452131            }
    20462132        }
    20472133    }
    20482134    return QString();
     2135
     2136
     2137
     2138
     2139
     2140
     2141
     2142
     2143
     2144
    20492145}
    20502146
     
    27892885  simple streaming API.
    27902886
    2791   \mainclass
    2792   \inmodule QtXml
    27932887  \ingroup xml-tools
    27942888
     
    28492943
    28502944  The \l{QXmlStream Bookmarks Example} illustrates how to use a
    2851   subclassed stream writer to write an XML bookmark file (XBEL) that
     2945  stream writer to write an XML bookmark file (XBEL) that
    28522946  was previously read in by a QXmlStreamReader.
    28532947
     
    30593153        int n = ++namespacePrefixCount;
    30603154        forever {
    3061             s = QLatin1String("n") + QString::number(n++);
     3155            s = QLatin1) + QString::number(n++);
    30623156            int j = namespaceDeclarations.size() - 2;
    30633157            while (j >= 0 && namespaceDeclarations.at(j).prefix != s)
     
    31323226QXmlStreamWriter::~QXmlStreamWriter()
    31333227{
    3134     Q_D(QXmlStreamWriter);
    3135     delete d;
    31363228}
    31373229
     
    34123504    Q_D(QXmlStreamWriter);
    34133505    Q_ASSERT(!text.contains(QLatin1String("--")) && !text.endsWith(QLatin1Char('-')));
    3414     if (!d->finishStartElement() && d->autoFormatting)
     3506    if (!d->finishStartElement() && d->autoFormatting)
    34153507        d->indent(d->tagStack.size());
    34163508    d->write("<!--");
    34173509    d->write(text);
    34183510    d->write("-->");
     3511
    34193512}
    34203513
Note: See TracChangeset for help on using the changeset viewer.