Changeset 561 for trunk/src/xml/sax/qxml.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/xml/sax/qxml.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtXml module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 245 245 { 246 246 public: 247 QXmlParseExceptionPrivate() 248 : column(-1), line(-1) 249 { 250 } 251 QXmlParseExceptionPrivate(const QXmlParseExceptionPrivate &other) 252 : msg(other.msg), column(other.column), line(other.line), 253 pub(other.pub), sys(other.sys) 254 { 255 } 256 247 257 QString msg; 248 258 int column; … … 263 273 class QXmlSimpleReaderPrivate 264 274 { 275 public: 276 ~QXmlSimpleReaderPrivate(); 265 277 private: 266 278 // functions 267 QXmlSimpleReaderPrivate(); 268 ~QXmlSimpleReaderPrivate(); 279 QXmlSimpleReaderPrivate(QXmlSimpleReader *reader); 269 280 void initIncrementalParsing(); 270 281 … … 303 314 // used for parsing of entity references 304 315 struct XmlRef { 305 XmlRef(const QString &_name = QString(), const QString &_value = QString()) 316 XmlRef() 317 : index(0) {} 318 XmlRef(const QString &_name, const QString &_value) 306 319 : name(_name), value(_value), index(0) {} 307 320 bool isEmpty() const { return index == value.length(); } … … 349 362 350 363 // helper classes 351 Q XmlLocator *locator;364 QScopedPointer<QXmlLocator> locator; 352 365 QXmlNamespaceSupport namespaceSupport; 353 366 … … 544 557 QXmlParseException::QXmlParseException(const QString& name, int c, int l, 545 558 const QString& p, const QString& s) 546 { 547 d = new QXmlParseExceptionPrivate; 559 : d(new QXmlParseExceptionPrivate) 560 { 548 561 d->msg = name; 549 562 d->column = c; … … 554 567 555 568 /*! 569 Creates a copy of \a other. 570 */ 571 QXmlParseException::QXmlParseException(const QXmlParseException& other) : 572 d(new QXmlParseExceptionPrivate(*other.d)) 573 { 574 575 } 576 577 /*! 556 578 Destroys the QXmlParseException. 557 579 */ 558 580 QXmlParseException::~QXmlParseException() 559 581 { 560 delete d;561 582 } 562 583 … … 927 948 void QXmlNamespaceSupport::reset() 928 949 { 950 QXmlNamespaceSupportPrivate *newD = new QXmlNamespaceSupportPrivate; 929 951 delete d; 930 d = new QXmlNamespaceSupportPrivate;952 d = newD; 931 953 } 932 954 … … 1259 1281 d = new QXmlInputSourcePrivate; 1260 1282 1261 d->inputDevice = 0; 1262 d->inputStream = 0; 1263 1264 setData(QString()); 1283 QT_TRY { 1284 d->inputDevice = 0; 1285 d->inputStream = 0; 1286 1287 setData(QString()); 1265 1288 #ifndef QT_NO_TEXTCODEC 1266 d->encMapper = 0;1289 d->encMapper = 0; 1267 1290 #endif 1268 d->nextReturnedEndOfData = true; // first call to next() will call fetchData() 1269 1270 d->encodingDeclBytes.clear(); 1271 d->encodingDeclChars.clear(); 1272 d->lookingForEncodingDecl = true; 1291 d->nextReturnedEndOfData = true; // first call to next() will call fetchData() 1292 1293 d->encodingDeclBytes.clear(); 1294 d->encodingDeclChars.clear(); 1295 d->lookingForEncodingDecl = true; 1296 } QT_CATCH(...) { 1297 delete(d); 1298 QT_RETHROW; 1299 } 1273 1300 } 1274 1301 … … 2108 2135 QXmlReader::setLexicalHandler(). 2109 2136 2110 This interface's design is based on the theSAX2 extension2137 This interface's design is based on the SAX2 extension 2111 2138 LexicalHandler. 2112 2139 … … 2404 2431 \reimp 2405 2432 2406 Does nothing.2433 This reimplementation does nothing. 2407 2434 */ 2408 2435 void QXmlDefaultHandler::setDocumentLocator(QXmlLocator*) … … 2413 2440 \reimp 2414 2441 2415 Does nothing.2442 This reimplementation does nothing. 2416 2443 */ 2417 2444 bool QXmlDefaultHandler::startDocument() … … 2423 2450 \reimp 2424 2451 2425 Does nothing.2452 This reimplementation does nothing. 2426 2453 */ 2427 2454 bool QXmlDefaultHandler::endDocument() … … 2433 2460 \reimp 2434 2461 2435 Does nothing.2462 This reimplementation does nothing. 2436 2463 */ 2437 2464 bool QXmlDefaultHandler::startPrefixMapping(const QString&, const QString&) … … 2443 2470 \reimp 2444 2471 2445 Does nothing.2472 This reimplementation does nothing. 2446 2473 */ 2447 2474 bool QXmlDefaultHandler::endPrefixMapping(const QString&) … … 2453 2480 \reimp 2454 2481 2455 Does nothing.2482 This reimplementation does nothing. 2456 2483 */ 2457 2484 bool QXmlDefaultHandler::startElement(const QString&, const QString&, … … 2464 2491 \reimp 2465 2492 2466 Does nothing.2493 This reimplementation does nothing. 2467 2494 */ 2468 2495 bool QXmlDefaultHandler::endElement(const QString&, const QString&, … … 2475 2502 \reimp 2476 2503 2477 Does nothing.2504 This reimplementation does nothing. 2478 2505 */ 2479 2506 bool QXmlDefaultHandler::characters(const QString&) … … 2485 2512 \reimp 2486 2513 2487 Does nothing.2514 This reimplementation does nothing. 2488 2515 */ 2489 2516 bool QXmlDefaultHandler::ignorableWhitespace(const QString&) … … 2495 2522 \reimp 2496 2523 2497 Does nothing.2524 This reimplementation does nothing. 2498 2525 */ 2499 2526 bool QXmlDefaultHandler::processingInstruction(const QString&, … … 2506 2533 \reimp 2507 2534 2508 Does nothing.2535 This reimplementation does nothing. 2509 2536 */ 2510 2537 bool QXmlDefaultHandler::skippedEntity(const QString&) … … 2516 2543 \reimp 2517 2544 2518 Does nothing.2545 This reimplementation does nothing. 2519 2546 */ 2520 2547 bool QXmlDefaultHandler::warning(const QXmlParseException&) … … 2526 2553 \reimp 2527 2554 2528 Does nothing.2555 This reimplementation does nothing. 2529 2556 */ 2530 2557 bool QXmlDefaultHandler::error(const QXmlParseException&) … … 2536 2563 \reimp 2537 2564 2538 Does nothing.2565 This reimplementation does nothing. 2539 2566 */ 2540 2567 bool QXmlDefaultHandler::fatalError(const QXmlParseException&) … … 2546 2573 \reimp 2547 2574 2548 Does nothing.2575 This reimplementation does nothing. 2549 2576 */ 2550 2577 bool QXmlDefaultHandler::notationDecl(const QString&, const QString&, … … 2557 2584 \reimp 2558 2585 2559 Does nothing.2586 This reimplementation does nothing. 2560 2587 */ 2561 2588 bool QXmlDefaultHandler::unparsedEntityDecl(const QString&, const QString&, … … 2591 2618 \reimp 2592 2619 2593 Does nothing.2620 This reimplementation does nothing. 2594 2621 */ 2595 2622 bool QXmlDefaultHandler::startDTD(const QString&, const QString&, const QString&) … … 2601 2628 \reimp 2602 2629 2603 Does nothing.2630 This reimplementation does nothing. 2604 2631 */ 2605 2632 bool QXmlDefaultHandler::endDTD() … … 2611 2638 \reimp 2612 2639 2613 Does nothing.2640 This reimplementation does nothing. 2614 2641 */ 2615 2642 bool QXmlDefaultHandler::startEntity(const QString&) … … 2621 2648 \reimp 2622 2649 2623 Does nothing.2650 This reimplementation does nothing. 2624 2651 */ 2625 2652 bool QXmlDefaultHandler::endEntity(const QString&) … … 2631 2658 \reimp 2632 2659 2633 Does nothing.2660 This reimplementation does nothing. 2634 2661 */ 2635 2662 bool QXmlDefaultHandler::startCDATA() … … 2641 2668 \reimp 2642 2669 2643 Does nothing.2670 This reimplementation does nothing. 2644 2671 */ 2645 2672 bool QXmlDefaultHandler::endCDATA() … … 2651 2678 \reimp 2652 2679 2653 Does nothing.2680 This reimplementation does nothing. 2654 2681 */ 2655 2682 bool QXmlDefaultHandler::comment(const QString&) … … 2661 2688 \reimp 2662 2689 2663 Does nothing.2690 This reimplementation does nothing. 2664 2691 */ 2665 2692 bool QXmlDefaultHandler::attributeDecl(const QString&, const QString&, const QString&, const QString&, const QString&) … … 2671 2698 \reimp 2672 2699 2673 Does nothing.2700 This reimplementation does nothing. 2674 2701 */ 2675 2702 bool QXmlDefaultHandler::internalEntityDecl(const QString&, const QString&) … … 2681 2708 \reimp 2682 2709 2683 Does nothing.2710 This reimplementation does nothing. 2684 2711 */ 2685 2712 bool QXmlDefaultHandler::externalEntityDecl(const QString&, const QString&, const QString&) … … 2714 2741 } 2715 2742 2716 QXmlSimpleReaderPrivate::QXmlSimpleReaderPrivate() 2717 { 2743 QXmlSimpleReaderPrivate::QXmlSimpleReaderPrivate(QXmlSimpleReader *reader) 2744 { 2745 q_ptr = reader; 2718 2746 parseStack = 0; 2747 2748 locator.reset(new QXmlSimpleReaderLocator(reader)); 2749 entityRes = 0; 2750 dtdHnd = 0; 2751 contentHnd = 0; 2752 errorHnd = 0; 2753 lexicalHnd = 0; 2754 declHnd = 0; 2755 2756 // default feature settings 2757 useNamespaces = true; 2758 useNamespacePrefixes = false; 2759 reportWhitespaceCharData = true; 2760 reportEntities = false; 2719 2761 } 2720 2762 … … 2726 2768 void QXmlSimpleReaderPrivate::initIncrementalParsing() 2727 2769 { 2728 delete parseStack; 2729 parseStack = new QStack<ParseState>; 2770 if(parseStack) 2771 parseStack->clear(); 2772 else 2773 parseStack = new QStack<ParseState>; 2730 2774 } 2731 2775 … … 2969 3013 \inmodule QtXml 2970 3014 \ingroup xml-tools 2971 \mainclass 3015 2972 3016 2973 3017 This XML reader is suitable for a wide range of applications. It … … 3013 3057 parseContinue() function, until all the data has been processed. 3014 3058 3015 A common way to perform incremental parsing is to connect the 3016 \c readyRead() signal of the input source to a slot, and handle the 3017 incoming data there. For example, the following code shows how a 3018 parser for \l{http://web.resource.org/rss/1.0/}{RSS feeds} can be 3019 used to incrementally parse data that it receives from a QHttp 3020 object: 3021 3022 \snippet doc/src/snippets/xml/rsslisting/rsslisting.cpp 1 3023 3059 A common way to perform incremental parsing is to connect the \c 3060 readyRead() signal of a \l{QNetworkReply} {network reply} a slot, 3061 and handle the incoming data there. See QNetworkAccessManager. 3062 3024 3063 Aspects of the parsing behavior can be adapted using setFeature() 3025 and setProperty(). For example, the following code could be used 3026 to enable reporting of namespace prefixes to the content handler: 3064 and setProperty(). 3065 3066 \snippet doc/src/snippets/code/src_xml_sax_qxml.cpp 0 3027 3067 3028 3068 QXmlSimpleReader is not reentrant. If you want to use the class 3029 3069 in threaded code, lock the code using QXmlSimpleReader with a 3030 3070 locking mechanism, such as a QMutex. 3031 3032 \snippet doc/src/snippets/code/src_xml_sax_qxml.cpp 03033 3071 */ 3034 3072 … … 3100 3138 */ 3101 3139 QXmlSimpleReader::QXmlSimpleReader() 3102 { 3103 d_ptr = new QXmlSimpleReaderPrivate(); 3104 Q_D(QXmlSimpleReader); 3105 d->q_ptr = this; 3106 3107 d->locator = new QXmlSimpleReaderLocator(this); 3108 3109 d->entityRes = 0; 3110 d->dtdHnd = 0; 3111 d->contentHnd = 0; 3112 d->errorHnd = 0; 3113 d->lexicalHnd = 0; 3114 d->declHnd = 0; 3115 3116 // default feature settings 3117 d->useNamespaces = true; 3118 d->useNamespacePrefixes = false; 3119 d->reportWhitespaceCharData = true; 3120 d->reportEntities = false; 3140 : d_ptr(new QXmlSimpleReaderPrivate(this)) 3141 { 3121 3142 } 3122 3143 … … 3126 3147 QXmlSimpleReader::~QXmlSimpleReader() 3127 3148 { 3128 Q_D(QXmlSimpleReader);3129 delete d->locator;3130 delete d;3131 3149 } 3132 3150 … … 3138 3156 const QXmlSimpleReaderPrivate *d = d_func(); 3139 3157 3140 // Qt5 ###: Change these strings to qt software.com3158 // Qt5 ###: Change these strings to qt.nokia.com 3141 3159 if (ok != 0) 3142 3160 *ok = true; … … 3193 3211 { 3194 3212 Q_D(QXmlSimpleReader); 3195 // Qt5 ###: Change these strings to qt software.com3213 // Qt5 ###: Change these strings to qt.nokia.com 3196 3214 if (name == QLatin1String("http://xml.org/sax/features/namespaces")) { 3197 3215 d->useNamespaces = enable; … … 3211 3229 bool QXmlSimpleReader::hasFeature(const QString& name) const 3212 3230 { 3213 // Qt5 ###: Change these strings to qt software.com3231 // Qt5 ###: Change these strings to qt.nokia.com 3214 3232 if (name == QLatin1String("http://xml.org/sax/features/namespaces") 3215 3233 || name == QLatin1String("http://xml.org/sax/features/namespace-prefixes") … … 3411 3429 // call the handler 3412 3430 if (d->contentHnd) { 3413 d->contentHnd->setDocumentLocator(d->locator );3431 d->contentHnd->setDocumentLocator(d->locator.data()); 3414 3432 if (!d->contentHnd->startDocument()) { 3415 3433 d->reportParseError(d->contentHnd->errorString()); … … 5465 5483 if (skipIt) { 5466 5484 if (contentHnd) { 5467 if (!contentHnd->skippedEntity(Q String::fromLatin1("%") + ref())) {5485 if (!contentHnd->skippedEntity(QLatin1Char('%') + ref())) { 5468 5486 reportParseError(contentHnd->errorString()); 5469 5487 return false; … … 5477 5495 } else if (parsePEReference_context == InDTD) { 5478 5496 // Included as PE 5479 if (!insertXmlRef(Q String::fromLatin1(" ")+xmlRefString+QString::fromLatin1(" "), ref(), false))5497 if (!insertXmlRef(QLatin1Char(' ') + xmlRefString + QLatin1Char(' '), ref(), false)) 5480 5498 return false; 5481 5499 } … … 6729 6747 parameterEntities.insert(name(), string()); 6730 6748 if (declHnd) { 6731 if (!declHnd->internalEntityDecl(Q String::fromLatin1("%")+name(), string())) {6749 if (!declHnd->internalEntityDecl(QLatin1Char('%') + name(), string())) { 6732 6750 reportParseError(declHnd->errorString()); 6733 6751 return false; … … 6741 6759 externParameterEntities.insert(name(), QXmlSimpleReaderPrivate::ExternParameterEntity(publicId, systemId)); 6742 6760 if (declHnd) { 6743 if (!declHnd->externalEntityDecl(Q String::fromLatin1("%")+name(), publicId, systemId)) {6761 if (!declHnd->externalEntityDecl(QLatin1Char('%') + name(), publicId, systemId)) { 6744 6762 reportParseError(declHnd->errorString()); 6745 6763 return false; … … 7865 7883 if (inLiteral) { 7866 7884 QString tmp = data; 7867 xmlRefStack.push(XmlRef(name, tmp.replace(QLatin1 String("\""),7868 QLatin1String(""")).replace(QLatin1 String("'"), QLatin1String("'"))));7885 xmlRefStack.push(XmlRef(name, tmp.replace(QLatin1Char('\"'), 7886 QLatin1String(""")).replace(QLatin1Char('\''), QLatin1String("'")))); 7869 7887 } else { 7870 7888 xmlRefStack.push(XmlRef(name, data));
Note:
See TracChangeset
for help on using the changeset viewer.