OpenCoverage

qstringlist.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qstringlist.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtCore module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include <qstringlist.h>-
41#include <qset.h>-
42#include <qregularexpression.h>-
43-
44#include <algorithm>-
45-
46QT_BEGIN_NAMESPACE-
47-
48/*! \typedef QStringListIterator-
49 \relates QStringList-
50-
51 The QStringListIterator type definition provides a Java-style const-
52 iterator for QStringList.-
53-
54 QStringList provides both \l{Java-style iterators} and-
55 \l{STL-style iterators}. The Java-style const iterator is simply-
56 a type definition for QListIterator<QString>.-
57-
58 \sa QMutableStringListIterator, QStringList::const_iterator-
59*/-
60-
61/*! \typedef QMutableStringListIterator-
62 \relates QStringList-
63-
64 The QStringListIterator type definition provides a Java-style-
65 non-const iterator for QStringList.-
66-
67 QStringList provides both \l{Java-style iterators} and-
68 \l{STL-style iterators}. The Java-style non-const iterator is-
69 simply a type definition for QMutableListIterator<QString>.-
70-
71 \sa QStringListIterator, QStringList::iterator-
72*/-
73-
74/*!-
75 \class QStringList-
76 \inmodule QtCore-
77 \brief The QStringList class provides a list of strings.-
78-
79 \ingroup tools-
80 \ingroup shared-
81 \ingroup string-processing-
82-
83 \reentrant-
84-
85 QStringList inherits from QList<QString>. Like QList, QStringList is-
86 \l{implicitly shared}. It provides fast index-based access as well as fast-
87 insertions and removals. Passing string lists as value parameters is both-
88 fast and safe.-
89-
90 All of QList's functionality also applies to QStringList. For example, you-
91 can use isEmpty() to test whether the list is empty, and you can call-
92 functions like append(), prepend(), insert(), replace(), removeAll(),-
93 removeAt(), removeFirst(), removeLast(), and removeOne() to modify a-
94 QStringList. In addition, QStringList provides a few convenience-
95 functions that make handling lists of strings easier:-
96-
97 \tableofcontents-
98-
99 \section1 Adding Strings-
100-
101 Strings can be added to a list using the \l-
102 {QList::append()}{append()}, \l-
103 {QList::operator+=()}{operator+=()} and \l-
104 {QStringList::operator<<()}{operator<<()} functions. For example:-
105-
106 \snippet qstringlist/main.cpp 0-
107-
108 \section1 Iterating Over the Strings-
109-
110 To iterate over a list, you can either use index positions or-
111 QList's Java-style and STL-style iterator types:-
112-
113 Indexing:-
114-
115 \snippet qstringlist/main.cpp 1-
116-
117 Java-style iterator:-
118-
119 \snippet qstringlist/main.cpp 2-
120-
121 STL-style iterator:-
122-
123 \snippet qstringlist/main.cpp 3-
124-
125 The QStringListIterator class is simply a type definition for-
126 QListIterator<QString>. QStringList also provide the-
127 QMutableStringListIterator class which is a type definition for-
128 QMutableListIterator<QString>.-
129-
130 \section1 Manipulating the Strings-
131-
132 QStringList provides several functions allowing you to manipulate-
133 the contents of a list. You can concatenate all the strings in a-
134 string list into a single string (with an optional separator)-
135 using the join() function. For example:-
136-
137 \snippet qstringlist/main.cpp 4-
138-
139 The argument to join can be a single character or a string.-
140-
141 To break up a string into a string list, use the QString::split()-
142 function:-
143-
144 \snippet qstringlist/main.cpp 6-
145-
146 The argument to split can be a single character, a string, or a-
147 QRegExp.-
148-
149 In addition, the \l {QStringList::operator+()}{operator+()}-
150 function allows you to concatenate two string lists into one. To-
151 sort a string list, use the sort() function.-
152-
153 QString list also provides the filter() function which lets you-
154 to extract a new list which contains only those strings which-
155 contain a particular substring (or match a particular regular-
156 expression):-
157-
158 \snippet qstringlist/main.cpp 7-
159-
160 The contains() function tells you whether the list contains a-
161 given string, while the indexOf() function returns the index of-
162 the first occurrence of the given string. The lastIndexOf()-
163 function on the other hand, returns the index of the last-
164 occurrence of the string.-
165-
166 Finally, the replaceInStrings() function calls QString::replace()-
167 on each string in the string list in turn. For example:-
168-
169 \snippet qstringlist/main.cpp 8-
170-
171 \sa QString-
172*/-
173-
174/*!-
175 \fn QStringList::QStringList()-
176-
177 Constructs an empty string list.-
178*/-
179-
180/*!-
181 \fn QStringList::QStringList(const QString &str)-
182-
183 Constructs a string list that contains the given string, \a-
184 str. Longer lists are easily created like this:-
185-
186 \snippet qstringlist/main.cpp 9-
187-
188 \sa append()-
189*/-
190-
191/*!-
192 \fn QStringList::QStringList(const QList<QString> &other)-
193-
194 Constructs a copy of \a other.-
195-
196 This operation takes \l{constant time}, because QStringList is-
197 \l{implicitly shared}. This makes returning a QStringList from a-
198 function very fast. If a shared instance is modified, it will be-
199 copied (copy-on-write), and that takes \l{linear time}.-
200-
201 \sa operator=()-
202*/-
203-
204/*!-
205 \fn QStringList::QStringList(QList<QString> &&other)-
206 \overload-
207 \since 5.4-
208-
209 Move-constructs from QList<QString>.-
210-
211 After a successful construction, \a other will be empty.-
212*/-
213-
214/*!-
215 \fn QStringList &QStringList::operator=(const QList<QString> &other)-
216 \since 5.4-
217-
218 Copy assignment operator from QList<QString>. Assigns the \a other-
219 list of strings to this string list.-
220-
221 After the operation, \a other and \c *this will be equal.-
222*/-
223-
224/*!-
225 \fn QStringList &QStringList::operator=(QList<QString> &&other)-
226 \overload-
227 \since 5.4-
228-
229 Move assignment operator from QList<QString>. Moves the \a other-
230 list of strings to this string list.-
231-
232 After the operation, \a other will be empty.-
233*/-
234-
235/*!-
236 \fn void QStringList::sort(Qt::CaseSensitivity cs)-
237-
238 Sorts the list of strings in ascending order.-
239 If \a cs is \l Qt::CaseSensitive (the default), the string comparison-
240 is case sensitive; otherwise the comparison is case insensitive.-
241-
242 Sorting is performed using the STL's std::sort() algorithm,-
243 which averages \l{linear-logarithmic time}, i.e. O(\e{n} log \e{n}).-
244-
245 If you want to sort your strings in an arbitrary order, consider-
246 using the QMap class. For example, you could use a QMap<QString,-
247 QString> to create a case-insensitive ordering (e.g. with the keys-
248 being lower-case versions of the strings, and the values being the-
249 strings), or a QMap<int, QString> to sort the strings by some-
250 integer index.-
251*/-
252-
253namespace {-
254struct CaseInsensitiveLessThan {-
255 typedef bool result_type;-
256 result_type operator()(const QString &s1, const QString &s2) const-
257 {-
258 return s1.compare(s2, Qt::CaseInsensitive) < 0;
executed 15 times by 1 test: return s1.compare(s2, Qt::CaseInsensitive) < 0;
Executed by:
  • tst_QStringList
15
259 }-
260};-
261}-
262-
263void QtPrivate::QStringList_sort(QStringList *that, Qt::CaseSensitivity cs)-
264{-
265 if (cs == Qt::CaseSensitive)
cs == Qt::CaseSensitiveDescription
TRUEevaluated 3290 times by 30 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QAlgorithms
  • tst_QApplication
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QDirIterator
  • tst_QDnsLookup
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QHostInfo
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSettings
  • tst_QSidebar
  • tst_QSortFilterProxyModel
  • ...
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QStringList
1-3290
266 std::sort(that->begin(), that->end());
executed 3290 times by 30 tests: std::sort(that->begin(), that->end());
Executed by:
  • tst_QAccessibility
  • tst_QAlgorithms
  • tst_QApplication
  • tst_QCalendarWidget
  • tst_QComboBox
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QDirIterator
  • tst_QDnsLookup
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontComboBox
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsWidget
  • tst_QGuiApplication
  • tst_QGuiVariant
  • tst_QHostInfo
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_QPrinter
  • tst_QSettings
  • tst_QSidebar
  • tst_QSortFilterProxyModel
  • ...
3290
267 else-
268 std::sort(that->begin(), that->end(), CaseInsensitiveLessThan());
executed 1 time by 1 test: std::sort(that->begin(), that->end(), CaseInsensitiveLessThan());
Executed by:
  • tst_QStringList
1
269}-
270-
271-
272/*!-
273 \fn QStringList QStringList::filter(const QString &str, Qt::CaseSensitivity cs) const-
274-
275 Returns a list of all the strings containing the substring \a str.-
276-
277 If \a cs is \l Qt::CaseSensitive (the default), the string-
278 comparison is case sensitive; otherwise the comparison is case-
279 insensitive.-
280-
281 \snippet qstringlist/main.cpp 5-
282 \snippet qstringlist/main.cpp 10-
283-
284 This is equivalent to-
285-
286 \snippet qstringlist/main.cpp 11-
287 \snippet qstringlist/main.cpp 12-
288-
289 \sa contains()-
290*/-
291QStringList QtPrivate::QStringList_filter(const QStringList *that, const QString &str,-
292 Qt::CaseSensitivity cs)-
293{-
294 QStringMatcher matcher(str, cs);-
295 QStringList res;-
296 for (int i = 0; i < that->size(); ++i)
i < that->size()Description
TRUEevaluated 782 times by 9 tests
Evaluated by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
  • tst_QSqlThread
  • tst_QStringList
  • tst_selftests - unknown status
FALSEevaluated 141 times by 9 tests
Evaluated by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
  • tst_QSqlThread
  • tst_QStringList
  • tst_selftests - unknown status
141-782
297 if (matcher.indexIn(that->at(i)) != -1)
matcher.indexI...->at(i)) != -1Description
TRUEevaluated 158 times by 9 tests
Evaluated by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
  • tst_QSqlThread
  • tst_QStringList
  • tst_selftests - unknown status
FALSEevaluated 624 times by 8 tests
Evaluated by:
  • tst_QSqlDatabase
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
  • tst_QSqlThread
  • tst_QStringList
  • tst_selftests - unknown status
158-624
298 res << that->at(i);
executed 158 times by 9 tests: res << that->at(i);
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
  • tst_QSqlThread
  • tst_QStringList
  • tst_selftests - unknown status
158
299 return res;
executed 141 times by 9 tests: return res;
Executed by:
  • tst_QSqlDatabase
  • tst_QSqlDriver
  • tst_QSqlQuery
  • tst_QSqlQueryModel
  • tst_QSqlRelationalTableModel
  • tst_QSqlTableModel
  • tst_QSqlThread
  • tst_QStringList
  • tst_selftests - unknown status
141
300}-
301-
302-
303/*!-
304 \fn bool QStringList::contains(const QString &str, Qt::CaseSensitivity cs) const-
305-
306 Returns \c true if the list contains the string \a str; otherwise-
307 returns \c false. The search is case insensitive if \a cs is-
308 Qt::CaseInsensitive; the search is case sensitive by default.-
309-
310 \sa indexOf(), lastIndexOf(), QString::contains()-
311 */-
312bool QtPrivate::QStringList_contains(const QStringList *that, const QString &str,-
313 Qt::CaseSensitivity cs)-
314{-
315 for (int i = 0; i < that->size(); ++i) {
i < that->size()Description
TRUEevaluated 204714 times by 235 tests
Evaluated by:
  • tst_Gestures
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • ...
FALSEevaluated 364727 times by 263 tests
Evaluated by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • ...
204714-364727
316 const QString & string = that->at(i);-
317 if (string.length() == str.length() && str.compare(string, cs) == 0)
string.length(...= str.length()Description
TRUEevaluated 79440 times by 207 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • tst_QCoreApplication
  • ...
FALSEevaluated 125210 times by 227 tests
Evaluated by:
  • tst_Gestures
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • ...
str.compare(string, cs) == 0Description
TRUEevaluated 44213 times by 207 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • tst_QCoreApplication
  • ...
FALSEevaluated 35291 times by 161 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • tst_QCssParser
  • tst_QDBusConnection
  • tst_QDBusConnection_SpyHook
  • tst_QDBusThreading
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • ...
35291-125210
318 return true;
executed 44213 times by 207 tests: return true;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • tst_QCoreApplication
  • ...
44213
319 }
executed 160501 times by 228 tests: end of block
Executed by:
  • tst_Gestures
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • ...
160501
320 return false;
executed 364727 times by 263 tests: return false;
Executed by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • ...
364727
321}-
322-
323#ifndef QT_NO_REGEXP-
324/*!-
325 \fn QStringList QStringList::filter(const QRegExp &rx) const-
326-
327 \overload-
328-
329 Returns a list of all the strings that match the regular-
330 expression \a rx.-
331*/-
332QStringList QtPrivate::QStringList_filter(const QStringList *that, const QRegExp &rx)-
333{-
334 QStringList res;-
335 for (int i = 0; i < that->size(); ++i)
i < that->size()Description
TRUEevaluated 56 times by 3 tests
Evaluated by:
  • tst_QProcess
  • tst_QStringList
  • tst_qstandardpaths
FALSEevaluated 18 times by 3 tests
Evaluated by:
  • tst_QProcess
  • tst_QStringList
  • tst_qstandardpaths
18-56
336 if (that->at(i).contains(rx))
that->at(i).contains(rx)Description
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QProcess
  • tst_QStringList
FALSEevaluated 53 times by 3 tests
Evaluated by:
  • tst_QProcess
  • tst_QStringList
  • tst_qstandardpaths
3-53
337 res << that->at(i);
executed 3 times by 2 tests: res << that->at(i);
Executed by:
  • tst_QProcess
  • tst_QStringList
3
338 return res;
executed 18 times by 3 tests: return res;
Executed by:
  • tst_QProcess
  • tst_QStringList
  • tst_qstandardpaths
18
339}-
340#endif-
341-
342#ifndef QT_BOOTSTRAPPED-
343#ifndef QT_NO_REGULAREXPRESSION-
344/*!-
345 \fn QStringList QStringList::filter(const QRegularExpression &re) const-
346 \overload-
347 \since 5.0-
348-
349 Returns a list of all the strings that match the regular-
350 expression \a re.-
351*/-
352QStringList QtPrivate::QStringList_filter(const QStringList *that, const QRegularExpression &re)-
353{-
354 QStringList res;-
355 for (int i = 0; i < that->size(); ++i) {
i < that->size()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QStringList
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QStringList
1-3
356 if (that->at(i).contains(re))
that->at(i).contains(re)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QStringList
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QStringList
1-2
357 res << that->at(i);
executed 2 times by 1 test: res << that->at(i);
Executed by:
  • tst_QStringList
2
358 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_QStringList
3
359 return res;
executed 1 time by 1 test: return res;
Executed by:
  • tst_QStringList
1
360}-
361#endif // QT_NO_REGULAREXPRESSION-
362#endif // QT_BOOTSTRAPPED-
363-
364/*!-
365 \fn QStringList &QStringList::replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs)-
366-
367 Returns a string list where every string has had the \a before-
368 text replaced with the \a after text wherever the \a before text-
369 is found. The \a before text is matched case-sensitively or not-
370 depending on the \a cs flag.-
371-
372 For example:-
373-
374 \snippet qstringlist/main.cpp 5-
375 \snippet qstringlist/main.cpp 13-
376-
377 \sa QString::replace()-
378*/-
379void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QString &before,-
380 const QString &after, Qt::CaseSensitivity cs)-
381{-
382 for (int i = 0; i < that->size(); ++i)
i < that->size()Description
TRUEevaluated 18 times by 2 tests
Evaluated by:
  • tst_QSortFilterProxyModel
  • tst_QStringList
FALSEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QSortFilterProxyModel
  • tst_QStringList
3-18
383 (*that)[i].replace(before, after, cs);
executed 18 times by 2 tests: (*that)[i].replace(before, after, cs);
Executed by:
  • tst_QSortFilterProxyModel
  • tst_QStringList
18
384}
executed 3 times by 2 tests: end of block
Executed by:
  • tst_QSortFilterProxyModel
  • tst_QStringList
3
385-
386-
387#ifndef QT_NO_REGEXP-
388/*!-
389 \fn QStringList &QStringList::replaceInStrings(const QRegExp &rx, const QString &after)-
390 \overload-
391-
392 Replaces every occurrence of the regexp \a rx, in each of the-
393 string lists's strings, with \a after. Returns a reference to the-
394 string list.-
395-
396 For example:-
397-
398 \snippet qstringlist/main.cpp 5-
399 \snippet qstringlist/main.cpp 14-
400-
401 For regular expressions that contain \l{capturing parentheses},-
402 occurrences of \b{\\1}, \b{\\2}, ..., in \a after are-
403 replaced with \a{rx}.cap(1), \a{rx}.cap(2), ...-
404-
405 For example:-
406-
407 \snippet qstringlist/main.cpp 5-
408 \snippet qstringlist/main.cpp 15-
409*/-
410void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegExp &rx, const QString &after)-
411{-
412 for (int i = 0; i < that->size(); ++i)
i < that->size()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QStringList
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QStringList
2-6
413 (*that)[i].replace(rx, after);
executed 6 times by 1 test: (*that)[i].replace(rx, after);
Executed by:
  • tst_QStringList
6
414}
executed 2 times by 1 test: end of block
Executed by:
  • tst_QStringList
2
415#endif-
416-
417#ifndef QT_BOOTSTRAPPED-
418#ifndef QT_NO_REGULAREXPRESSION-
419/*!-
420 \fn QStringList &QStringList::replaceInStrings(const QRegularExpression &re, const QString &after)-
421 \overload-
422 \since 5.0-
423-
424 Replaces every occurrence of the regular expression \a re, in each of the-
425 string lists's strings, with \a after. Returns a reference to the string-
426 list.-
427-
428 For example:-
429-
430 \snippet qstringlist/main.cpp 5-
431 \snippet qstringlist/main.cpp 16-
432-
433 For regular expressions that contain capturing groups,-
434 occurrences of \b{\\1}, \b{\\2}, ..., in \a after are-
435 replaced with the string captured by the corresponding capturing group.-
436-
437 For example:-
438-
439 \snippet qstringlist/main.cpp 5-
440 \snippet qstringlist/main.cpp 17-
441*/-
442void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegularExpression &re, const QString &after)-
443{-
444 for (int i = 0; i < that->size(); ++i)
i < that->size()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QStringList
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QStringList
2-6
445 (*that)[i].replace(re, after);
executed 6 times by 1 test: (*that)[i].replace(re, after);
Executed by:
  • tst_QStringList
6
446}
executed 2 times by 1 test: end of block
Executed by:
  • tst_QStringList
2
447#endif // QT_NO_REGULAREXPRESSION-
448#endif // QT_BOOTSTRAPPED-
449-
450/*!-
451 \fn QString QStringList::join(const QString &separator) const-
452-
453 Joins all the string list's strings into a single string with each-
454 element separated by the given \a separator (which can be an-
455 empty string).-
456-
457 \sa QString::split()-
458*/-
459-
460/*!-
461 \fn QString QStringList::join(QChar separator) const-
462 \since 5.0-
463 \overload join()-
464*/-
465QString QtPrivate::QStringList_join(const QStringList *that, const QChar *sep, int seplen)-
466{-
467 int totalLength = 0;-
468 const int size = that->size();-
469-
470 for (int i = 0; i < size; ++i)
i < sizeDescription
TRUEevaluated 113985 times by 139 tests
Evaluated by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • tst_QCssParser
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDnsLookup
  • tst_QDockWidget
  • ...
FALSEevaluated 47707 times by 141 tests
Evaluated by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • tst_QCssParser
  • tst_QDBusAbstractAdaptor
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDnsLookup
  • ...
47707-113985
471 totalLength += that->at(i).size();
executed 113985 times by 139 tests: totalLength += that->at(i).size();
Executed by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • tst_QCssParser
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDnsLookup
  • tst_QDockWidget
  • ...
113985
472-
473 if(size > 0)
size > 0Description
TRUEevaluated 47047 times by 139 tests
Evaluated by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • tst_QCssParser
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDnsLookup
  • tst_QDockWidget
  • ...
FALSEevaluated 660 times by 11 tests
Evaluated by:
  • tst_QDBusAbstractAdaptor
  • tst_QDnsLookup
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QHostInfo
  • tst_QMimeDatabase
  • tst_QOpenGlConfig
  • tst_QSharedPointer
  • tst_QSslCertificate
  • tst_QStringList
  • tst_Selftests
660-47047
474 totalLength += seplen * (size - 1);
executed 47047 times by 139 tests: totalLength += seplen * (size - 1);
Executed by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • tst_QCssParser
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDnsLookup
  • tst_QDockWidget
  • ...
47047
475-
476 QString res;-
477 if (totalLength == 0)
totalLength == 0Description
TRUEevaluated 798 times by 11 tests
Evaluated by:
  • tst_QDBusAbstractAdaptor
  • tst_QDnsLookup
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QHostInfo
  • tst_QMimeDatabase
  • tst_QOpenGlConfig
  • tst_QSharedPointer
  • tst_QSslCertificate
  • tst_QStringList
  • tst_Selftests
FALSEevaluated 46909 times by 139 tests
Evaluated by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • tst_QCssParser
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDnsLookup
  • tst_QDockWidget
  • ...
798-46909
478 return res;
executed 798 times by 11 tests: return res;
Executed by:
  • tst_QDBusAbstractAdaptor
  • tst_QDnsLookup
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QHostInfo
  • tst_QMimeDatabase
  • tst_QOpenGlConfig
  • tst_QSharedPointer
  • tst_QSslCertificate
  • tst_QStringList
  • tst_Selftests
798
479 res.reserve(totalLength);-
480 for (int i = 0; i < size; ++i) {
i < sizeDescription
TRUEevaluated 113847 times by 139 tests
Evaluated by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • tst_QCssParser
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDnsLookup
  • tst_QDockWidget
  • ...
FALSEevaluated 46909 times by 139 tests
Evaluated by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • tst_QCssParser
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDnsLookup
  • tst_QDockWidget
  • ...
46909-113847
481 if (i)
iDescription
TRUEevaluated 66938 times by 26 tests
Evaluated by:
  • tst_QApplication
  • tst_QCommandLineParser
  • tst_QCompleter
  • tst_QDebug
  • tst_QDnsLookup
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontCache
  • tst_QGraphicsProxyWidget
  • tst_QHostInfo
  • tst_QMimeDatabase
  • tst_QNetworkProxyFactory
  • tst_QPrinter
  • tst_QSidebar
  • tst_QSql
  • tst_QSqlDatabase
  • tst_QSqlQuery
  • tst_QSslCertificate
  • tst_QStringList
  • tst_QStyleSheetStyle
  • tst_Selftests
  • tst_languageChange
  • tst_qlogging - unknown status
  • ...
FALSEevaluated 46909 times by 139 tests
Evaluated by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • tst_QCssParser
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDnsLookup
  • tst_QDockWidget
  • ...
46909-66938
482 res.append(sep, seplen);
executed 66938 times by 26 tests: res.append(sep, seplen);
Executed by:
  • tst_QApplication
  • tst_QCommandLineParser
  • tst_QCompleter
  • tst_QDebug
  • tst_QDnsLookup
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFontCache
  • tst_QGraphicsProxyWidget
  • tst_QHostInfo
  • tst_QMimeDatabase
  • tst_QNetworkProxyFactory
  • tst_QPrinter
  • tst_QSidebar
  • tst_QSql
  • tst_QSqlDatabase
  • tst_QSqlQuery
  • tst_QSslCertificate
  • tst_QStringList
  • tst_QStyleSheetStyle
  • tst_Selftests
  • tst_languageChange
  • tst_qlogging - unknown status
  • ...
66938
483 res += that->at(i);-
484 }
executed 113847 times by 139 tests: end of block
Executed by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • tst_QCssParser
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDnsLookup
  • tst_QDockWidget
  • ...
113847
485 return res;
executed 46909 times by 139 tests: return res;
Executed by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QComplexText
  • tst_QCssParser
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDnsLookup
  • tst_QDockWidget
  • ...
46909
486}-
487-
488/*!-
489 \fn QStringList QStringList::operator+(const QStringList &other) const-
490-
491 Returns a string list that is the concatenation of this string-
492 list with the \a other string list.-
493-
494 \sa append()-
495*/-
496-
497/*!-
498 \fn QStringList &QStringList::operator<<(const QString &str)-
499-
500 Appends the given string, \a str, to this string list and returns-
501 a reference to the string list.-
502-
503 \sa append()-
504*/-
505-
506/*!-
507 \fn QStringList &QStringList::operator<<(const QStringList &other)-
508-
509 \overload-
510-
511 Appends the \a other string list to the string list and returns a reference to-
512 the latter string list.-
513*/-
514-
515/*!-
516 \fn QStringList &QStringList::operator<<(const QList<QString> &other)-
517 \since 5.4-
518-
519 \overload-
520-
521 Appends the \a other string list to the string list and returns a reference to-
522 the latter string list.-
523*/-
524-
525#ifndef QT_NO_REGEXP-
526static int indexOfMutating(const QStringList *that, QRegExp &rx, int from)-
527{-
528 if (from < 0)
from < 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QStringList
FALSEevaluated 8 times by 2 tests
Evaluated by:
  • tst_QProcess
  • tst_QStringList
3-8
529 from = qMax(from + that->size(), 0);
executed 3 times by 1 test: from = qMax(from + that->size(), 0);
Executed by:
  • tst_QStringList
3
530 for (int i = from; i < that->size(); ++i) {
i < that->size()Description
TRUEevaluated 61 times by 2 tests
Evaluated by:
  • tst_QProcess
  • tst_QStringList
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QProcess
  • tst_QStringList
6-61
531 if (rx.exactMatch(that->at(i)))
rx.exactMatch(that->at(i))Description
TRUEevaluated 5 times by 2 tests
Evaluated by:
  • tst_QProcess
  • tst_QStringList
FALSEevaluated 56 times by 2 tests
Evaluated by:
  • tst_QProcess
  • tst_QStringList
5-56
532 return i;
executed 5 times by 2 tests: return i;
Executed by:
  • tst_QProcess
  • tst_QStringList
5
533 }
executed 56 times by 2 tests: end of block
Executed by:
  • tst_QProcess
  • tst_QStringList
56
534 return -1;
executed 6 times by 2 tests: return -1;
Executed by:
  • tst_QProcess
  • tst_QStringList
6
535}-
536-
537static int lastIndexOfMutating(const QStringList *that, QRegExp &rx, int from)-
538{-
539 if (from < 0)
from < 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QStringList
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QStringList
3-6
540 from += that->size();
executed 6 times by 1 test: from += that->size();
Executed by:
  • tst_QStringList
6
541 else if (from >= that->size())
from >= that->size()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QStringList
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QStringList
1-2
542 from = that->size() - 1;
executed 1 time by 1 test: from = that->size() - 1;
Executed by:
  • tst_QStringList
1
543 for (int i = from; i >= 0; --i) {
i >= 0Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • tst_QStringList
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QStringList
3-17
544 if (rx.exactMatch(that->at(i)))
rx.exactMatch(that->at(i))Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QStringList
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tst_QStringList
6-11
545 return i;
executed 6 times by 1 test: return i;
Executed by:
  • tst_QStringList
6
546 }
executed 11 times by 1 test: end of block
Executed by:
  • tst_QStringList
11
547 return -1;
executed 3 times by 1 test: return -1;
Executed by:
  • tst_QStringList
3
548}-
549-
550/*!-
551 \fn int QStringList::indexOf(const QRegExp &rx, int from) const-
552-
553 Returns the index position of the first exact match of \a rx in-
554 the list, searching forward from index position \a from. Returns-
555 -1 if no item matched.-
556-
557 By default, this function is case sensitive.-
558-
559 \sa lastIndexOf(), contains(), QRegExp::exactMatch()-
560*/-
561int QtPrivate::QStringList_indexOf(const QStringList *that, const QRegExp &rx, int from)-
562{-
563 QRegExp rx2(rx);-
564 return indexOfMutating(that, rx2, from);
executed 2 times by 1 test: return indexOfMutating(that, rx2, from);
Executed by:
  • tst_QStringList
2
565}-
566-
567/*!-
568 \fn int QStringList::indexOf(QRegExp &rx, int from) const-
569 \overload indexOf()-
570 \since 4.5-
571-
572 Returns the index position of the first exact match of \a rx in-
573 the list, searching forward from index position \a from. Returns-
574 -1 if no item matched.-
575-
576 By default, this function is case sensitive.-
577-
578 If an item matched, the \a rx regular expression will contain the-
579 matched objects (see QRegExp::matchedLength, QRegExp::cap).-
580-
581 \sa lastIndexOf(), contains(), QRegExp::exactMatch()-
582*/-
583int QtPrivate::QStringList_indexOf(const QStringList *that, QRegExp &rx, int from)-
584{-
585 return indexOfMutating(that, rx, from);
executed 9 times by 2 tests: return indexOfMutating(that, rx, from);
Executed by:
  • tst_QProcess
  • tst_QStringList
9
586}-
587-
588/*!-
589 \fn int QStringList::lastIndexOf(const QRegExp &rx, int from) const-
590-
591 Returns the index position of the last exact match of \a rx in-
592 the list, searching backward from index position \a from. If \a-
593 from is -1 (the default), the search starts at the last item.-
594 Returns -1 if no item matched.-
595-
596 By default, this function is case sensitive.-
597-
598 \sa indexOf(), contains(), QRegExp::exactMatch()-
599*/-
600int QtPrivate::QStringList_lastIndexOf(const QStringList *that, const QRegExp &rx, int from)-
601{-
602 QRegExp rx2(rx);-
603 return lastIndexOfMutating(that, rx2, from);
executed 2 times by 1 test: return lastIndexOfMutating(that, rx2, from);
Executed by:
  • tst_QStringList
2
604}-
605-
606/*!-
607 \fn int QStringList::lastIndexOf(QRegExp &rx, int from) const-
608 \overload lastIndexOf()-
609 \since 4.5-
610-
611 Returns the index position of the last exact match of \a rx in-
612 the list, searching backward from index position \a from. If \a-
613 from is -1 (the default), the search starts at the last item.-
614 Returns -1 if no item matched.-
615-
616 By default, this function is case sensitive.-
617-
618 If an item matched, the \a rx regular expression will contain the-
619 matched objects (see QRegExp::matchedLength, QRegExp::cap).-
620-
621 \sa indexOf(), contains(), QRegExp::exactMatch()-
622*/-
623int QtPrivate::QStringList_lastIndexOf(const QStringList *that, QRegExp &rx, int from)-
624{-
625 return lastIndexOfMutating(that, rx, from);
executed 7 times by 1 test: return lastIndexOfMutating(that, rx, from);
Executed by:
  • tst_QStringList
7
626}-
627#endif-
628-
629#ifndef QT_BOOTSTRAPPED-
630#ifndef QT_NO_REGULAREXPRESSION-
631/*!-
632 \fn int QStringList::indexOf(const QRegularExpression &re, int from) const-
633 \overload-
634 \since 5.0-
635-
636 Returns the index position of the first match of \a re in-
637 the list, searching forward from index position \a from. Returns-
638 -1 if no item matched.-
639-
640 \sa lastIndexOf()-
641*/-
642int QtPrivate::QStringList_indexOf(const QStringList *that, const QRegularExpression &re, int from)-
643{-
644 if (from < 0)
from < 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QStringList
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QStringList
3-6
645 from = qMax(from + that->size(), 0);
executed 3 times by 1 test: from = qMax(from + that->size(), 0);
Executed by:
  • tst_QStringList
3
646-
647 QString exactPattern = QLatin1String("\\A(?:") + re.pattern() + QLatin1String(")\\z");-
648 QRegularExpression exactRe(exactPattern, re.patternOptions());-
649-
650 for (int i = from; i < that->size(); ++i) {
i < that->size()Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_QStringList
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QStringList
5-16
651 QRegularExpressionMatch m = exactRe.match(that->at(i));-
652 if (m.hasMatch())
m.hasMatch()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QStringList
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QStringList
4-12
653 return i;
executed 4 times by 1 test: return i;
Executed by:
  • tst_QStringList
4
654 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_QStringList
12
655 return -1;
executed 5 times by 1 test: return -1;
Executed by:
  • tst_QStringList
5
656}-
657-
658/*!-
659 \fn int QStringList::lastIndexOf(const QRegularExpression &re, int from) const-
660 \overload-
661 \since 5.0-
662-
663 Returns the index position of the last exact match of \a re in-
664 the list, searching backward from index position \a from. If \a-
665 from is -1 (the default), the search starts at the last item.-
666 Returns -1 if no item matched.-
667-
668 \sa indexOf()-
669*/-
670int QtPrivate::QStringList_lastIndexOf(const QStringList *that, const QRegularExpression &re, int from)-
671{-
672 if (from < 0)
from < 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QStringList
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QStringList
3-6
673 from += that->size();
executed 6 times by 1 test: from += that->size();
Executed by:
  • tst_QStringList
6
674 else if (from >= that->size())
from >= that->size()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QStringList
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QStringList
1-2
675 from = that->size() - 1;
executed 1 time by 1 test: from = that->size() - 1;
Executed by:
  • tst_QStringList
1
676-
677 QString exactPattern = QLatin1String("\\A(?:") + re.pattern() + QLatin1String(")\\z");-
678 QRegularExpression exactRe(exactPattern, re.patternOptions());-
679-
680 for (int i = from; i >= 0; --i) {
i >= 0Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • tst_QStringList
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QStringList
3-17
681 QRegularExpressionMatch m = exactRe.match(that->at(i));-
682 if (m.hasMatch())
m.hasMatch()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QStringList
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tst_QStringList
6-11
683 return i;
executed 6 times by 1 test: return i;
Executed by:
  • tst_QStringList
6
684 }
executed 11 times by 1 test: end of block
Executed by:
  • tst_QStringList
11
685 return -1;
executed 3 times by 1 test: return -1;
Executed by:
  • tst_QStringList
3
686}-
687#endif // QT_NO_REGULAREXPRESSION-
688#endif // QT_BOOTSTRAPPED-
689-
690/*!-
691 \fn int QStringList::removeDuplicates()-
692-
693 \since 4.5-
694-
695 This function removes duplicate entries from a list.-
696 The entries do not have to be sorted. They will retain their-
697 original order.-
698-
699 Returns the number of removed entries.-
700*/-
701int QtPrivate::QStringList_removeDuplicates(QStringList *that)-
702{-
703 int n = that->size();-
704 int j = 0;-
705 QSet<QString> seen;-
706 seen.reserve(n);-
707 int setSize = 0;-
708 for (int i = 0; i < n; ++i) {
i < nDescription
TRUEevaluated 159 times by 4 tests
Evaluated by:
  • tst_QMimeDatabase
  • tst_QStringList
  • tst_qmakelib
  • tst_qstandardpaths
FALSEevaluated 149 times by 5 tests
Evaluated by:
  • tst_QMimeDatabase
  • tst_QStringList
  • tst_qmakelib
  • tst_qmimetype
  • tst_qstandardpaths
149-159
709 const QString &s = that->at(i);-
710 seen.insert(s);-
711 if (setSize == seen.size()) // unchanged size => was already seen
setSize == seen.size()Description
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QStringList
  • tst_qmakelib
FALSEevaluated 156 times by 4 tests
Evaluated by:
  • tst_QMimeDatabase
  • tst_QStringList
  • tst_qmakelib
  • tst_qstandardpaths
3-156
712 continue;
executed 3 times by 2 tests: continue;
Executed by:
  • tst_QStringList
  • tst_qmakelib
3
713 ++setSize;-
714 if (j != i)
j != iDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmakelib
FALSEevaluated 155 times by 4 tests
Evaluated by:
  • tst_QMimeDatabase
  • tst_QStringList
  • tst_qmakelib
  • tst_qstandardpaths
1-155
715 that->swap(i, j);
executed 1 time by 1 test: that->swap(i, j);
Executed by:
  • tst_qmakelib
1
716 ++j;-
717 }
executed 156 times by 4 tests: end of block
Executed by:
  • tst_QMimeDatabase
  • tst_QStringList
  • tst_qmakelib
  • tst_qstandardpaths
156
718 if (n != j)
n != jDescription
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QStringList
  • tst_qmakelib
FALSEevaluated 146 times by 5 tests
Evaluated by:
  • tst_QMimeDatabase
  • tst_QStringList
  • tst_qmakelib
  • tst_qmimetype
  • tst_qstandardpaths
3-146
719 that->erase(that->begin() + j, that->end());
executed 3 times by 2 tests: that->erase(that->begin() + j, that->end());
Executed by:
  • tst_QStringList
  • tst_qmakelib
3
720 return n - j;
executed 149 times by 5 tests: return n - j;
Executed by:
  • tst_QMimeDatabase
  • tst_QStringList
  • tst_qmakelib
  • tst_qmimetype
  • tst_qstandardpaths
149
721}-
722-
723/*! \fn QStringList::QStringList(std::initializer_list<QString> args)-
724 \since 4.8-
725-
726 Construct a list from a std::initializer_list given by \a args.-
727-
728 This constructor is only enabled if the compiler supports C++11 initializer-
729 lists.-
730*/-
731-
732-
733QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9