qurlquery.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qurlquery.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2012 Intel Corporation.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtCore module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://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 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qurlquery.h"-
35#include "qurl_p.h"-
36-
37#include <QtCore/qhashfunctions.h>-
38#include <QtCore/qstringlist.h>-
39-
40QT_BEGIN_NAMESPACE-
41-
42/*!-
43 \class QUrlQuery-
44 \inmodule QtCore-
45 \since 5.0-
46-
47 \brief The QUrlQuery class provides a way to manipulate a key-value pairs in-
48 a URL's query.-
49-
50 \reentrant-
51 \ingroup io-
52 \ingroup network-
53 \ingroup shared-
54-
55 It is used to parse the query strings found in URLs like the following:-
56-
57 \image qurl-querystring.png-
58-
59 Query strings like the above are used to transmit options in the URL and are-
60 usually decoded into multiple key-value pairs. The one above would contain-
61 two entries in its list, with keys "type" and "color". QUrlQuery can also be-
62 used to create a query string suitable for use in QUrl::setQuery() from the-
63 individual components of the query.-
64-
65 The most common way of parsing a query string is to initialize it in the-
66 constructor by passing it the query string. Otherwise, the setQuery() method-
67 can be used to set the query to be parsed. That method can also be used to-
68 parse a query with non-standard delimiters, after having set them using the-
69 setQueryDelimiters() function.-
70-
71 The encoded query string can be obtained again using query(). This will take-
72 all the internally-stored items and encode the string using the delimiters.-
73-
74 \section1 Encoding-
75-
76 All of the getter methods in QUrlQuery support an optional parameter of type-
77 QUrl::ComponentFormattingOptions, including query(), which dictate how to-
78 encode the data in question. Except for QUrl::FullyDecoded, the returned value must-
79 still be considered a percent-encoded string, as there are certain values-
80 which cannot be expressed in decoded form (like control characters, byte-
81 sequences not decodable to UTF-8). For that reason, the percent character is-
82 always represented by the string "%25".-
83-
84 \section2 Handling of spaces and plus ("+")-
85-
86 Web browsers usually encode spaces found in HTML FORM elements to a plus sign-
87 ("+") and plus signs to its percent-encoded form (%2B). However, the Internet-
88 specifications governing URLs do not consider spaces and the plus character-
89 equivalent.-
90-
91 For that reason, QUrlQuery never encodes the space character to "+" and will-
92 never decode "+" to a space character. Instead, space characters will be-
93 rendered "%20" in encoded form.-
94-
95 To support encoding like that of HTML forms, QUrlQuery also never decodes the-
96 "%2B" sequence to a plus sign nor encode a plus sign. In fact, any "%2B" or-
97 "+" sequences found in the keys, values, or query string are left exactly-
98 like written (except for the uppercasing of "%2b" to "%2B").-
99-
100 \section2 Full decoding-
101-
102 With QUrl::FullyDecoded formatting, all percent-encoded sequences will be-
103 decoded fully and the '%' character is used to represent itself.-
104 QUrl::FullyDecoded should be used with care, since it may cause data loss.-
105 See the documentation of QUrl::FullyDecoded for information on what data may-
106 be lost.-
107-
108 This formatting mode should be used only when dealing with text presented to-
109 the user in contexts where percent-encoding is not desired. Note that-
110 QUrlQuery setters and query methods do not support the counterpart-
111 QUrl::DecodedMode parsing, so using QUrl::FullyDecoded to obtain a listing of-
112 keys may result in keys not found in the object.-
113-
114 \section1 Non-standard delimiters-
115-
116 By default, QUrlQuery uses an equal sign ("=") to separate a key from its-
117 value, and an ampersand ("&") to separate key-value pairs from each other. It-
118 is possible to change the delimiters that QUrlQuery uses for parsing and for-
119 reconstructing the query by calling setQueryDelimiters().-
120-
121 Non-standard delimiters should be chosen from among what RFC 3986 calls-
122 "sub-delimiters". They are:-
123-
124 \code-
125 sub-delims = "!" / "$" / "&" / "'" / "(" / ")"-
126 / "*" / "+" / "," / ";" / "="-
127 \endcode-
128-
129 Use of other characters is not supported and may result in unexpected-
130 behaviour. QUrlQuery does not verify that you passed a valid delimiter.-
131-
132 \sa QUrl-
133*/-
134-
135/*!-
136 \fn QUrlQuery &QUrlQuery::operator=(QUrlQuery &&other)-
137-
138 Move-assigns \a other to this QUrlQuery instance.-
139-
140 \since 5.2-
141*/-
142-
143typedef QList<QPair<QString, QString> > Map;-
144-
145class QUrlQueryPrivate : public QSharedData-
146{-
147public:-
148 QUrlQueryPrivate(const QString &query = QString())-
149 : valueDelimiter(QUrlQuery::defaultQueryValueDelimiter()),-
150 pairDelimiter(QUrlQuery::defaultQueryPairDelimiter())-
151 { if (!query.isEmpty()) setQuery(query); }
executed 108 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QUrlQuery
executed 53 times by 2 tests: setQuery(query);
Executed by:
  • tst_QNetworkReply
  • tst_QUrlQuery
!query.isEmpty()Description
TRUEevaluated 53 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
FALSEevaluated 55 times by 1 test
Evaluated by:
  • tst_QUrlQuery
53-108
152-
153 QString recodeFromUser(const QString &input) const;-
154 QString recodeToUser(const QString &input, QUrl::ComponentFormattingOptions encoding) const;-
155-
156 void setQuery(const QString &query);-
157-
158 void addQueryItem(const QString &key, const QString &value)-
159 { itemList.append(qMakePair(recodeFromUser(key), recodeFromUser(value))); }
executed 104 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
104
160 int findRecodedKey(const QString &key, int from = 0) const-
161 {-
162 for (int i = from; i < itemList.size(); ++i)
i < itemList.size()Description
TRUEevaluated 103 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
FALSEevaluated 17 times by 1 test
Evaluated by:
  • tst_QUrlQuery
17-103
163 if (itemList.at(i).first == key)
itemList.at(i).first == keyDescription
TRUEevaluated 59 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
FALSEevaluated 44 times by 1 test
Evaluated by:
  • tst_QUrlQuery
44-59
164 return i;
executed 59 times by 2 tests: return i;
Executed by:
  • tst_QNetworkReply
  • tst_QUrlQuery
59
165 return itemList.size();
executed 17 times by 1 test: return itemList.size();
Executed by:
  • tst_QUrlQuery
17
166 }-
167 Map::const_iterator findKey(const QString &key) const-
168 { return itemList.constBegin() + findRecodedKey(recodeFromUser(key)); }
executed 39 times by 2 tests: return itemList.constBegin() + findRecodedKey(recodeFromUser(key));
Executed by:
  • tst_QNetworkReply
  • tst_QUrlQuery
39
169 Map::iterator findKey(const QString &key)-
170 { return itemList.begin() + findRecodedKey(recodeFromUser(key)); }
executed 6 times by 1 test: return itemList.begin() + findRecodedKey(recodeFromUser(key));
Executed by:
  • tst_QUrlQuery
6
171-
172 // use QMap so we end up sorting the items by key-
173 Map itemList;-
174 QChar valueDelimiter;-
175 QChar pairDelimiter;-
176};-
177-
178template<> void QSharedDataPointer<QUrlQueryPrivate>::detach()-
179{-
180 if (d && d->ref.load() == 1)
dDescription
TRUEevaluated 111 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 55 times by 1 test
Evaluated by:
  • tst_QUrlQuery
d->ref.load() == 1Description
TRUEevaluated 107 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QUrlQuery
4-111
181 return;
executed 107 times by 1 test: return;
Executed by:
  • tst_QUrlQuery
107
182 QUrlQueryPrivate *x = (d ? new QUrlQueryPrivate(*d)
dDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 55 times by 1 test
Evaluated by:
  • tst_QUrlQuery
4-55
183 : new QUrlQueryPrivate);-
184 x->ref.ref();-
185 if (d && !d->ref.deref())
dDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 55 times by 1 test
Evaluated by:
  • tst_QUrlQuery
!d->ref.deref()Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QUrlQuery
0-55
186 delete d;
never executed: delete d;
0
187 d = x;-
188}
executed 59 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
59
189-
190// Here's how we do the encoding in QUrlQuery-
191// The RFC says these are the delimiters:-
192// gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"-
193// sub-delims = "!" / "$" / "&" / "'" / "(" / ")"-
194// / "*" / "+" / "," / ";" / "="-
195// And the definition of query is:-
196// query = *( pchar / "/" / "?" )-
197// pchar = unreserved / pct-encoded / sub-delims / ":" / "@"-
198//-
199// The strict definition of query says that it can have unencoded any-
200// unreserved, sub-delim, ":", "@", "/" and "?". Or, by exclusion, excluded-
201// delimiters are "#", "[" and "]" -- if those are present, they must be-
202// percent-encoded. The fact that "[" and "]" should be encoded is probably a-
203// mistake in the spec, so we ignore it and leave the decoded.-
204//-
205// The internal storage in the Map is equivalent to PrettyDecoded. That means-
206// the getter methods, when called with the default encoding value, will not-
207// have to recode anything (except for toString()).-
208//-
209// QUrlQuery handling of delimiters is quite simple: we never touch any of-
210// them, except for the "#" character and the pair and value delimiters. Those-
211// are always kept in their decoded forms.-
212//-
213// But when recreating the query string, in toString(), we must take care of-
214// the special delimiters: the pair and value delimiters, as well as the "#"-
215// character if unambiguous decoding is requested.-
216-
217#define decode(x) ushort(x)-
218#define leave(x) ushort(0x100 | (x))-
219#define encode(x) ushort(0x200 | (x))-
220-
221inline QString QUrlQueryPrivate::recodeFromUser(const QString &input) const-
222{-
223 // note: duplicated in setQuery()-
224 QString output;-
225 ushort prettyDecodedActions[] = {-
226 decode(pairDelimiter.unicode()),-
227 decode(valueDelimiter.unicode()),-
228 decode('#'),-
229 0-
230 };-
231 if (qt_urlRecode(output, input.constData(), input.constData() + input.length(),
qt_urlRecode(o...ecodedActions)Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 242 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
26-242
232 QUrl::DecodeReserved,
qt_urlRecode(o...ecodedActions)Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 242 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
26-242
233 prettyDecodedActions))
qt_urlRecode(o...ecodedActions)Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 242 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
26-242
234 return output;
executed 26 times by 1 test: return output;
Executed by:
  • tst_QUrlQuery
26
235 return input;
executed 242 times by 2 tests: return input;
Executed by:
  • tst_QNetworkReply
  • tst_QUrlQuery
242
236}-
237-
238inline bool idempotentRecodeToUser(QUrl::ComponentFormattingOptions encoding)-
239{-
240 return encoding == QUrl::PrettyDecoded;
executed 153 times by 2 tests: return encoding == QUrl::PrettyDecoded;
Executed by:
  • tst_QNetworkReply
  • tst_QUrlQuery
153
241}-
242-
243inline QString QUrlQueryPrivate::recodeToUser(const QString &input, QUrl::ComponentFormattingOptions encoding) const-
244{-
245 // our internal formats are stored in "PrettyDecoded" form-
246 // and there are no ambiguous characters-
247 if (idempotentRecodeToUser(encoding))
idempotentReco...User(encoding)Description
TRUEevaluated 42 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_QUrlQuery
24-42
248 return input;
executed 42 times by 2 tests: return input;
Executed by:
  • tst_QNetworkReply
  • tst_QUrlQuery
42
249-
250 if (!(encoding & QUrl::EncodeDelimiters)) {
!(encoding & Q...odeDelimiters)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_QUrlQuery
8-16
251 QString output;-
252 if (qt_urlRecode(output, input.constData(), input.constData() + input.length(),
qt_urlRecode(o..., encoding, 0)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QUrlQuery
4
253 encoding, 0))
qt_urlRecode(o..., encoding, 0)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QUrlQuery
4
254 return output;
executed 4 times by 1 test: return output;
Executed by:
  • tst_QUrlQuery
4
255 return input;
executed 4 times by 1 test: return input;
Executed by:
  • tst_QUrlQuery
4
256 }-
257-
258 // re-encode the "#" character and the query delimiter pair-
259 ushort actions[] = { encode(pairDelimiter.unicode()), encode(valueDelimiter.unicode()),-
260 encode('#'), 0 };-
261 QString output;-
262 if (qt_urlRecode(output, input.constData(), input.constData() + input.length(), encoding, actions))
qt_urlRecode(o...ding, actions)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QUrlQuery
6-10
263 return output;
executed 6 times by 1 test: return output;
Executed by:
  • tst_QUrlQuery
6
264 return input;
executed 10 times by 1 test: return input;
Executed by:
  • tst_QUrlQuery
10
265}-
266-
267void QUrlQueryPrivate::setQuery(const QString &query)-
268{-
269 ushort prettyDecodedActions[] = {-
270 decode(pairDelimiter.unicode()),-
271 decode(valueDelimiter.unicode()),-
272 decode('#'),-
273 0-
274 };-
275-
276 itemList.clear();-
277 const QChar *pos = query.constData();-
278 const QChar *const end = pos + query.size();-
279 while (pos != end) {
pos != endDescription
TRUEevaluated 79 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
FALSEevaluated 56 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
56-79
280 const QChar *begin = pos;-
281 const QChar *delimiter = 0;-
282 while (pos != end) {
pos != endDescription
TRUEevaluated 572 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
FALSEevaluated 55 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
55-572
283 // scan for the component parts of this pair-
284 if (!delimiter && pos->unicode() == valueDelimiter)
!delimiterDescription
TRUEevaluated 344 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
FALSEevaluated 228 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
pos->unicode()...valueDelimiterDescription
TRUEevaluated 69 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
FALSEevaluated 275 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
69-344
285 delimiter = pos;
executed 69 times by 2 tests: delimiter = pos;
Executed by:
  • tst_QNetworkReply
  • tst_QUrlQuery
69
286 if (pos->unicode() == pairDelimiter)
pos->unicode()... pairDelimiterDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 548 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
24-548
287 break;
executed 24 times by 1 test: break;
Executed by:
  • tst_QUrlQuery
24
288 ++pos;-
289 }
executed 548 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QUrlQuery
548
290 if (!delimiter)
!delimiterDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 69 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
10-69
291 delimiter = pos;
executed 10 times by 1 test: delimiter = pos;
Executed by:
  • tst_QUrlQuery
10
292-
293 // pos is the end of this pair (the end of the string or the pair delimiter)-
294 // delimiter points to the value delimiter or to the end of this pair-
295-
296 QString key;-
297 if (!qt_urlRecode(key, begin, delimiter,
!qt_urlRecode(...ecodedActions)Description
TRUEevaluated 67 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QUrlQuery
12-67
298 QUrl::DecodeReserved,
!qt_urlRecode(...ecodedActions)Description
TRUEevaluated 67 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QUrlQuery
12-67
299 prettyDecodedActions))
!qt_urlRecode(...ecodedActions)Description
TRUEevaluated 67 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QUrlQuery
12-67
300 key = QString(begin, delimiter - begin);
executed 67 times by 2 tests: key = QString(begin, delimiter - begin);
Executed by:
  • tst_QNetworkReply
  • tst_QUrlQuery
67
301-
302 if (delimiter == pos) {
delimiter == posDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 69 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
10-69
303 // the value delimiter wasn't found, store a null value-
304 itemList.append(qMakePair(key, QString()));-
305 } else if (delimiter + 1 == pos) {
executed 10 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
delimiter + 1 == posDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 64 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
5-64
306 // if the delimiter was found but the value is empty, store empty-but-not-null-
307 itemList.append(qMakePair(key, QString(0, Qt::Uninitialized)));-
308 } else {
executed 5 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
5
309 QString value;-
310 if (!qt_urlRecode(value, delimiter + 1, pos,
!qt_urlRecode(...ecodedActions)Description
TRUEevaluated 52 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QUrlQuery
12-52
311 QUrl::DecodeReserved,
!qt_urlRecode(...ecodedActions)Description
TRUEevaluated 52 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QUrlQuery
12-52
312 prettyDecodedActions))
!qt_urlRecode(...ecodedActions)Description
TRUEevaluated 52 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QUrlQuery
12-52
313 value = QString(delimiter + 1, pos - delimiter - 1);
executed 52 times by 2 tests: value = QString(delimiter + 1, pos - delimiter - 1);
Executed by:
  • tst_QNetworkReply
  • tst_QUrlQuery
52
314 itemList.append(qMakePair(key, value));-
315 }
executed 64 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QUrlQuery
64
316-
317 if (pos != end)
pos != endDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 55 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
24-55
318 ++pos;
executed 24 times by 1 test: ++pos;
Executed by:
  • tst_QUrlQuery
24
319 }
executed 79 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QUrlQuery
79
320}
executed 56 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QUrlQuery
56
321-
322// allow QUrlQueryPrivate to detach from null-
323template <> inline QUrlQueryPrivate *-
324QSharedDataPointer<QUrlQueryPrivate>::clone()-
325{-
326 return d ? new QUrlQueryPrivate(*d) : new QUrlQueryPrivate;
never executed: return d ? new QUrlQueryPrivate(*d) : new QUrlQueryPrivate;
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
327}-
328-
329/*!-
330 Constructs an empty QUrlQuery object. A query can be set afterwards by-
331 calling setQuery() or items can be added by using addQueryItem().-
332-
333 \sa setQuery(), addQueryItem()-
334*/-
335QUrlQuery::QUrlQuery()-
336 : d(0)-
337{-
338}
executed 60 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
60
339-
340/*!-
341 Constructs a QUrlQuery object and parses the \a queryString query string,-
342 using the default query delimiters. To parse a query string using other-
343 delimiters, you should first set them using setQueryDelimiters() and then-
344 set the query with setQuery().-
345*/-
346QUrlQuery::QUrlQuery(const QString &queryString)-
347 : d(queryString.isEmpty() ? 0 : new QUrlQueryPrivate(queryString))-
348{-
349}
executed 49 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
49
350-
351/*!-
352 Constructs a QUrlQuery object and parses the query string found in the \a-
353 url URL, using the default query delimiters. To parse a query string using-
354 other delimiters, you should first set them using setQueryDelimiters() and-
355 then set the query with setQuery().-
356-
357 \sa QUrl::query()-
358*/-
359QUrlQuery::QUrlQuery(const QUrl &url)-
360 : d(0)-
361{-
362 // use internals to avoid unnecessary recoding-
363 // ### FIXME: actually do it-
364 if (url.hasQuery())
url.hasQuery()Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-7
365 d = new QUrlQueryPrivate(url.query());
executed 7 times by 1 test: d = new QUrlQueryPrivate(url.query());
Executed by:
  • tst_QNetworkReply
7
366}
executed 7 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
7
367-
368/*!-
369 Copies the contents of the \a other QUrlQuery object, including the query-
370 delimiters.-
371*/-
372QUrlQuery::QUrlQuery(const QUrlQuery &other)-
373 : d(other.d)-
374{-
375}
executed 5 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
5
376-
377/*!-
378 Copies the contents of the \a other QUrlQuery object, including the query-
379 delimiters.-
380*/-
381QUrlQuery &QUrlQuery::operator =(const QUrlQuery &other)-
382{-
383 d = other.d;-
384 return *this;
executed 2 times by 1 test: return *this;
Executed by:
  • tst_QUrlQuery
2
385}-
386-
387/*!-
388 \fn void QUrlQuery::swap(QUrlQuery &other)-
389-
390 Swaps this URL query instance with \a other. This function is very-
391 fast and never fails.-
392*/-
393-
394/*!-
395 Destroys this QUrlQuery object.-
396*/-
397QUrlQuery::~QUrlQuery()-
398{-
399 // d auto-deletes-
400}-
401-
402/*!-
403 Returns \c true if this object and the \a other object contain the same-
404 contents, in the same order, and use the same query delimiters.-
405*/-
406bool QUrlQuery::operator ==(const QUrlQuery &other) const-
407{-
408 if (d == other.d)
d == other.dDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QUrlQuery
7-10
409 return true;
executed 7 times by 1 test: return true;
Executed by:
  • tst_QUrlQuery
7
410 if (d && other.d)-
411 // keep in sync with qHash(QUrlQuery):-
412 return d->valueDelimiter == other.d->valueDelimiter &&
executed 8 times by 1 test: return d->valueDelimiter == other.d->valueDelimiter && d->pairDelimiter == other.d->pairDelimiter && d->itemList == other.d->itemList;
Executed by:
  • tst_QUrlQuery
d->valueDelimi...valueDelimiterDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEnever evaluated
0-8
413 d->pairDelimiter == other.d->pairDelimiter &&
executed 8 times by 1 test: return d->valueDelimiter == other.d->valueDelimiter && d->pairDelimiter == other.d->pairDelimiter && d->itemList == other.d->itemList;
Executed by:
  • tst_QUrlQuery
d->pairDelimit...>pairDelimiterDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEnever evaluated
0-8
414 d->itemList == other.d->itemList;
executed 8 times by 1 test: return d->valueDelimiter == other.d->valueDelimiter && d->pairDelimiter == other.d->pairDelimiter && d->itemList == other.d->itemList;
Executed by:
  • tst_QUrlQuery
d->itemList ==...er.d->itemListDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QUrlQuery
3-8
415 return false;
executed 2 times by 1 test: return false;
Executed by:
  • tst_QUrlQuery
2
416}-
417-
418/*!-
419 \since 5.6-
420 \relates QUrlQuery-
421-
422 Returns the hash value for \a key,-
423 using \a seed to seed the calculation.-
424*/-
425uint qHash(const QUrlQuery &key, uint seed) Q_DECL_NOTHROW-
426{-
427 if (const QUrlQueryPrivate *d = key.d) {
const QUrlQuer...ate *d = key.dDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QUrlQuery
2-4
428 QtPrivate::QHashCombine hash;-
429 // keep in sync with operator==:-
430 seed = hash(seed, d->valueDelimiter);-
431 seed = hash(seed, d->pairDelimiter);-
432 seed = hash(seed, d->itemList);-
433 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
2
434 return seed;
executed 6 times by 1 test: return seed;
Executed by:
  • tst_QUrlQuery
6
435}-
436-
437/*!-
438 Returns \c true if this QUrlQuery object contains no key-value pairs, such as-
439 after being default-constructed or after parsing an empty query string.-
440-
441 \sa setQuery(), clear()-
442*/-
443bool QUrlQuery::isEmpty() const-
444{-
445 return d ? d->itemList.isEmpty() : true;
executed 37 times by 1 test: return d ? d->itemList.isEmpty() : true;
Executed by:
  • tst_QUrlQuery
dDescription
TRUEevaluated 31 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QUrlQuery
6-37
446}-
447-
448/*!-
449 \internal-
450*/-
451bool QUrlQuery::isDetached() const-
452{-
453 return d && d->ref.load() == 1;
executed 4 times by 1 test: return d && d->ref.load() == 1;
Executed by:
  • tst_QUrlQuery
d->ref.load() == 1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEnever evaluated
0-4
454}-
455-
456/*!-
457 Clears this QUrlQuery object by removing all of the key-value pairs-
458 currently stored. If the query delimiters have been changed, this function-
459 will leave them with their changed values.-
460-
461 \sa isEmpty(), setQueryDelimiters()-
462*/-
463void QUrlQuery::clear()-
464{-
465 if (d.constData())
d.constData()Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QUrlQuery
5-16
466 d->itemList.clear();
executed 16 times by 1 test: d->itemList.clear();
Executed by:
  • tst_QUrlQuery
16
467}
executed 21 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
21
468-
469/*!-
470 Parses the query string in \a queryString and sets the internal items to-
471 the values found there. If any delimiters have been specified with-
472 setQueryDelimiters(), this function will use them instead of the default-
473 delimiters to parse the string.-
474*/-
475void QUrlQuery::setQuery(const QString &queryString)-
476{-
477 d->setQuery(queryString);-
478}
executed 3 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
3
479-
480static void recodeAndAppend(QString &to, const QString &input,-
481 QUrl::ComponentFormattingOptions encoding, const ushort *tableModifications)-
482{-
483 if (!qt_urlRecode(to, input.constData(), input.constData() + input.length(), encoding, tableModifications))
!qt_urlRecode(...Modifications)Description
TRUEevaluated 123 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_QUrlQuery
32-123
484 to += input;
executed 123 times by 1 test: to += input;
Executed by:
  • tst_QUrlQuery
123
485}
executed 155 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
155
486-
487/*!-
488 Returns the reconstructed query string, formed from the key-value pairs-
489 currently stored in this QUrlQuery object and separated by the query-
490 delimiters chosen for this object. The keys and values are encoded using-
491 the options given by the \a encoding parameter.-
492-
493 For this function, the only ambiguous delimiter is the hash ("#"), as in-
494 URLs it is used to separate the query string from the fragment that may-
495 follow.-
496-
497 The order of the key-value pairs in the returned string is exactly the same-
498 as in the original query.-
499-
500 \sa setQuery(), QUrl::setQuery(), QUrl::fragment(), {encoding}{Encoding}-
501*/-
502QString QUrlQuery::query(QUrl::ComponentFormattingOptions encoding) const-
503{-
504 if (!d)
!dDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 66 times by 1 test
Evaluated by:
  • tst_QUrlQuery
2-66
505 return QString();
executed 2 times by 1 test: return QString();
Executed by:
  • tst_QUrlQuery
2
506-
507 // unlike the component encoding, for the whole query we need to modify a little:-
508 // - the "#" character is unambiguous, so we encode it in EncodeDelimiters mode-
509 // - the query delimiter pair must always be encoded-
510-
511 // start with what's always encoded-
512 ushort tableActions[] = {-
513 encode(d->pairDelimiter.unicode()), // 0-
514 encode(d->valueDelimiter.unicode()), // 1-
515 0, // 2-
516 0-
517 };-
518 if (encoding & QUrl::EncodeDelimiters) {
encoding & QUr...codeDelimitersDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 60 times by 1 test
Evaluated by:
  • tst_QUrlQuery
6-60
519 tableActions[2] = encode('#');-
520 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
6
521-
522 QString result;-
523 Map::const_iterator it = d->itemList.constBegin();-
524 Map::const_iterator end = d->itemList.constEnd();-
525-
526 {-
527 int size = 0;-
528 for ( ; it != end; ++it)
it != endDescription
TRUEevaluated 81 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 66 times by 1 test
Evaluated by:
  • tst_QUrlQuery
66-81
529 size += it->first.length() + 1 + it->second.length() + 1;
executed 81 times by 1 test: size += it->first.length() + 1 + it->second.length() + 1;
Executed by:
  • tst_QUrlQuery
81
530 result.reserve(size + size / 4);-
531 }-
532-
533 for (it = d->itemList.constBegin(); it != end; ++it) {
it != endDescription
TRUEevaluated 81 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 66 times by 1 test
Evaluated by:
  • tst_QUrlQuery
66-81
534 if (!result.isEmpty())
!result.isEmpty()Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 66 times by 1 test
Evaluated by:
  • tst_QUrlQuery
15-66
535 result += QChar(d->pairDelimiter);
executed 15 times by 1 test: result += QChar(d->pairDelimiter);
Executed by:
  • tst_QUrlQuery
15
536 recodeAndAppend(result, it->first, encoding, tableActions);-
537 if (!it->second.isNull()) {
!it->second.isNull()Description
TRUEevaluated 74 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_QUrlQuery
7-74
538 result += QChar(d->valueDelimiter);-
539 recodeAndAppend(result, it->second, encoding, tableActions);-
540 }
executed 74 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
74
541 }
executed 81 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
81
542 return result;
executed 66 times by 1 test: return result;
Executed by:
  • tst_QUrlQuery
66
543}-
544-
545/*!-
546 Sets the characters used for delimiting between keys and values,-
547 and between key-value pairs in the URL's query string. The default-
548 value delimiter is '=' and the default pair delimiter is '&'.-
549-
550 \image qurl-querystring.png-
551-
552 \a valueDelimiter will be used for separating keys from values,-
553 and \a pairDelimiter will be used to separate key-value pairs.-
554 Any occurrences of these delimiting characters in the encoded-
555 representation of the keys and values of the query string are-
556 percent encoded when returned in query().-
557-
558 If \a valueDelimiter is set to '(' and \a pairDelimiter is ')',-
559 the above query string would instead be represented like this:-
560-
561 \snippet code/src_corelib_io_qurl.cpp 4-
562-
563 \note Non-standard delimiters should be chosen from among what RFC 3986 calls-
564 "sub-delimiters". They are:-
565-
566 \code-
567 sub-delims = "!" / "$" / "&" / "'" / "(" / ")"-
568 / "*" / "+" / "," / ";" / "="-
569 \endcode-
570-
571 Use of other characters is not supported and may result in unexpected-
572 behaviour. This method does not verify that you passed a valid delimiter.-
573-
574 \sa queryValueDelimiter(), queryPairDelimiter()-
575*/-
576void QUrlQuery::setQueryDelimiters(QChar valueDelimiter, QChar pairDelimiter)-
577{-
578 d->valueDelimiter = valueDelimiter.unicode();-
579 d->pairDelimiter = pairDelimiter.unicode();-
580}
executed 3 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
3
581-
582/*!-
583 Returns the character used to delimit between keys and values when-
584 reconstructing the query string in query() or when parsing in setQuery().-
585-
586 \sa setQueryDelimiters(), queryPairDelimiter()-
587*/-
588QChar QUrlQuery::queryValueDelimiter() const-
589{-
590 return d ? d->valueDelimiter : defaultQueryValueDelimiter();
executed 2 times by 1 test: return d ? d->valueDelimiter : defaultQueryValueDelimiter();
Executed by:
  • tst_QUrlQuery
dDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QUrlQuery
1-2
591}-
592-
593/*!-
594 Returns the character used to delimit between keys-value pairs when-
595 reconstructing the query string in query() or when parsing in setQuery().-
596-
597 \sa setQueryDelimiters(), queryValueDelimiter()-
598*/-
599QChar QUrlQuery::queryPairDelimiter() const-
600{-
601 return d ? d->pairDelimiter : defaultQueryPairDelimiter();
executed 2 times by 1 test: return d ? d->pairDelimiter : defaultQueryPairDelimiter();
Executed by:
  • tst_QUrlQuery
dDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QUrlQuery
1-2
602}-
603-
604/*!-
605 Sets the items in this QUrlQuery object to \a query. The order of the-
606 elements in \a query is preserved.-
607-
608 \note This method does not treat spaces (ASCII 0x20) and plus ("+") signs-
609 as the same, like HTML forms do. If you need spaces to be represented as-
610 plus signs, use actual plus signs.-
611-
612 \sa queryItems(), isEmpty()-
613*/-
614void QUrlQuery::setQueryItems(const QList<QPair<QString, QString> > &query)-
615{-
616 clear();-
617 if (query.isEmpty())
query.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QUrlQuery
1-9
618 return;
executed 1 time by 1 test: return;
Executed by:
  • tst_QUrlQuery
1
619-
620 QUrlQueryPrivate *dd = d;-
621 QList<QPair<QString, QString> >::const_iterator it = query.constBegin(),-
622 end = query.constEnd();-
623 for ( ; it != end; ++it)
it != endDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QUrlQuery
9-24
624 dd->addQueryItem(it->first, it->second);
executed 24 times by 1 test: dd->addQueryItem(it->first, it->second);
Executed by:
  • tst_QUrlQuery
24
625}
executed 9 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
9
626-
627/*!-
628 Returns the query string of the URL, as a map of keys and values, using the-
629 options specified in \a encoding to encode the items. The order of the-
630 elements is the same as the one found in the query string or set with-
631 setQueryItems().-
632-
633 \sa setQueryItems(), {encoding}{Encoding}-
634*/-
635QList<QPair<QString, QString> > QUrlQuery::queryItems(QUrl::ComponentFormattingOptions encoding) const-
636{-
637 if (!d)
!dDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 87 times by 1 test
Evaluated by:
  • tst_QUrlQuery
5-87
638 return QList<QPair<QString, QString> >();
executed 5 times by 1 test: return QList<QPair<QString, QString> >();
Executed by:
  • tst_QUrlQuery
5
639 if (idempotentRecodeToUser(encoding))
idempotentReco...User(encoding)Description
TRUEevaluated 76 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tst_QUrlQuery
11-76
640 return d->itemList;
executed 76 times by 1 test: return d->itemList;
Executed by:
  • tst_QUrlQuery
76
641-
642 QList<QPair<QString, QString> > result;-
643 Map::const_iterator it = d->itemList.constBegin();-
644 Map::const_iterator end = d->itemList.constEnd();-
645 result.reserve(d->itemList.count());-
646 for ( ; it != end; ++it)
it != endDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tst_QUrlQuery
11-12
647 result << qMakePair(d->recodeToUser(it->first, encoding),
executed 12 times by 1 test: result << qMakePair(d->recodeToUser(it->first, encoding), d->recodeToUser(it->second, encoding));
Executed by:
  • tst_QUrlQuery
12
648 d->recodeToUser(it->second, encoding));
executed 12 times by 1 test: result << qMakePair(d->recodeToUser(it->first, encoding), d->recodeToUser(it->second, encoding));
Executed by:
  • tst_QUrlQuery
12
649 return result;
executed 11 times by 1 test: return result;
Executed by:
  • tst_QUrlQuery
11
650}-
651-
652/*!-
653 Returns \c true if there is a query string pair whose key is equal-
654 to \a key from the URL.-
655-
656 \sa addQueryItem(), queryItemValue()-
657*/-
658bool QUrlQuery::hasQueryItem(const QString &key) const-
659{-
660 if (!d)
!dDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_QUrlQuery
4-16
661 return false;
executed 4 times by 1 test: return false;
Executed by:
  • tst_QUrlQuery
4
662 return d->findKey(key) != d->itemList.constEnd();
executed 16 times by 1 test: return d->findKey(key) != d->itemList.constEnd();
Executed by:
  • tst_QUrlQuery
16
663}-
664-
665/*!-
666 Appends the pair \a key = \a value to the end of the query string of the-
667 URL. This method does not overwrite existing items that might exist with-
668 the same key.-
669-
670 \note This method does not treat spaces (ASCII 0x20) and plus ("+") signs-
671 as the same, like HTML forms do. If you need spaces to be represented as-
672 plus signs, use actual plus signs.-
673-
674 \sa hasQueryItem(), queryItemValue()-
675*/-
676void QUrlQuery::addQueryItem(const QString &key, const QString &value)-
677{-
678 d->addQueryItem(key, value);-
679}
executed 80 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
80
680-
681/*!-
682 Returns the query value associated with key \a key from the URL, using the-
683 options specified in \a encoding to encode the return value. If the key \a-
684 key is not found, this function returns an empty string. If you need to-
685 distinguish between an empty value and a non-existent key, you should check-
686 for the key's presence first using hasQueryItem().-
687-
688 If the key \a key is multiply defined, this function will return the first-
689 one found, in the order they were present in the query string or added-
690 using addQueryItem().-
691-
692 \sa addQueryItem(), allQueryItemValues(), {encoding}{Encoding}-
693*/-
694QString QUrlQuery::queryItemValue(const QString &key, QUrl::ComponentFormattingOptions encoding) const-
695{-
696 QString result;-
697 if (d) {
dDescription
TRUEevaluated 23 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QUrlQuery
3-23
698 Map::const_iterator it = d->findKey(key);-
699 if (it != d->itemList.constEnd())
it != d->itemList.constEnd()Description
TRUEevaluated 23 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QUrlQuery
FALSEnever evaluated
0-23
700 result = d->recodeToUser(it->second, encoding);
executed 23 times by 2 tests: result = d->recodeToUser(it->second, encoding);
Executed by:
  • tst_QNetworkReply
  • tst_QUrlQuery
23
701 }
executed 23 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QUrlQuery
23
702 return result;
executed 26 times by 2 tests: return result;
Executed by:
  • tst_QNetworkReply
  • tst_QUrlQuery
26
703}-
704-
705/*!-
706 Returns the a list of query string values whose key is equal to \a key from-
707 the URL, using the options specified in \a encoding to encode the return-
708 value. If the key \a key is not found, this function returns an empty list.-
709-
710 \sa queryItemValue(), addQueryItem()-
711*/-
712QStringList QUrlQuery::allQueryItemValues(const QString &key, QUrl::ComponentFormattingOptions encoding) const-
713{-
714 QStringList result;-
715 if (d) {
dDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QUrlQuery
3-12
716 QString encodedKey = d->recodeFromUser(key);-
717 int idx = d->findRecodedKey(encodedKey);-
718 while (idx < d->itemList.size()) {
idx < d->itemList.size()Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QUrlQuery
12-19
719 result << d->recodeToUser(d->itemList.at(idx).second, encoding);-
720 idx = d->findRecodedKey(encodedKey, idx + 1);-
721 }
executed 19 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
19
722 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
12
723 return result;
executed 15 times by 1 test: return result;
Executed by:
  • tst_QUrlQuery
15
724}-
725-
726/*!-
727 Removes the query string pair whose key is equal to \a key from the URL. If-
728 there are multiple items with a key equal to \a key, it removes the first-
729 item in the order they were present in the query string or added with-
730 addQueryItem().-
731-
732 \sa removeAllQueryItems()-
733*/-
734void QUrlQuery::removeQueryItem(const QString &key)-
735{-
736 if (d) {
dDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEnever evaluated
0-6
737 Map::iterator it = d->findKey(key);-
738 if (it != d->itemList.end())
it != d->itemList.end()Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QUrlQuery
1-5
739 d->itemList.erase(it);
executed 5 times by 1 test: d->itemList.erase(it);
Executed by:
  • tst_QUrlQuery
5
740 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
6
741}
executed 6 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
6
742-
743/*!-
744 Removes all the query string pairs whose key is equal to \a key-
745 from the URL.-
746-
747 \sa removeQueryItem()-
748*/-
749void QUrlQuery::removeAllQueryItems(const QString &key)-
750{-
751 if (d.constData()) {
d.constData()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEnever evaluated
0-3
752 QString encodedKey = d->recodeFromUser(key);-
753 Map::iterator it = d->itemList.begin();-
754 while (it != d->itemList.end()) {
it != d->itemList.end()Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QUrlQuery
3-14
755 if (it->first == encodedKey)
it->first == encodedKeyDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QUrlQuery
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QUrlQuery
6-8
756 it = d->itemList.erase(it);
executed 6 times by 1 test: it = d->itemList.erase(it);
Executed by:
  • tst_QUrlQuery
6
757 else-
758 ++it;
executed 8 times by 1 test: ++it;
Executed by:
  • tst_QUrlQuery
8
759 }-
760 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
3
761}
executed 3 times by 1 test: end of block
Executed by:
  • tst_QUrlQuery
3
762-
763/*!-
764 \fn QChar QUrlQuery::defaultQueryValueDelimiter()-
765 Returns the default character for separating keys from values in the query,-
766 an equal sign ("=").-
767-
768 \sa setQueryDelimiters(), queryValueDelimiter(), defaultQueryPairDelimiter()-
769*/-
770-
771/*!-
772 \fn QChar QUrlQuery::defaultQueryPairDelimiter()-
773 Returns the default character for separating keys-value pairs from each-
774 other, an ampersand ("&").-
775-
776 \sa setQueryDelimiters(), queryPairDelimiter(), defaultQueryValueDelimiter()-
777*/-
778-
779/*!-
780 \typedef QUrlQuery::DataPtr-
781 \internal-
782*/-
783-
784/*!-
785 \fn DataPtr &QUrlQuery::data_ptr()-
786 \internal-
787*/-
788-
789/*!-
790 \fn QString QUrlQuery::toString(QUrl::ComponentFormattingOptions encoding = QUrl::PrettyDecoded) const-
791-
792 Returns this QUrlQuery as a QString. \a encoding can be used to specify the URL string encoding of the return value.-
793*/-
794-
795/*!-
796 \fn bool QUrlQuery::operator!=(const QUrlQuery &other) const-
797-
798 Returns \c true if \a other is not equal to this QUrlQuery. Otherwise, returns \c false.-
799-
800 \sa operator==()-
801*/-
802QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

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