From 825f98815683faea06144ab0262129b0367798ee Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 2 Oct 2018 12:59:24 +0200 Subject: Modernize the "textcodec" feature Also clean up QTextCodec usage in qmake build and some includes of qtextcodec.h. Change-Id: I0475b82690024054add4e85a8724c8ea3adcf62a Reviewed-by: Edward Welbourne Reviewed-by: Oswald Buddenhagen --- src/xml/dom/qdom.cpp | 10 ++++++---- src/xml/sax/qxml.cpp | 14 ++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'src/xml') diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index 91796106a2..5893d8448e 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -49,7 +49,9 @@ #include #include #include +#if QT_CONFIG(textcodec) #include +#endif #include #include #include "private/qxml_p.h" @@ -4149,7 +4151,7 @@ static QString encodeText(const QString &str, const bool performAVN = false, const bool encodeEOLs = false) { -#ifdef QT_NO_TEXTCODEC +#if !QT_CONFIG(textcodec) Q_UNUSED(s); #else const QTextCodec *const codec = s.codec(); @@ -4191,7 +4193,7 @@ static QString encodeText(const QString &str, len += 4; i += 5; } else { -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) if(codec->canEncode(ati)) ++i; else @@ -6428,7 +6430,7 @@ void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNod const QDomNodePrivate* n = first; if(encUsed == QDomNode::EncodingFromDocument) { -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) const QDomNodePrivate* n = first; QTextCodec *codec = 0; @@ -6464,7 +6466,7 @@ void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNod else { // Write out the XML declaration. -#ifdef QT_NO_TEXTCODEC +#if !QT_CONFIG(textcodec) const QLatin1String codecName("iso-8859-1"); #else const QTextCodec *const codec = s.codec(); diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index 168e8c3cb4..7b6669b057 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -39,7 +39,9 @@ #include "qxml.h" #include "qxml_p.h" +#if QT_CONFIG(textcodec) #include "qtextcodec.h" +#endif #include "qbuffer.h" #include "qregexp.h" #include "qmap.h" @@ -237,7 +239,7 @@ public: int pos; int length; bool nextReturnedEndOfData; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) QTextDecoder *encMapper; #endif @@ -1075,7 +1077,7 @@ void QXmlInputSource::init() d->inputStream = 0; setData(QString()); -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) d->encMapper = 0; #endif d->nextReturnedEndOfData = true; // first call to next() will call fetchData() @@ -1121,7 +1123,7 @@ QXmlInputSource::QXmlInputSource(QIODevice *dev) QXmlInputSource::~QXmlInputSource() { // ### close the input device. -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) delete d->encMapper; #endif delete d; @@ -1284,7 +1286,7 @@ void QXmlInputSource::fetchData() } } -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) static QString extractEncodingDecl(const QString &text, bool *needMoreText) { *needMoreText = false; @@ -1326,7 +1328,7 @@ static QString extractEncodingDecl(const QString &text, bool *needMoreText) return encoding; } -#endif // QT_NO_TEXTCODEC +#endif // textcodec /*! This function reads the XML file from \a data and tries to @@ -1341,7 +1343,7 @@ static QString extractEncodingDecl(const QString &text, bool *needMoreText) */ QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning) { -#ifdef QT_NO_TEXTCODEC +#if !QT_CONFIG(textcodec) Q_UNUSED(beginning); return QString::fromLatin1(data.constData(), data.size()); #else -- cgit v1.2.3 From d545d36c8e11dcd974244a69d2beef726be9ed9d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 12 Dec 2018 15:00:43 +0100 Subject: Remove QRegExp dependency from QtXml Use QRegularExpression instead. Change-Id: I6fc9400064ef6b7e425b140f5ffac0c9248c1ec0 Reviewed-by: Samuel Gaist --- src/xml/dom/qdom.cpp | 14 ++++++++------ src/xml/sax/qxml.cpp | 14 ++++++++++---- 2 files changed, 18 insertions(+), 10 deletions(-) (limited to 'src/xml') diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index 5893d8448e..a1f4d57da6 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -48,7 +48,9 @@ #include #include #include -#include +#if QT_CONFIG(regularexpression) +#include +#endif #if QT_CONFIG(textcodec) #include #endif @@ -6430,7 +6432,7 @@ void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNod const QDomNodePrivate* n = first; if(encUsed == QDomNode::EncodingFromDocument) { -#if QT_CONFIG(textcodec) +#if QT_CONFIG(textcodec) && QT_CONFIG(regularexpression) const QDomNodePrivate* n = first; QTextCodec *codec = 0; @@ -6438,11 +6440,11 @@ void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNod if (n && n->isProcessingInstruction() && n->nodeName() == QLatin1String("xml")) { // we have an XML declaration QString data = n->nodeValue(); - QRegExp encoding(QString::fromLatin1("encoding\\s*=\\s*((\"([^\"]*)\")|('([^']*)'))")); - encoding.indexIn(data); - QString enc = encoding.cap(3); + QRegularExpression encoding(QString::fromLatin1("encoding\\s*=\\s*((\"([^\"]*)\")|('([^']*)'))")); + auto match = encoding.match(data); + QString enc = match.captured(3); if (enc.isEmpty()) - enc = encoding.cap(5); + enc = match.captured(5); if (!enc.isEmpty()) codec = QTextCodec::codecForName(std::move(enc).toLatin1()); } diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index 7b6669b057..fa31e71cc1 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -43,7 +43,9 @@ #include "qtextcodec.h" #endif #include "qbuffer.h" -#include "qregexp.h" +#if QT_CONFIG(regularexpression) +#include "qregularexpression.h" +#endif #include "qmap.h" #include "qhash.h" #include "qstack.h" @@ -193,19 +195,23 @@ static const signed char charLookupTable[256]={ */ static bool stripTextDecl(QString& str) { - QString textDeclStart(QLatin1String("" - )); + )); QString strTmp = str.replace(textDecl, QLatin1String("")); if (strTmp.length() != str.length()) return false; // external entity has wrong TextDecl str = strTmp; +#else + return false; +#endif } return true; } -- cgit v1.2.3 From 4ee8f755722bac9ad0b6fa62ddbfed8ee9943094 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 27 Jan 2019 17:42:27 +0100 Subject: QtBase: replace 0 with \nullptr in documentation Replace 0 with \nullptr in the documentation. As a drive-by also replace some 0 with nullptr in the corresponding code. Change-Id: I914b6b2151554c06acc2d244eff004524cbb9a82 Reviewed-by: Friedemann Kleint Reviewed-by: Paul Wicking --- src/xml/sax/qxml.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/xml') diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index fa31e71cc1..f4e6937146 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -2676,9 +2676,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() */ /*! - \fn QXmlEntityResolver* QXmlReader::entityResolver() const + \fn QXmlEntityResolver *QXmlReader::entityResolver() const - Returns the entity resolver or 0 if none was set. + Returns the entity resolver or \nullptr if none was set. \sa setEntityResolver() */ @@ -2692,9 +2692,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() */ /*! - \fn QXmlDTDHandler* QXmlReader::DTDHandler() const + \fn QXmlDTDHandler *QXmlReader::DTDHandler() const - Returns the DTD handler or 0 if none was set. + Returns the DTD handler or \nullptr if none was set. \sa setDTDHandler() */ @@ -2708,9 +2708,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() */ /*! - \fn QXmlContentHandler* QXmlReader::contentHandler() const + \fn QXmlContentHandler *QXmlReader::contentHandler() const - Returns the content handler or 0 if none was set. + Returns the content handler or \nullptr if none was set. \sa setContentHandler() */ @@ -2725,9 +2725,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() */ /*! - \fn QXmlErrorHandler* QXmlReader::errorHandler() const + \fn QXmlErrorHandler *QXmlReader::errorHandler() const - Returns the error handler or 0 if none is set. + Returns the error handler or \nullptr if none is set. \sa setErrorHandler() */ @@ -2741,9 +2741,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() */ /*! - \fn QXmlLexicalHandler* QXmlReader::lexicalHandler() const + \fn QXmlLexicalHandler *QXmlReader::lexicalHandler() const - Returns the lexical handler or 0 if none was set. + Returns the lexical handler or \nullptr if none was set. \sa setLexicalHandler() */ @@ -2757,9 +2757,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() */ /*! - \fn QXmlDeclHandler* QXmlReader::declHandler() const + \fn QXmlDeclHandler *QXmlReader::declHandler() const - Returns the declaration handler or 0 if none was set. + Returns the declaration handler or \nullptr if none was set. \sa setDeclHandler() */ -- cgit v1.2.3 From a4b8e7141b3dd3bf3c2ac139b44ece0f74b054d8 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 15 Feb 2019 21:27:58 +0100 Subject: QtGui/Network/OpenGl/Widgets/Xml: use \nullptr in documentation Replace null and '\c nullptr' with \nullptr in the documentation. Change-Id: I58934eea06943309ba895833f1991629870ab45b Reviewed-by: Friedemann Kleint --- src/xml/sax/qxml.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/xml') diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index f4e6937146..0e3a87e883 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -2613,8 +2613,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() is returned. If no such feature exists the return value is undefined. - If \a ok is not 0: \c{*}\a{ok} is set to true if the reader has the - feature called \a name; otherwise \c{*}\a{ok} is set to false. + If \a ok is not \nullptr: \c{*}\a{ok} is set to true if the + reader has the feature called \a name; otherwise \c{*}\a{ok} is + set to false. \sa setFeature(), hasFeature() */ @@ -2643,7 +2644,7 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() If the reader has the property \a name, this function returns the value of the property; otherwise the return value is undefined. - If \a ok is not 0: if the reader has the \a name property + If \a ok is not \nullptr: if the reader has the \a name property \c{*}\a{ok} is set to true; otherwise \c{*}\a{ok} is set to false. \sa setProperty(), hasProperty() -- cgit v1.2.3 From 85b0ce8ca36d52db71b519ee8d2a1ce369c53a81 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Mon, 25 Feb 2019 13:54:26 +0100 Subject: Fix can not -> cannot Change-Id: Ie9992f67ca59aff662a4be046ace08640e7c2714 Reviewed-by: Paul Wicking --- src/xml/dom/qdom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/xml') diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index a1f4d57da6..cffc1974af 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -5183,7 +5183,7 @@ QDomNodePrivate* QDomTextPrivate::cloneNode(bool deep) QDomTextPrivate* QDomTextPrivate::splitText(int offset) { if (!parent()) { - qWarning("QDomText::splitText The node has no parent. So I can not split"); + qWarning("QDomText::splitText The node has no parent. So I cannot split"); return 0; } -- cgit v1.2.3 From 8d7c97d428cdf89c3419a4e13b62a9849feefce9 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 4 Apr 2019 16:46:41 +0200 Subject: Remove remaining Q_DECL_NOEXCEPT/Q_DECL_NOTHROW usage Change-Id: I91ac9e714a465cab226b211812aa46e8fe5ff2ab Reviewed-by: Thiago Macieira --- src/xml/sax/qxml.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/xml') diff --git a/src/xml/sax/qxml.h b/src/xml/sax/qxml.h index 94dc8dfb8e..26b674c894 100644 --- a/src/xml/sax/qxml.h +++ b/src/xml/sax/qxml.h @@ -118,14 +118,14 @@ public: QXmlAttributes(); #ifdef Q_COMPILER_DEFAULT_MEMBERS QXmlAttributes(const QXmlAttributes &) = default; - QXmlAttributes(QXmlAttributes &&) Q_DECL_NOTHROW = default; + QXmlAttributes(QXmlAttributes &&) noexcept = default; QXmlAttributes &operator=(const QXmlAttributes &) = default; - QXmlAttributes &operator=(QXmlAttributes &&) Q_DECL_NOTHROW = default; + QXmlAttributes &operator=(QXmlAttributes &&) noexcept = default; #endif // default members QT6_NOT_VIRTUAL ~QXmlAttributes(); - void swap(QXmlAttributes &other) Q_DECL_NOTHROW + void swap(QXmlAttributes &other) noexcept { qSwap(attList, other.attList); qSwap(d, other.d); -- cgit v1.2.3