summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qstringconverter.h
Commit message (Collapse)AuthorAgeFilesLines
* Fix some qdoc warningsFriedemann Kleint2020-07-211-1/+1
| | | | | | | | | | | | | | | | | | src/corelib/text/qstringconverter.h:160:54: error: no matching constructor for initialization of 'QStringConverterBase::State' src/corelib/text/qstringconverter.h:72:19: note: candidate constructor not viable: no known conversion from 'QFlags<QStringConverter::Flag>' to 'QFlags<QStringConverterBase::Flag>' for 1st argument src/corelib/text/qstringconverter.h:75:9: note: candidate constructor not viable: no known conversion from 'QStringConverter::Flags' (aka 'QFlags<QStringConverter::Flag>') to 'QStringConverterBase::State' for 1st argument src/corelib/text/qstringconverter.h:108:24: note: candidate constructor not viable: no known conversion from 'QStringConverter::Flags' (aka 'QFlags<QStringConverter::Flag>') to 'const QStringConverterBase::State' for 1st argument src/corelib/text/qstringconverter.h:159:32: warning: constexpr constructor that does not initialize all members is a C++20 extension [-Wc++20-extensions] src/corelib/text/qstringconverter.h:187:11: note: member not initialized by constructor src/corelib/kernel/qproperty.h:403:14: error: deduction guide must be declared in the same scope as template 'QProperty' src/corelib/kernel/qproperty.h:202:7: note: template is declared here src/corelib/kernel/qproperty.h:403:14: error: deduction guide declaration without trailing return type src/gui/painting/qregion.h:139:5: error: unknown type name 'HRGN' src/gui/painting/qregion.h:140:29: error: unknown type name 'HRGN' Change-Id: I3c195a60ceeb51664368a4aeef90c70c31954fc3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Add explicit encode()/decode() methods to QStringConverterLars Knoll2020-06-261-4/+22
| | | | | | | | | The functional style interface is nice, but does feel alien in some contexts, so better also have explicit encode and decode methods. Change-Id: Ic07ced15f65cdb3a7f1cf044041e341d2ef87f79 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Fix QString{Encoder|Decoder} documentationKarsten Heimrich2020-06-181-4/+4
| | | | | | Change-Id: I8e29846db77581953d90c818060950744cb9f521 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Don't change the implementation of a method depending on QT_USE_QSTRINGUILDERLars Knoll2020-05-261-23/+13
| | | | | | | | | | | | | | | | | | | | | | | This is rather evil and caused crashes in static builds, when library and application where compiler with different settings of the QT_USE_QSTRINGBUILDER flag. The reason is that the implementation of QStringDecoder::operator() was different (and returning different data) with or without the setting. The compiler would thus create two very different versions of this method in different .o files. When linking the app, one of the implementations would be chosen, leading to crashes in places where the other one was expected. Fix this by only providing the QStringBuilder enabled version of the methods. They return a temporary object that's converatable to a QString/QByteArray anyway. Make sure that qdoc shows a simple signature. As a drive by fix a compile error in a code path that didn't get hit so far. Change-Id: I312fa564d0bc6b464f2b4466de1d53841f7b7b0f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Document the string converter classesLars Knoll2020-05-141-12/+26
| | | | | | | | | | Document QStringConverter, QStringDecoder and QStringEncoder. In addition, do some touches to the API, renaming one enum value, add a flags argument to one constructor and make some members private. Change-Id: I8f99dc3d98fb8860cf6fa46301e34b7eb400511b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Optimize appending to an existing stringLars Knoll2020-05-141-0/+22
| | | | | | | | Optimize the common pattern of "str += decode(data);" and "bytearray += encode(string);" Change-Id: I1da621fa1ad400f23c9718ecf8ae64c00d9d459c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add a method to determine the encoding for encoded HTML dataLars Knoll2020-05-141-0/+1
| | | | | | | This is a replacement for Qt::codecForHtml(). Change-Id: I31f03518fd9c70507cbd210a8bcf405b6a0106b1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QStringConverter::encodingForData()Lars Knoll2020-05-141-0/+1
| | | | | | | | Add method that tries to determine the encoding of the data from an initial byte order mark. Change-Id: I348c51a3d4db9b434af53359b739a7e17acfc760 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add methods to convert between encoding and name to QStringConverterLars Knoll2020-05-141-1/+7
| | | | | | | | Add static methods that allow converting between a name for an encoding and the Encoding enum. Change-Id: I12bc503cf757ea31d3ca8d5e1f1216efddcb16d4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Construct a string converter by nameLars Knoll2020-05-141-0/+20
| | | | | | | | | | | Add a constructor, that allows constructing a string converter by name. This is required in some cases and also makes it possible to (in the future) extend the API to 3rd party encodings. Also add a name() accessor. Change-Id: I606d6ce9405ee967f76197b803615e27c5b001cf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Ensure the conversion methods in qstringconverter always get a valid stateLars Knoll2020-05-141-5/+4
| | | | | | | | | | | | Make sure that the conversion methods always get a valid state. This is already the ecase then using the new QStringConverter API, ensure the old QTextCodec API also passes in a valid state. This helps simplify the logic inside those methods. Change-Id: I1945e98cdefd46bf1427e11984337f1d62abcaa2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Clean up the Flag handling in QStringConverterLars Knoll2020-05-141-14/+14
| | | | | | | | | | | | | | | 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>
* Enable using QStringConverter together with QStringBuilderLars Knoll2020-05-141-6/+99
| | | | | | | | | | The way the new converters are structured allows us to use them together with QStringBuilder. Like this, we can avoid additional and unnecessary copies of the data. Change-Id: I168da3860537fe81a1eb62632e4d9a6680f86af1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Allow moving of string converter objectsLars Knoll2020-05-141-0/+19
| | | | | | | They are still not copyable, but can be moved. Change-Id: Id66e35be4ecdaa781ecb9212d646d224b1767913 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add Latin1 to the set of supported encodings in QStringConverterLars Knoll2020-05-141-0/+1
| | | | | | | | | | | | | Latin1 is the only non Unicode encoding that is still being used to some extent. Current web site statistics show that it is being used in ~2% of all web sites. An additional 1% of web sites use Windows1251 (which is almost the same as latin1). As it's trivial to support this encoding, we keep it supported in QStringConverter. Change-Id: I0eff53a490b6c43d3e474107e7823be245d1715a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move local8bit conversion over to qutfsupportLars Knoll2020-05-141-1/+2
| | | | | | | | Local8Bit is always UTF-8 except for Windows platforms. Also add a Locale encoding to QStringConverter. Change-Id: I8d729931fd4c1d7fc6857696b6442a44def3fd9d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Start work on a new API to replace QTextCodecLars Knoll2020-05-141-0/+195
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>