summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qtextstream.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QTextStream: discard+comment the possibility of file opening failureGiuseppe D'Angelo2024-03-261-1/+4
| | | | | | | | | | | | The QTextStream(FILE*) constructor may fail to open the filehandle through QFile (e.g. if the open mode is incompatible). However QTextStream has no error report mechanism for this and still reports status Ok. This is consistent for instance with the QIODevice* constructor, where even passing a closed device sets the status to Ok. Add a comment and discard the return of open(). Change-Id: I430b96fd26e0ebca15a4d9ee640b09895bdd0b03 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Bootstrap: remove the UTF-16 and UTF-32 codecsThiago Macieira2024-03-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Unlike most of everything else in the Bootstrap lib, this is code that couldn't be eliminated by the linker because they were referenced in one static array. Maybe an exceptionally smart whole-program analysis could do it, but GCC and Clang LTO modes don't do that now. I removed the code that performed detection from HTML and from data too. I could have left the detection of UTF-8 and "other" but this code wasn't necessary. In particular, QTextStream couldn't benefit from it because it already defaults to UTF-8, so the detection code would never determine anything different from the input. Drive-by removed QStringConverter::availableCodecs() too because it was in the middle of functions #ifdef'ed out to. This reduced the size of release-mode moc text data bss dec hex filename 1079858 5440 640 1085938 1091f2 original/moc 1074386 5200 640 1080226 107ba2 updated/moc -5472 -240 0 -5712 difference Change-Id: I01ec3c774d9943adb903fffd17b7f114c42874ac Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Bootstrap: remove qnumeric.cpp by using qnumeric_p.hThiago Macieira2024-03-131-3/+4
| | | | | | | | | That is, use the inline functions that refer to <numeric_limits> and <cmath> directly, instead of the out-of-line wrappers. Someone should verify if the hacks for QNX's <math.h> are still required. Change-Id: I01ec3c774d9943adb903fffd17b7ee560b4b71b9 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Doc: Fix typoAndreas Eliasson2023-04-181-1/+1
| | | | | | | | | It should read ISO-8859-1, not IS0-5589-1. Fixes: QTBUG-112735 Pick-to: 6.5 6.2 5.15 Change-Id: I8247264d39f2af5b2f9699564cdd576df65cd9b8 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Use QtMiscUtils hex/oct-related helpersAhmad Samir2023-02-071-6/+3
| | | | | | | Thanks to Thiago for pointing them out in review. Change-Id: I14d588a8bd5ba29d43a5daeacfd55d974eb65557 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtMiscUtils: add some more character helpersAhmad Samir2023-02-071-1/+3
| | | | | | | | | | | | | isHexDigit, isOctalDigit, isAsciiDigit, isAsciiLower, isAsciiUpper, isAsciiLetterOrNumber. This de-duplicates some code through out. Rename two local lambdas that were called "isAsciiLetterOrNumber" to not conflict with the method in QtMiscUtils. Change-Id: I5b631f95b9f109136d19515f7e20b8e2fbca3d43 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Documentation: Clarify the meaning of the precision parameter for double ↵Friedemann Kleint2023-01-071-2/+5
| | | | | | | | | | | formatting Move it to the table for QLocale::toString() to make it more prominent. Explain the meaning for QTextStream::realNumberPrecision(). Pick-to: 6.5 6.4 6.2 Change-Id: Ic2da22ff6bea09e79e17f19b4636cef35dc3a615 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Document Qt Serialization with use casesJaishree Vyas2022-12-081-0/+1
| | | | | | | | | | | Added some background about Serialization with the classes and used cases. Fixes: QTBUG-103951 Pick-to: 6.4 6.3 6.2 Change-Id: I3ff179b814fc5d424f2ac2ffaf3237b90ddd7e2b Reviewed-by: Vladimir Minenko <vladimir.minenko@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTextStream: Fix logical error in setEncodingMårten Nordheim2022-09-071-1/+1
| | | | | | | | | | We only want to enable writing BOM if we have _not_ started writing. Fixes: QTBUG-106279 Pick-to: 6.2 6.3.2 6.4 6.4.0 Change-Id: Ibcbc101b931615fddb2507f01307bf9619772d7b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use SPDX license identifiersLucie Gérard2022-05-161-39/+3
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QTextStream: complete char16_t supportMarc Mutz2022-05-041-0/+8
| | | | | | | | | | ... by providing also op>> for char16_t. [ChangeLog][QtCore][QTextStream] Added op>>(char16_t&). Change-Id: I2f6cc2b2cdacd5190d364f94c1830f6de62d3b7e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QTextStream: fix streaming of char16_t'sMarc Mutz2022-05-031-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | Clazy complains about all uses of QLatin1Char these days, but if one actually applies the fixit to turn out << QLatin1Char(' '); into out << u' '; the space is now streamed as an int (20), not as a space. Fix by providing an explicit char16_t overload. [ChangeLog][QtCore][QTextStream] Added op<<(char16_t). [ChangeLog][Important Behavior Changes] QTextStream streams char16_t's as QChars now instead of outputting the numeric value. If you want to preserve the old behavior, cast the char16_t to a numeric type, such as ushort or int, and stream that. This is backwards-compatible. Pick-to: 6.3 Change-Id: I42d422cdebb27d38ac1714b22ef186642ec407e7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QtCore: Replace remaining uses of QLatin1String with QLatin1StringViewSona Kurazyan2022-03-261-4/+4
| | | | | | | Task-number: QTBUG-98434 Change-Id: Ib7c5fc0aaca6ef33b93c7486e99502c555bf20bc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QtCore: replace QLatin1String/QLatin1Char with _L1/u'' where applicableSona Kurazyan2022-03-251-17/+19
| | | | | | | | | | | As a drive-by, did also minor refactorings/improvements. Task-number: QTBUG-98434 Change-Id: I81964176ae2f07ea63674c96f47f9c6aa046854f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
* QTextStream: code tidiesGiuseppe D'Angelo2022-01-161-4/+4
| | | | | | | | | | | | Port the internals to qsizetype, and use QStringView instead of QString as a function parameter. The padding() function is changed to take a qsizetype to avoid warnings, but the maximum padding that can be specified is still limited by the range of an int (this is guarded via an assert). Change-Id: I9dd98e5a534990a1758b080900a12dc793528d19 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QTextStream: fix a dead writeMarc Mutz2021-06-171-2/+1
| | | | | | | Found by Clazy. Change-Id: Iabe4fb23f63ea8df2142dc66cd16b04526b628c2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Consolidate debug string generationAlex Trotsenko2021-05-311-45/+4
| | | | | | | | | | | | | | Several QIODevice subclasses use the qt_prettyDebug() function to get a printable representation of the buffer data for debug output. Rather than having this feature statically implemented in each respective file, this patch introduces a generic function in the QtDebugUtils namespace. Accordingly, some inaccuracies in the use-cases have been corrected. Change-Id: I1a8465cab08c8acf5fdcdba5085182511b1cbb7b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Convert a couple of APIs to use viewsLars Knoll2020-10-061-3/+3
| | | | | | | | | | | Try to get rid of APIs that use raw 'const {char, QChar} *, length' pairs. Instead, use QByteArrayView or QStringView. As QStringConverter is a new class, simply change the API to what we'd like to have. Also adjust hidden API in QStringBuilder and friends. Change-Id: I897d47f63a7b965f5574a1e51da64147f9e981f6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix qdoc warnings: QTextStream manipulators are in the Qt namespaceVolker Hilsheimer2020-09-261-4/+4
| | | | | Change-Id: I55c0c6454e27e0a002021a73f6c1cf8d8ed4d6af Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Use UTF-8 when converting 8 bit data in QTextStreamLars Knoll2020-09-151-13/+17
| | | | | | | | | This was overlooked when doing the conversion to use UTF-8 as the standard 8 bit encoding for text. Fixes: QTBUG-54942 Change-Id: Ib7b1b75b4d694648ab7143f6930b6bb1dcad19c9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTextStream: purge deprecated APIEdward Welbourne2020-08-311-37/+0
| | | | | | | All deprecated in 5.15, for removal in 6.0 Change-Id: I40415d388cfcf3e428bce3327297a775ec756eeb Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Disentangle QIODevice dependenciesLars Knoll2020-08-151-6/+6
| | | | | | | | | | | | | | | | | Move the QIODevice::OpenMode enum into a base class, so that we can remove the full QIODevice (and thus QObject) dependency from qdatastream.h and qtextstream.h. This is required so that we can include QDataStream in qmetatype.h without getting circular dependencies. As a nice side effect, QDataStream and QTextStream can now inherit QIODeviceBase and provide the OpenMode enum directly in their class scope. Change-Id: Ifa68b7b1d8d95687ed032f6c9206f92e63bfacdf Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Remove non-Qt6 compile time switches from QtCoreAllan Sandfeld Jensen2020-07-241-35/+0
| | | | | | | | We already manage to compile without this code, and none of it are full classes or separate functions suitable for qt5compat. Change-Id: I47facac7ec621cfc4b0b26214b7de37897443519 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix a number of qdoc warnings related to deprecationFriedemann Kleint2020-07-241-144/+0
| | | | | | | Remove obsolete documentation. Change-Id: Iaf4b6f9852a883dea0f256c5c89e74f6ebbe85f3 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Support digit-grouping correctlyEdward Welbourne2020-07-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Read three more values from CLDR and add a byte to the bit-fields at the end of QLocaleData, indicating the three group sizes. This adds three new parameters to various low-level formatting functions. At the same time, rename ThousandsGroup to GroupDigits, more faithfully expressing what this (internal) option means. This replaces commit 27d139128013c969a939779536485c1a80be977e with a fuller implementation that handles digit-grouping in any of the ways that CLDR supports. The formerly "Indian" formatting now also applies to at least some locales for Bangladesh, Bhutan and Sri Lanka. Fixed Costa Rica currency formatting test that wrongly put a separator after the first digit; the locale (in common with several Spanish locales) requires at least two digits before the first separator. [ChangeLog][QtCore][Important Behavior Changes] Some locales require more than one digit before the first grouping separator; others use group sizes other than three. The latter was partially supported (only for India) at 5.15 but is now systematically supported; the former is now also supported. Task-number: QTBUG-24301 Fixes: QTBUG-81050 Change-Id: I4ea4e331f3254d1f34801cddf51f3c65d3815573 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove more QStringRef overloads that aren't requiredLars Knoll2020-06-111-15/+0
| | | | | | | | The QStringView versions will do the job just fine :) Task-number: QTBUG-84319 Change-Id: I376b310deb27683fd98bbcc55e0f56014cacecc3 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Add since markers for the Qt::endl, etc.Albert Astals Cid2020-06-091-24/+72
| | | | | | | | | | | The Qt namespace was introduced in 461e89ee1a53f7669e0215f9015380c4a9d62371 which is only since 5.14 Also remove QTextStreamFunctions:: from the documentation of the deprecated functions since the QTextStreamFunctions namespace is a syntaxic workaround. Pick-to: 5.15 Change-Id: I9c15bcc49984bf5f5099c2f7df6b8adb3d2c61fb Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Get rid of some QTextCodec leftoversLars Knoll2020-05-141-1/+1
| | | | | | | There's no real dependency to QTextCodec in those files anymore. Change-Id: Ifaf19ab554fd108fa26095db4e2bd4a3e9ea427f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Get rid of QTextCodec in QTextStreamLars Knoll2020-05-141-199/+66
| | | | | | | | Use QStringConverter instead. Also change the default encoding of QTextStream to utf8. Change-Id: I30682e75fe0462d1a937539f773640c83a2d82e1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Start porting QTextStream away from QTextCodecLars Knoll2020-05-141-0/+39
| | | | | | | | | | | | As a first step add setEncoding/encoding() methods that use the QStringConverter::Encoding enum, and port all uses of setCodec()/ codec() over to the new API. Internally QTextStream still uses QTextCodec, this will be ported over to QStringConverter in a follow-up change. Change-Id: Icd764cf47b449b57f4ebd010c2dad89e6717d6c0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Clean up the Flag handling in QStringConverterLars Knoll2020-05-141-2/+2
| | | | | | | | | | | | | | | IgnoreHeader was a rather badly defined enum, in addition the utf8 and utf16 codecs where handling BOMs somewhat different for stateless decoding. Fix this by introducing explicit flags for writing a bom when encoding and not skipping the initial bom when decoding. Source compatibility for QTextCodec is done with a couple of static constexpr variables. Change-Id: I0b2d94f84c937cec1e0494c16ef448c00382691d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Start work on a new API to replace QTextCodecLars Knoll2020-05-141-1/+1
| | | | | | | | | | | | | | | The new QStringEncoder and QStringDecoder classes (with a common QStringConverter base class) are there to replace QTextCodec in Qt 6. It currently uses a trivial wrapper around the utf encoding functionality. Added some autotests, mostly copied from the text codec tests. Change-Id: Ib6eeee55fba918b9424be244cbda9dfd5096f7eb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Clean up state handling for ICU and iconv based codecsLars Knoll2020-05-101-2/+4
| | | | | | | | Get rid of the hack for the FreeFunction and instead add a proper function pointer to clear the data to the ConverterState struct. Change-Id: I104aae1a4381c69f1a254713ec76e1aeaa862cdc Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Doc: Document QTestStream manipulators under the Qt namespaceTopi Reinio2020-04-071-24/+96
| | | | | | | | | | | | | The global variants of the manipulators have been deprecated in favor of the ones in the Qt namespace. However, only one set was documented (the deprecated ones). Ensure documentation for both sets is generated, and link to the Qt:: manipulators in QTextStream documentation. Fixes: QTBUG-82532 Change-Id: I430d15f6d9a34411d1d7265031249e600f6874ef Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Doc: Mark QTextStream manipulators as deprecatedTopi Reinio2020-03-261-0/+24
| | | | | | | | and instruct to use the ones from the Qt namespace instead. Task-number: QTBUG-82532 Change-Id: I6a85f5096da8aec925a287beff136b77d113926e Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc/QtBase: replace some 0 with \nullptrChristian Ehrlicher2020-01-261-1/+1
| | | | | | | | | Replace some 'is 0' or 'are 0' where 0 referes to a nullptr with 'is \nullptr' and 'are \nullptr' Change-Id: Ida9af2971924377efe2f49f435d79e109de2bdf4 Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
* Mark the old style unprefixed stream functions deprecatedAllan Sandfeld Jensen2019-12-161-10/+42
| | | | | | | | Requires a third definition for the source-compatible but deprecated version. Change-Id: I260ae79f4547f99eed701b10e0b25222f81cd5ff Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Use quiet NaNs instead of signaling onesEdward Welbourne2019-09-041-1/+1
| | | | | | | | | | | | | | | I see no good reason why the NaN returned when reading "nan" as a double should be a signaling one; a quiet one should be just fine. [ChangeLog][QtCore][QLocale] The NaN obtained when reading "nan" as a floating-point value is now quiet rather than signaling. [ChangeLog][QtCore][QTextStream] The NaN obtained when reading "nan" as a floating-point value is now quiet rather than signaling. Change-Id: Ife477a30bfb813c611b13a33c38ea82f9e8a93eb Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Be less laissez-faire with implicit conversions to QCharMarc Mutz2019-07-091-1/+1
| | | | | | | | | | | | | QChar currently is convertible from nearly every integral type. This is bad code hygiene and should be fixed come Qt 6. The present patch is the result of compile fixes from marking these constructors explicit. As is clear from the distribution of fixes, only low-level string handling code used these implicit conversions, an indication that they're not in widespread use elsewhere. Change-Id: Ief5336f21e6d181e03ab92893b3d13a14adc7cb0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Move away from using 0 as a pointer constantAllan Sandfeld Jensen2019-06-071-13/+13
| | | | | | | | | Cleans up most of corelib to use nullptr or default enums where appropriate. Change-Id: Ifcaac14ecdaaee730f87f10941db3ce407d71ef9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Prefix textstream operators with Qt::Lars Knoll2019-05-021-2/+2
| | | | | | | As the non prefixed variants are deprecated Change-Id: I2ba09d71b9cea5203b54297a3f2332e6d44fedcf Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Clean up QTextStream functionsAllan Sandfeld Jensen2019-03-231-24/+76
| | | | | | | | | They are the only Qt symbols neither prefixed with q or with the Qt namespace. This changes preserves source and binary compatibility while making it possible to define conflicting symbols. Change-Id: I6d4181206e63faa922fa0c8b644e0a4b88826a97 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtCore: replace 0 with \nullptr in documentationChristian Ehrlicher2019-01-281-3/+3
| | | | | | | | | | | Replace 0 with \nullptr in the documentation. As a drive-by also replace some 0 with nullptr in the corresponding code. Change-Id: I101a61f5fad71cadb73bba9a8fd5dce6cc0836d0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Merge remote-tracking branch 'origin/5.11' into 5.12Liang Qi2018-11-091-12/+12
|\ | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf qmake/Makefile.unix src/gui/text/qtextdocument.cpp src/gui/text/qtextdocument.h Change-Id: Iba26da0ecbf2aa4ff4b956391cfb373f977f88c9
| * Modernize the "textcodec" featureLiang Qi2018-11-071-12/+12
| | | | | | | | | | | | | | | | | | Also clean up QTextCodec usage in qmake build and some includes of qtextcodec.h. Change-Id: I0475b82690024054add4e85a8724c8ea3adcf62a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* | Correct which codecs QTextStream::autoDetectUnicode detectsThiago Macieira2018-11-081-6/+6
| | | | | | | | | | | | Fixes: QTBUG-67187 Change-Id: If7e743cf8476463880ccfffd155f86b78a279f81 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Add QTextStream operators for QStringViewFriedemann Kleint2018-07-201-0/+15
|/ | | | | Change-Id: I72d597fa21521a04b7f7c0e41bd45ee9dabb6222 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Create corelib/serialization and move existing file formats into itThiago Macieira2018-01-261-0/+3192
This is in preparation to adding CBOR support. We don't need yet another dir for CBOR and placing it in src/corelib/json is just wrong. Change-Id: I9741f017961b410c910dfffd14ffb9d870340fa6 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>