summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qbytearray.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Unduplicate the implementations of next power of twoAllan Sandfeld Jensen2014-06-261-13/+2
| | | | | | | | | | | Qtbase contains four identical implementations of next power of two, these should be shared and the implementation made available to other qt modules, as it is also used many places outside of qtbase. [ChangeLog][QtCore][QtMath] Introduced qNextPowerOfTwo methods. Change-Id: Id23fbe5ad6bae647b30d5a4212c0330e48a50278 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Introduce std::string conversion to QByteArrayAllan Sandfeld Jensen2014-06-251-0/+21
| | | | | | | | | | | | | Add conversion methods similar to those in QString to QByteArray. This is often more useful than the QString version since std::string like QByteArray are byte arrays. [ChangeLog][QtCore][QByteArray] Added convenience methods to convert directly to and from std::string. Change-Id: I92c29d4bb1d9e06a667dd9cdd936970e2d272006 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Unify all mid() functions in QtBase.Jędrzej Nowacki2014-05-161-10/+13
| | | | | | | | | | | | | | | | | | | Up to now, Qt had at least 3 different implementations of the mid(). Only QString::mid implementation was not crashing on edge cases and was protected against overflows, therefore I picked that one as the base implementation, even if it has weird semantics for an invalid input. As a side effect QVector::mid was slightly optimized to not detach in all cases (which follows current QList behavior). Documentation of QVector::mid and QList::mid was updated to not mention "copy of data" which could suggest that the mid() result is detached. QStringRef::mid was fixed and now it follows general Qt behavior, by returning a null value for a null input. Change-Id: Ie9ff5d98372bd193d66508e6dd92b6ed1180ad9b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/stable' into devSergio Ahumada2014-03-131-0/+85
|\ | | | | | | Change-Id: Idec54e19963e8d88c711cb179cffc81596323899
| * Add Objective-C specific type converters to QByteArraySamuel Gaist2014-03-081-0/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the Objective-C NSData/CDataRef converters to QByteArray This will replace the current converters offered in QMacExtras [ChangeLog][QtCore][Objective-C] Added NSData/CDataRef converters for QByteArray Change-Id: I7a0f14bee4271798db345f3c5efd26ac671a3ea4 Reviewed-by: Jake Petroules <jake.petroules@petroules.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/stable' into devSimon Hausmann2014-02-281-6/+5
|\| | | | | | | | | | | | | Conflicts: src/network/access/qhttpthreaddelegate.cpp Change-Id: Ia15372687c93cd585967b006c0baaac3a5f29e91
| * Doc: Address some "No documentation for..." QDoc warningsSze Howe Koh2014-02-241-6/+5
| | | | | | | | | | | | | | Task-number: QTBUG-36985 Change-Id: I8619fb77e7879399064281f7bbefe5f12d3849a2 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
* | Mark the QArrayData alloc/dealloc functions as nothrowThiago Macieira2014-02-191-1/+1
|/ | | | | | | Throwing is handled at a higher level. Change-Id: I573e4ded135b61e35fbe6e188be09acf449911fc Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Centralize the merging toFloat conversionsThiago Macieira2014-02-161-1/+1
| | | | | | | | The QByteArray version was missing the overflow check that the other versions had. Change-Id: I03cd92e5e5a84c038bee1f1ee217e93e9d9a675a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Centralize the handling of all the toXxx (integral) functionsThiago Macieira2014-02-141-59/+41
| | | | | | | By way of templates. This makes the code a lot cleaner. Change-Id: Ie369561c7631b0d34d76a6852883716cc0aa89d4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* QLocalePrivate: move the stringToXxx to QLocaleDataThiago Macieira2014-02-141-3/+3
| | | | | | | | | Along with some more helper functions. There are two more functions used in QIntValidator Change-Id: I469ef40426cbb73ab515454bd5ecb12d944f5c0a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* QLocalePrivate: move the xxxToString functions to QLocaleDataThiago Macieira2014-02-141-7/+6
| | | | | | | | | | | Those functions do not need any of extra QLocale settings in QLocalePrivate, so we can move them easily, along with their flags. It's also very convenient that we can now bypass completely QLocale when formatting numbers to strings. Change-Id: I8cae64e8e2056a6b2d716758e4be79f746644732 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-02-071-18/+12
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/gui/kernel/qguiapplication.cpp src/plugins/platforms/android/androidjnimain.cpp src/plugins/platforms/android/qandroidplatformintegration.cpp src/plugins/platforms/android/qandroidplatformintegration.h src/plugins/platforms/android/qandroidplatformopenglcontext.cpp src/plugins/platforms/cocoa/qcocoawindow.h src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/sql/doc/src/sql-driver.qdoc src/widgets/widgets/qtoolbararealayout.cpp Change-Id: Ifd7e58760c3cb6bd8a7d1dd32ef83b7ec190d41e
| * Fix QByteArray documentation w.r.t. QString-related methodsGiuseppe D'Angelo2014-02-011-18/+12
| | | | | | | | | | | | | | | | There's no loss of data when converting a Unicode string to UTF-8, so don't state that in the docs. Change-Id: If26914ec674a994d9c59136448e8e4292d0412e8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | expand tabs and related whitespace fixes in *.{cpp,h,qdoc}Oswald Buddenhagen2014-01-131-4/+4
|/ | | | | | | | the diff -w for this commit is empty. Started-by: Thiago Macieira <thiago.macieira@intel.com> Change-Id: I77bb84e71c63ce75e0709e5b94bee18e3ce6ab9e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Avoid signed integer overflow by making an addition a subtractionThiago Macieira2013-11-091-1/+1
| | | | | | | | | | | The task has a very good explanation. The use-case was ba.remove(n, INT_MAX); since you can't pass -1 to the length, and that results in overflow when you add n+INT_MAX. Task-number: QTBUG-34694 Change-Id: I365eb86b2d0dabbe0bde67e4e7f33d64fd5793af Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Doc: Adding mark-up to boolean default values.Jerome Pasion2013-10-081-70/+70
| | | | | | | | | | | | | | | | | Default values should have mark-up to denote that they are code. This commit changes: -"property is true" to "property is \c true". -"Returns true" to "Returns \c true". -"property is false" to "property is \c false". -"returns true" to "returns \c true". -"returns false" to "returns \c false". src/3rdparty and non-documentation instances were ignored. Task-number: QTBUG-33360 Change-Id: Ie87eaa57af947caa1230602b61c5c46292a4cf4e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Doc: Add docs for rvalue references and move constructorsGeir Vattekar2013-09-271-0/+17
| | | | | | | | | These members were introduced in 4.8, but left undocumented. Because we consider undocumented API to be internal, the members are \since 5.2. Change-Id: I52e2840a8cfaa7f59f410b3e2a06c0942ea06539 Reviewed-by: Jerome Pasion <jerome.pasion@digia.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Base64: Implement the "base64url" encoding and the stripping of '='Thiago Macieira2013-09-141-12/+83
| | | | | | | | | The "base64url" encoding is defined in RFC 4648, which is the newest version of Base64. There are also a few situations where the ending '=' is not desired. Change-Id: I9bb9fa55817b57d125189e4e795d6fde97caea6d Reviewed-by: Richard J. Moore <rich@kde.org>
* Whitespace: re-indent the {to,from}Base64 functionsThiago Macieira2013-09-141-44/+52
| | | | | | | | The code must have been copied from somewhere, a sample implementation. Change-Id: Ieb6ac5d69824fe8a3f38710a22beb79ac986e182 Reviewed-by: Richard J. Moore <rich@kde.org>
* Remove redundant checks in some tools classesJędrzej Nowacki2013-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | This is a simple optimisation allowed to us by the fact that all platforms we run on use two's complement for the signed integers. The trick works as long as one of the two signed integers is known beforehand to be non-negative: - by definition, for any signed integer i, i <= INT_MAX - by definition, for any unsigned integer u, u >= 0 - given a signed integer x >= 0, 0U <= uint(x) <= uint(INT_MAX) - therefore, given another signed integer y of whatever value, uint(x) < uint(y) ←→ x < y && y >= 0 The trick is an optimisation because the compiler doesn't know that one of the two sides is always non-negative. Otherwise, it would do the same optimisation. Change-Id: If256ec0df4e06335805af8010bb67ce5fd3e065a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/stable' into devSergio Ahumada2013-09-071-2/+0
|\ | | | | | | Change-Id: I9ee4176f0a0078908d49896508826154c9f71530
| * Remove the size limit of QByteArray information.Leonard Lee2013-09-021-2/+0
| | | | | | | | | | | | | | | | | | | | The information is explaining implementation details rather than on how to use it effectively. The size limit of QByteArray may vary depending on available memory. Task-number: QTBUG-33037 Change-Id: I361316422ade3624a0c2864d93f87caeb654f4d7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-08-271-0/+2
|\| | | | | | | | | | | | | Conflicts: examples/widgets/doc/src/addressbook-fr.qdoc Change-Id: Id1196e8e0c6445f1616c3f29234c974d809f8e48
| * Specify maximum array size for QByteArray.Leonard Lee2013-08-211-0/+2
| | | | | | | | | | | | Task-number: QTBUG-33037 Change-Id: I3f39b1498fc70614402fca2281ffbd1a6ec4cf3f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-08-141-3/+3
|\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure mkspecs/macx-xcode/Info.plist.app mkspecs/macx-xcode/Info.plist.lib qmake/doc/qmake.qdocconf src/corelib/global/qglobal.h tests/auto/other/exceptionsafety/exceptionsafety.pro tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp Change-Id: I3c769a4a82dc2e99a12c69123fbf17613fd2ac2a
| * QByteArray: Remove some reinterpret_cast<>.Friedemann Kleint2013-07-301-3/+3
| | | | | | | | | | | | | | | | | | | | Fix warning: QByteArray(QByteArrayDataPtr dd) constructor warning C4946: reinterpret_cast used between related classes: 'QArrayData' and 'QTypedArrayData<T>'. Task-number: QTBUG-32559 Change-Id: I06356902f79ed6bf784127ff0c3a97d3263a25da Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-06-201-10/+10
|\| | | | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp tools/configure/configureapp.cpp Change-Id: I3092bd3276af14304b7ab3ae1e1cc05d11cdede0
| * Remove use of 'register' from Qt.Stephen Kelly2013-06-171-10/+10
| | | | | | | | | | | | | | | | | | | | It is deprecated and clang is starting to warn about it. Patch mostly generated by clang itself, with some careful grep and sed for the platform-specific parts. Change-Id: I8058e6db0f1b41b33a9e8f17a712739159982450 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Initialize variable to quiet valgrind.Sérgio Martins2013-06-051-0/+1
|/ | | | | | | It's accessed by the Q_ASSERT in QArrayData::data(). Change-Id: I859ef9c736b24857cd3f57f9fa54aafd36e57afc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Whitespace cleanup: remove trailing whitespaceAxel Waggershauser2013-03-161-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | Remove all trailing whitespace from the following list of files: *.cpp *.h *.conf *.qdoc *.pro *.pri *.mm *.rc *.pl *.qps *.xpm *.txt *README excluding 3rdparty, test-data and auto generated code. Note A): the only non 3rdparty c++-files that still have trailing whitespace after this change are: * src/corelib/codecs/cp949codetbl_p.h * src/corelib/codecs/qjpunicode.cpp * src/corelib/codecs/qbig5codec.cpp * src/corelib/xml/qxmlstream_p.h * src/tools/qdoc/qmlparser/qqmljsgrammar.cpp * src/tools/uic/ui4.cpp * tests/auto/other/qtokenautomaton/tokenizers/* * tests/benchmarks/corelib/tools/qstring/data.cpp * util/lexgen/tokenizer.cpp Note B): in about 30 files some overlapping 'leading tab' and 'TAB character in non-leading whitespace' issues have been fixed to make the sanity bot happy. Plus some general ws-fixes here and there as asked for during review. Change-Id: Ia713113c34d82442d6ce4d93d8b1cf545075d11d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Speed up and fix QByteArray::setNum()hjk2012-12-301-12/+34
| | | | | | | | | | | | Going through QLocale and QString is not really needed. This also makes the result of the conversion of negative numbers in bases other than 10 independent of the architecture and implements the documented behavior of treating them as unsigned types. Change-Id: Ibc231dc5241deb5cbadd9796484a8b5f79c29410 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Removed the "tst_QVector::outOfMemory" test.Christian Strømme2012-10-081-1/+1
| | | | | | | | | | | The test is useless as we assert if the requested size exceeds a certain limit. We could, as an alternative, throw an exception, but in the end it's the caller's responsibility to ensure that the requested size is a sane value. Task-number: QTBUG-27285 Change-Id: I738950a6a2b51671a54e4d25c7e4c3ac0d7f63b8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Fix QByteArray documentation errors.Mitch Curtis2012-09-131-0/+7
| | | | | | | | Add missing external resource link. Provide constructor documentation. Change-Id: I6d28a19da5c409dd0e0b48e0f693837b63de38f0 Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org> Reviewed-by: Jerome Pasion <jerome.pasion@nokia.com>
* Doc: Add \inmodule QtCore to all QtCore class doc bodiesThiago Macieira2012-08-231-0/+1
| | | | | Change-Id: I19100755c97cc155c76a859e19940e9f9222d34e Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Clarify QByteArray::size() documentation.Mitch Curtis2012-05-261-1/+6
| | | | | | | QTBUG-25438 Change-Id: I8cf9bfb295195548b6f7d4410682e4d675181a65 Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
* Remove references to to/fromAscii in QString and QByteArray main docsThiago Macieira2012-05-031-64/+50
| | | | | | | | | | | | Those functions are about to be deprecated and shouldn't be referred to in the main documentation. Since they were temporarily changed to mean UTF-8, this is not a behaviour change. The next commit will update the code to match the documentation. Change-Id: Ia8c2843c7f2b478f5691fe0224d5e631d94b1af6 Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* QLocale: Clean up QLocalePrivate implementationJohn Layt2012-04-241-3/+3
| | | | | | | | | | | | | | In Qt4 QLocalePrivate is a struct returned by a d() method. This will be unsuitable for the planned change to use ICU and may cause BIC issues. This change makes QLocalePrivate a class and creates a new struct QLocaleData to hold the data index. Further clean-ups are possible but are left for later. Change-Id: Ie316a07790f74674a3b520b735dff72695cc4060 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix MSVC conversion warnings in new bytearray code.Friedemann Kleint2012-04-201-10/+11
| | | | | | Change-Id: Ifc81564daf3fef0d7f08ae8d250ba41d3b1d5b0f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
* Doc: Prepare for building modular QtCore docs.Casper van Donderen2012-04-191-49/+49
| | | | | | | | | | | | This change fixes most qdoc errors in QtCore. There are about 900 left. The main thing this change does is moving documentation from qtcore from /doc/src to /src/corelib/doc. Other issues resolved are mis-use of qdoc commands. Change-Id: I002d01edfb13575e8bf27ce91596a577a92562d1 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com> Reviewed-by: Jerome Pasion <jerome.pasion@nokia.com>
* Make reallocData use QArrayData::AllocationOptionsJoão Abecasis2012-04-161-13/+13
| | | | | | | | | | | | | Growth computations are deferred to QArrayData::allocate, except in the case of realloc as that functionality is currently lacking in QArrayData. Since that sits in library code, anyway, it can be changed later to use a future QArrayData::reallocate. As it is, reallocData is becoming a model for QArrayData::reallocate and what it can offer to containers of POD/movable types. Change-Id: I045483f729114be43e4818149d1be1b333bcbe13 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Drop unnecessary assignmentJoão Abecasis2012-04-161-1/+0
| | | | | | | | | In this branch, !IS_RAW_DATA has already established that offset is sizeof(QByteArrayData) and realloc maintains the assumption. Change-Id: Ic160e36d7781d4c4f64a3b2ebec98c9cb605b3eb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Migrate QByteArray over QArrayData.Jędrzej Nowacki2012-04-161-53/+24
| | | | | | | | | | | | | | | | | | | For the time being QByteArrayData keeps its independent existence, for the sake of other modules. Once they have been ported to use the new initializer macros it can be changed to: struct QByteArrayData { QArrayData array; }; Extra braces can then be added to the macros. With respect to source compatibility, the only concern is with other modules, as QByteArrayData has already changed in incompatible ways with Qt 4.x Done-with: João Abecasis Change-Id: I044e2a680317431777a098feec8839a90a3d3da3 Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove explicit checks for shared_null/emptyJoão Abecasis2012-04-161-6/+6
| | | | | | | | | | | This eases porting to QArrayData and retains semantics. In append() and prepend() a conditional was generalized so that no work is done if there is nothing to add. Done-with: Jędrzej Nowacki Change-Id: Ib9e7bb572801b2434fa040cde2bf66dacf595f22 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Make QByteArray and QString keep track of terminating nullJoão Abecasis2012-04-161-22/+24
| | | | | | | | | | | | | | | | | | | | | In conceptual terms, this change increments the Data::alloc member by one for all strings allocated and maintained by these classes. Instances initialized with fromRawData retain 0 as the member value, so they are treated as immutable. This brings QByteArray and QString closer to QVector, making it possible for them to reference and share the same data in memory, in the future. It also brings them closer to QArrayData. In practical terms all comparisons to the alloc member were changed to take into account that it also tracks the terminating null character. Aside from the increment in the alloc member, there should be no user visible changes. Change-Id: I618f49022a9b1845754500c8f8706c72a68b9c7d Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make reallocData() take (unsigned) size, including nullJoão Abecasis2012-04-111-15/+15
| | | | | | | | | | | | The parameter represents an allocation size and unsigned matches the Q*Data::alloc member it ultimately represents (even if they currently differ in accounting for the null). There's still work up for grabs to ensure we avoid integer overflows when growing. Change-Id: Ib092fec37ec2ceed37bebfdc52e2de27b336328f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Don't allocate space for null when using fromRawDataJoão Abecasis2012-04-051-1/+1
| | | | | | | | In this case we only need to allocate space for the "header" data. Change-Id: I059627e47a5bae7a02c82d837c826a6ed0fd20fd Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Simplify conditionalsJoão Abecasis2012-04-051-1/+1
| | | | | | | | | | | alloc >= size is an invariant of both QString and QByteArray, unless string data is immutable (e.g., when using fromRawData()), in which case alloc will be 0, regardless of size, That's what needs to be checked here. Change-Id: Ief9e6a52a1d5ea1941d23ed3c141edfd15d2a6a7 Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>