Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qurlquery.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | typedef QList<QPair<QString, QString> > Map; | - | ||||||||||||
5 | - | |||||||||||||
6 | class QUrlQueryPrivate : public QSharedData | - | ||||||||||||
7 | { | - | ||||||||||||
8 | public: | - | ||||||||||||
9 | QUrlQueryPrivate(const QString &query = QString()) | - | ||||||||||||
10 | : valueDelimiter(QUrlQuery::defaultQueryValueDelimiter()), | - | ||||||||||||
11 | pairDelimiter(QUrlQuery::defaultQueryPairDelimiter()) | - | ||||||||||||
12 | { if (!query.isEmpty()
executed 53 times by 2 tests: }setQuery(query); Executed by:
executed 108 times by 2 tests: end of block Executed by:
| 53-108 | ||||||||||||
13 | - | |||||||||||||
14 | QString recodeFromUser(const QString &input) const; | - | ||||||||||||
15 | QString recodeToUser(const QString &input, QUrl::ComponentFormattingOptions encoding) const; | - | ||||||||||||
16 | - | |||||||||||||
17 | void setQuery(const QString &query); | - | ||||||||||||
18 | - | |||||||||||||
19 | void addQueryItem(const QString &key, const QString &value) | - | ||||||||||||
20 | { itemList.append(qMakePair(recodeFromUser(key), recodeFromUser(value))); } executed 104 times by 1 test: end of block Executed by:
| 104 | ||||||||||||
21 | int findRecodedKey(const QString &key, int from = 0) const | - | ||||||||||||
22 | { | - | ||||||||||||
23 | for (int i = from; i < itemList.size()
| 17-103 | ||||||||||||
24 | if (itemList.at(i).first == key
| 44-59 | ||||||||||||
25 | return executed 59 times by 2 tests: i;return i; Executed by:
executed 59 times by 2 tests: return i; Executed by:
| 59 | ||||||||||||
26 | return executed 17 times by 1 test: itemList.size();return itemList.size(); Executed by:
executed 17 times by 1 test: return itemList.size(); Executed by:
| 17 | ||||||||||||
27 | } | - | ||||||||||||
28 | Map::const_iterator findKey(const QString &key) const | - | ||||||||||||
29 | { return executed 39 times by 2 tests: itemList.constBegin() + findRecodedKey(recodeFromUser(key));return itemList.constBegin() + findRecodedKey(recodeFromUser(key)); Executed by:
executed 39 times by 2 tests: }return itemList.constBegin() + findRecodedKey(recodeFromUser(key)); Executed by:
| 39 | ||||||||||||
30 | Map::iterator findKey(const QString &key) | - | ||||||||||||
31 | { return executed 6 times by 1 test: itemList.begin() + findRecodedKey(recodeFromUser(key));return itemList.begin() + findRecodedKey(recodeFromUser(key)); Executed by:
executed 6 times by 1 test: }return itemList.begin() + findRecodedKey(recodeFromUser(key)); Executed by:
| 6 | ||||||||||||
32 | - | |||||||||||||
33 | - | |||||||||||||
34 | Map itemList; | - | ||||||||||||
35 | QChar valueDelimiter; | - | ||||||||||||
36 | QChar pairDelimiter; | - | ||||||||||||
37 | }; | - | ||||||||||||
38 | - | |||||||||||||
39 | template<> void QSharedDataPointer<QUrlQueryPrivate>::detach() | - | ||||||||||||
40 | { | - | ||||||||||||
41 | if (d
| 4-111 | ||||||||||||
42 | return; executed 107 times by 1 test: return; Executed by:
| 107 | ||||||||||||
43 | QUrlQueryPrivate *x = (d
| 4-55 | ||||||||||||
44 | : new QUrlQueryPrivate); | - | ||||||||||||
45 | x->ref.ref(); | - | ||||||||||||
46 | if (d
| 0-55 | ||||||||||||
47 | delete d; never executed: delete d; | 0 | ||||||||||||
48 | d = x; | - | ||||||||||||
49 | } executed 59 times by 1 test: end of block Executed by:
| 59 | ||||||||||||
50 | inline QString QUrlQueryPrivate::recodeFromUser(const QString &input) const | - | ||||||||||||
51 | { | - | ||||||||||||
52 | - | |||||||||||||
53 | QString output; | - | ||||||||||||
54 | ushort prettyDecodedActions[] = { | - | ||||||||||||
55 | ushort(pairDelimiter.unicode()), | - | ||||||||||||
56 | ushort(valueDelimiter.unicode()), | - | ||||||||||||
57 | ushort('#'), | - | ||||||||||||
58 | 0 | - | ||||||||||||
59 | }; | - | ||||||||||||
60 | if (qt_urlRecode(output, input.constData(), input.constData() + input.length(),
| 26-242 | ||||||||||||
61 | QUrl::DecodeReserved,
| 26-242 | ||||||||||||
62 | prettyDecodedActions)
| 26-242 | ||||||||||||
63 | return executed 26 times by 1 test: output;return output; Executed by:
executed 26 times by 1 test: return output; Executed by:
| 26 | ||||||||||||
64 | return executed 242 times by 2 tests: input;return input; Executed by:
executed 242 times by 2 tests: return input; Executed by:
| 242 | ||||||||||||
65 | } | - | ||||||||||||
66 | - | |||||||||||||
67 | inline bool idempotentRecodeToUser(QUrl::ComponentFormattingOptions encoding) | - | ||||||||||||
68 | { | - | ||||||||||||
69 | return executed 153 times by 2 tests: encoding == QUrl::PrettyDecoded;return encoding == QUrl::PrettyDecoded; Executed by:
executed 153 times by 2 tests: return encoding == QUrl::PrettyDecoded; Executed by:
| 153 | ||||||||||||
70 | } | - | ||||||||||||
71 | - | |||||||||||||
72 | inline QString QUrlQueryPrivate::recodeToUser(const QString &input, QUrl::ComponentFormattingOptions encoding) const | - | ||||||||||||
73 | { | - | ||||||||||||
74 | - | |||||||||||||
75 | - | |||||||||||||
76 | if (idempotentRecodeToUser(encoding)
| 24-42 | ||||||||||||
77 | return executed 42 times by 2 tests: input;return input; Executed by:
executed 42 times by 2 tests: return input; Executed by:
| 42 | ||||||||||||
78 | - | |||||||||||||
79 | if (!(encoding & QUrl::EncodeDelimiters)
| 8-16 | ||||||||||||
80 | QString output; | - | ||||||||||||
81 | if (qt_urlRecode(output, input.constData(), input.constData() + input.length(),
| 4 | ||||||||||||
82 | encoding, 0)
| 4 | ||||||||||||
83 | return executed 4 times by 1 test: output;return output; Executed by:
executed 4 times by 1 test: return output; Executed by:
| 4 | ||||||||||||
84 | return executed 4 times by 1 test: input;return input; Executed by:
executed 4 times by 1 test: return input; Executed by:
| 4 | ||||||||||||
85 | } | - | ||||||||||||
86 | - | |||||||||||||
87 | - | |||||||||||||
88 | ushort actions[] = { ushort(0x200 | (pairDelimiter.unicode())), ushort(0x200 | (valueDelimiter.unicode())), | - | ||||||||||||
89 | ushort(0x200 | ('#')), 0 }; | - | ||||||||||||
90 | QString output; | - | ||||||||||||
91 | if (qt_urlRecode(output, input.constData(), input.constData() + input.length(), encoding, actions)
| 6-10 | ||||||||||||
92 | return executed 6 times by 1 test: output;return output; Executed by:
executed 6 times by 1 test: return output; Executed by:
| 6 | ||||||||||||
93 | return executed 10 times by 1 test: input;return input; Executed by:
executed 10 times by 1 test: return input; Executed by:
| 10 | ||||||||||||
94 | } | - | ||||||||||||
95 | - | |||||||||||||
96 | void QUrlQueryPrivate::setQuery(const QString &query) | - | ||||||||||||
97 | { | - | ||||||||||||
98 | ushort prettyDecodedActions[] = { | - | ||||||||||||
99 | ushort(pairDelimiter.unicode()), | - | ||||||||||||
100 | ushort(valueDelimiter.unicode()), | - | ||||||||||||
101 | ushort('#'), | - | ||||||||||||
102 | 0 | - | ||||||||||||
103 | }; | - | ||||||||||||
104 | - | |||||||||||||
105 | itemList.clear(); | - | ||||||||||||
106 | const QChar *pos = query.constData(); | - | ||||||||||||
107 | const QChar *const end = pos + query.size(); | - | ||||||||||||
108 | while (pos != end
| 56-79 | ||||||||||||
109 | const QChar *begin = pos; | - | ||||||||||||
110 | const QChar *delimiter = 0; | - | ||||||||||||
111 | while (pos != end
| 55-572 | ||||||||||||
112 | - | |||||||||||||
113 | if (!delimiter
| 69-344 | ||||||||||||
114 | delimiter = pos; executed 69 times by 2 tests: delimiter = pos; Executed by:
| 69 | ||||||||||||
115 | if (pos->unicode() == pairDelimiter
| 24-548 | ||||||||||||
116 | break; executed 24 times by 1 test: break; Executed by:
| 24 | ||||||||||||
117 | ++pos; | - | ||||||||||||
118 | } executed 548 times by 2 tests: end of block Executed by:
| 548 | ||||||||||||
119 | if (!delimiter
| 10-69 | ||||||||||||
120 | delimiter = pos; executed 10 times by 1 test: delimiter = pos; Executed by:
| 10 | ||||||||||||
121 | - | |||||||||||||
122 | - | |||||||||||||
123 | - | |||||||||||||
124 | - | |||||||||||||
125 | QString key; | - | ||||||||||||
126 | if (!qt_urlRecode(key, begin, delimiter,
| 12-67 | ||||||||||||
127 | QUrl::DecodeReserved,
| 12-67 | ||||||||||||
128 | prettyDecodedActions)
| 12-67 | ||||||||||||
129 | key = QString(begin, delimiter - begin); executed 67 times by 2 tests: key = QString(begin, delimiter - begin); Executed by:
| 67 | ||||||||||||
130 | - | |||||||||||||
131 | if (delimiter == pos
| 10-69 | ||||||||||||
132 | - | |||||||||||||
133 | itemList.append(qMakePair(key, QString())); | - | ||||||||||||
134 | } executed 10 times by 1 test: else if (delimiter + 1 == posend of block Executed by:
| 5-64 | ||||||||||||
135 | - | |||||||||||||
136 | itemList.append(qMakePair(key, QString(0, Qt::Uninitialized))); | - | ||||||||||||
137 | } executed 5 times by 1 test: else {end of block Executed by:
| 5 | ||||||||||||
138 | QString value; | - | ||||||||||||
139 | if (!qt_urlRecode(value, delimiter + 1, pos,
| 12-52 | ||||||||||||
140 | QUrl::DecodeReserved,
| 12-52 | ||||||||||||
141 | prettyDecodedActions)
| 12-52 | ||||||||||||
142 | value = QString(delimiter + 1, pos - delimiter - 1); executed 52 times by 2 tests: value = QString(delimiter + 1, pos - delimiter - 1); Executed by:
| 52 | ||||||||||||
143 | itemList.append(qMakePair(key, value)); | - | ||||||||||||
144 | } executed 64 times by 2 tests: end of block Executed by:
| 64 | ||||||||||||
145 | - | |||||||||||||
146 | if (pos != end
| 24-55 | ||||||||||||
147 | ++ executed 24 times by 1 test: pos;++pos; Executed by:
executed 24 times by 1 test: ++pos; Executed by:
| 24 | ||||||||||||
148 | } executed 79 times by 2 tests: end of block Executed by:
| 79 | ||||||||||||
149 | } executed 56 times by 2 tests: end of block Executed by:
| 56 | ||||||||||||
150 | - | |||||||||||||
151 | - | |||||||||||||
152 | template <> inline QUrlQueryPrivate * | - | ||||||||||||
153 | QSharedDataPointer<QUrlQueryPrivate>::clone() | - | ||||||||||||
154 | { | - | ||||||||||||
155 | return never executed: dreturn d ? new QUrlQueryPrivate(*d) : new QUrlQueryPrivate;
never executed: return d ? new QUrlQueryPrivate(*d) : new QUrlQueryPrivate; | 0 | ||||||||||||
156 | } | - | ||||||||||||
157 | - | |||||||||||||
158 | - | |||||||||||||
159 | - | |||||||||||||
160 | - | |||||||||||||
161 | - | |||||||||||||
162 | - | |||||||||||||
163 | - | |||||||||||||
164 | QUrlQuery::QUrlQuery() | - | ||||||||||||
165 | : d(0) | - | ||||||||||||
166 | { | - | ||||||||||||
167 | } executed 60 times by 1 test: end of block Executed by:
| 60 | ||||||||||||
168 | - | |||||||||||||
169 | - | |||||||||||||
170 | - | |||||||||||||
171 | - | |||||||||||||
172 | - | |||||||||||||
173 | - | |||||||||||||
174 | - | |||||||||||||
175 | QUrlQuery::QUrlQuery(const QString &queryString) | - | ||||||||||||
176 | : d(queryString.isEmpty() ? 0 : new QUrlQueryPrivate(queryString)) | - | ||||||||||||
177 | { | - | ||||||||||||
178 | } executed 49 times by 1 test: end of block Executed by:
| 49 | ||||||||||||
179 | QUrlQuery::QUrlQuery(const QUrl &url) | - | ||||||||||||
180 | : d(0) | - | ||||||||||||
181 | { | - | ||||||||||||
182 | - | |||||||||||||
183 | - | |||||||||||||
184 | if (url.hasQuery()
| 0-7 | ||||||||||||
185 | d = new QUrlQueryPrivate(url.query()); executed 7 times by 1 test: d = new QUrlQueryPrivate(url.query()); Executed by:
| 7 | ||||||||||||
186 | } executed 7 times by 1 test: end of block Executed by:
| 7 | ||||||||||||
187 | - | |||||||||||||
188 | - | |||||||||||||
189 | - | |||||||||||||
190 | - | |||||||||||||
191 | - | |||||||||||||
192 | QUrlQuery::QUrlQuery(const QUrlQuery &other) | - | ||||||||||||
193 | : d(other.d) | - | ||||||||||||
194 | { | - | ||||||||||||
195 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||
196 | - | |||||||||||||
197 | - | |||||||||||||
198 | - | |||||||||||||
199 | - | |||||||||||||
200 | - | |||||||||||||
201 | QUrlQuery &QUrlQuery::operator =(const QUrlQuery &other) | - | ||||||||||||
202 | { | - | ||||||||||||
203 | d = other.d; | - | ||||||||||||
204 | return executed 2 times by 1 test: *this;return *this; Executed by:
executed 2 times by 1 test: return *this; Executed by:
| 2 | ||||||||||||
205 | } | - | ||||||||||||
206 | QUrlQuery::~QUrlQuery() | - | ||||||||||||
207 | { | - | ||||||||||||
208 | - | |||||||||||||
209 | } | - | ||||||||||||
210 | - | |||||||||||||
211 | - | |||||||||||||
212 | - | |||||||||||||
213 | - | |||||||||||||
214 | - | |||||||||||||
215 | bool QUrlQuery::operator ==(const QUrlQuery &other) const | - | ||||||||||||
216 | { | - | ||||||||||||
217 | if (d == other.d
| 7-10 | ||||||||||||
218 | return executed 7 times by 1 test: true;return true; Executed by:
executed 7 times by 1 test: return true; Executed by:
| 7 | ||||||||||||
219 | if (d && other.d) | - | ||||||||||||
220 | - | |||||||||||||
221 | return executed 8 times by 1 test: d->valueDelimiter == other.d->valueDelimiterreturn d->valueDelimiter == other.d->valueDelimiter && d->pairDelimiter == other.d->pairDelimiter && d->itemList == other.d->itemList; Executed by:
executed 8 times by 1 test: return d->valueDelimiter == other.d->valueDelimiter && d->pairDelimiter == other.d->pairDelimiter && d->itemList == other.d->itemList; Executed by:
| 0-8 | ||||||||||||
222 | 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:
| 0-8 | ||||||||||||
223 | 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:
| 3-8 | ||||||||||||
224 | return executed 2 times by 1 test: false;return false; Executed by:
executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||
225 | } | - | ||||||||||||
226 | uint qHash(const QUrlQuery &key, uint seed) noexcept | - | ||||||||||||
227 | { | - | ||||||||||||
228 | if (const
| 2-4 | ||||||||||||
229 | QtPrivate::QHashCombine hash; | - | ||||||||||||
230 | - | |||||||||||||
231 | seed = hash(seed, d->valueDelimiter); | - | ||||||||||||
232 | seed = hash(seed, d->pairDelimiter); | - | ||||||||||||
233 | seed = hash(seed, d->itemList); | - | ||||||||||||
234 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
235 | return executed 6 times by 1 test: seed;return seed; Executed by:
executed 6 times by 1 test: return seed; Executed by:
| 6 | ||||||||||||
236 | } | - | ||||||||||||
237 | - | |||||||||||||
238 | - | |||||||||||||
239 | - | |||||||||||||
240 | - | |||||||||||||
241 | - | |||||||||||||
242 | - | |||||||||||||
243 | - | |||||||||||||
244 | bool QUrlQuery::isEmpty() const | - | ||||||||||||
245 | { | - | ||||||||||||
246 | return executed 37 times by 1 test: dreturn d ? d->itemList.isEmpty() : true; Executed by:
executed 37 times by 1 test: return d ? d->itemList.isEmpty() : true; Executed by:
| 6-37 | ||||||||||||
247 | } | - | ||||||||||||
248 | - | |||||||||||||
249 | - | |||||||||||||
250 | - | |||||||||||||
251 | - | |||||||||||||
252 | bool QUrlQuery::isDetached() const | - | ||||||||||||
253 | { | - | ||||||||||||
254 | return executed 4 times by 1 test: d && d->ref.load() == 1return d && d->ref.load() == 1; Executed by:
executed 4 times by 1 test: return d && d->ref.load() == 1; Executed by:
| 0-4 | ||||||||||||
255 | } | - | ||||||||||||
256 | void QUrlQuery::clear() | - | ||||||||||||
257 | { | - | ||||||||||||
258 | if (d.constData()
| 5-16 | ||||||||||||
259 | d->itemList.clear(); executed 16 times by 1 test: d->itemList.clear(); Executed by:
| 16 | ||||||||||||
260 | } executed 21 times by 1 test: end of block Executed by:
| 21 | ||||||||||||
261 | - | |||||||||||||
262 | - | |||||||||||||
263 | - | |||||||||||||
264 | - | |||||||||||||
265 | - | |||||||||||||
266 | - | |||||||||||||
267 | - | |||||||||||||
268 | void QUrlQuery::setQuery(const QString &queryString) | - | ||||||||||||
269 | { | - | ||||||||||||
270 | d->setQuery(queryString); | - | ||||||||||||
271 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||
272 | - | |||||||||||||
273 | static void recodeAndAppend(QString &to, const QString &input, | - | ||||||||||||
274 | QUrl::ComponentFormattingOptions encoding, const ushort *tableModifications) | - | ||||||||||||
275 | { | - | ||||||||||||
276 | if (!qt_urlRecode(to, input.constData(), input.constData() + input.length(), encoding, tableModifications)
| 32-123 | ||||||||||||
277 | to += input; executed 123 times by 1 test: to += input; Executed by:
| 123 | ||||||||||||
278 | } executed 155 times by 1 test: end of block Executed by:
| 155 | ||||||||||||
279 | QString QUrlQuery::query(QUrl::ComponentFormattingOptions encoding) const | - | ||||||||||||
280 | { | - | ||||||||||||
281 | if (!d
| 2-66 | ||||||||||||
282 | return executed 2 times by 1 test: QString();return QString(); Executed by:
executed 2 times by 1 test: return QString(); Executed by:
| 2 | ||||||||||||
283 | - | |||||||||||||
284 | - | |||||||||||||
285 | - | |||||||||||||
286 | - | |||||||||||||
287 | - | |||||||||||||
288 | - | |||||||||||||
289 | ushort tableActions[] = { | - | ||||||||||||
290 | ushort(0x200 | (d->pairDelimiter.unicode())), | - | ||||||||||||
291 | ushort(0x200 | (d->valueDelimiter.unicode())), | - | ||||||||||||
292 | 0, | - | ||||||||||||
293 | 0 | - | ||||||||||||
294 | }; | - | ||||||||||||
295 | if (encoding & QUrl::EncodeDelimiters
| 6-60 | ||||||||||||
296 | tableActions[2] = ushort(0x200 | ('#')); | - | ||||||||||||
297 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||
298 | - | |||||||||||||
299 | QString result; | - | ||||||||||||
300 | Map::const_iterator it = d->itemList.constBegin(); | - | ||||||||||||
301 | Map::const_iterator end = d->itemList.constEnd(); | - | ||||||||||||
302 | - | |||||||||||||
303 | { | - | ||||||||||||
304 | int size = 0; | - | ||||||||||||
305 | for ( ; it != end
| 66-81 | ||||||||||||
306 | 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:
| 81 | ||||||||||||
307 | result.reserve(size + size / 4); | - | ||||||||||||
308 | } | - | ||||||||||||
309 | - | |||||||||||||
310 | for (it = d->itemList.constBegin(); it != end
| 66-81 | ||||||||||||
311 | if (!result.isEmpty()
| 15-66 | ||||||||||||
312 | result += QChar(d->pairDelimiter); executed 15 times by 1 test: result += QChar(d->pairDelimiter); Executed by:
| 15 | ||||||||||||
313 | recodeAndAppend(result, it->first, encoding, tableActions); | - | ||||||||||||
314 | if (!it->second.isNull()
| 7-74 | ||||||||||||
315 | result += QChar(d->valueDelimiter); | - | ||||||||||||
316 | recodeAndAppend(result, it->second, encoding, tableActions); | - | ||||||||||||
317 | } executed 74 times by 1 test: end of block Executed by:
| 74 | ||||||||||||
318 | } executed 81 times by 1 test: end of block Executed by:
| 81 | ||||||||||||
319 | return executed 66 times by 1 test: result;return result; Executed by:
executed 66 times by 1 test: return result; Executed by:
| 66 | ||||||||||||
320 | } | - | ||||||||||||
321 | void QUrlQuery::setQueryDelimiters(QChar valueDelimiter, QChar pairDelimiter) | - | ||||||||||||
322 | { | - | ||||||||||||
323 | d->valueDelimiter = valueDelimiter.unicode(); | - | ||||||||||||
324 | d->pairDelimiter = pairDelimiter.unicode(); | - | ||||||||||||
325 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||
326 | - | |||||||||||||
327 | - | |||||||||||||
328 | - | |||||||||||||
329 | - | |||||||||||||
330 | - | |||||||||||||
331 | - | |||||||||||||
332 | - | |||||||||||||
333 | QChar QUrlQuery::queryValueDelimiter() const | - | ||||||||||||
334 | { | - | ||||||||||||
335 | return executed 2 times by 1 test: dreturn d ? d->valueDelimiter : defaultQueryValueDelimiter(); Executed by:
executed 2 times by 1 test: return d ? d->valueDelimiter : defaultQueryValueDelimiter(); Executed by:
| 1-2 | ||||||||||||
336 | } | - | ||||||||||||
337 | - | |||||||||||||
338 | - | |||||||||||||
339 | - | |||||||||||||
340 | - | |||||||||||||
341 | - | |||||||||||||
342 | - | |||||||||||||
343 | - | |||||||||||||
344 | QChar QUrlQuery::queryPairDelimiter() const | - | ||||||||||||
345 | { | - | ||||||||||||
346 | return executed 2 times by 1 test: dreturn d ? d->pairDelimiter : defaultQueryPairDelimiter(); Executed by:
executed 2 times by 1 test: return d ? d->pairDelimiter : defaultQueryPairDelimiter(); Executed by:
| 1-2 | ||||||||||||
347 | } | - | ||||||||||||
348 | void QUrlQuery::setQueryItems(const QList<QPair<QString, QString> > &query) | - | ||||||||||||
349 | { | - | ||||||||||||
350 | clear(); | - | ||||||||||||
351 | if (query.isEmpty()
| 1-9 | ||||||||||||
352 | return; executed 1 time by 1 test: return; Executed by:
| 1 | ||||||||||||
353 | - | |||||||||||||
354 | QUrlQueryPrivate *dd = d; | - | ||||||||||||
355 | QList<QPair<QString, QString> >::const_iterator it = query.constBegin(), | - | ||||||||||||
356 | end = query.constEnd(); | - | ||||||||||||
357 | for ( ; it != end
| 9-24 | ||||||||||||
358 | dd->addQueryItem(it->first, it->second); executed 24 times by 1 test: dd->addQueryItem(it->first, it->second); Executed by:
| 24 | ||||||||||||
359 | } executed 9 times by 1 test: end of block Executed by:
| 9 | ||||||||||||
360 | QList<QPair<QString, QString> > QUrlQuery::queryItems(QUrl::ComponentFormattingOptions encoding) const | - | ||||||||||||
361 | { | - | ||||||||||||
362 | if (!d
| 5-87 | ||||||||||||
363 | return executed 5 times by 1 test: QList<QPair<QString, QString> >();return QList<QPair<QString, QString> >(); Executed by:
executed 5 times by 1 test: return QList<QPair<QString, QString> >(); Executed by:
| 5 | ||||||||||||
364 | if (idempotentRecodeToUser(encoding)
| 11-76 | ||||||||||||
365 | return executed 76 times by 1 test: d->itemList;return d->itemList; Executed by:
executed 76 times by 1 test: return d->itemList; Executed by:
| 76 | ||||||||||||
366 | - | |||||||||||||
367 | QList<QPair<QString, QString> > result; | - | ||||||||||||
368 | Map::const_iterator it = d->itemList.constBegin(); | - | ||||||||||||
369 | Map::const_iterator end = d->itemList.constEnd(); | - | ||||||||||||
370 | result.reserve(d->itemList.count()); | - | ||||||||||||
371 | for ( ; it != end
| 11-12 | ||||||||||||
372 | 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:
| 12 | ||||||||||||
373 | 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:
| 12 | ||||||||||||
374 | return executed 11 times by 1 test: result;return result; Executed by:
executed 11 times by 1 test: return result; Executed by:
| 11 | ||||||||||||
375 | } | - | ||||||||||||
376 | - | |||||||||||||
377 | - | |||||||||||||
378 | - | |||||||||||||
379 | - | |||||||||||||
380 | - | |||||||||||||
381 | - | |||||||||||||
382 | - | |||||||||||||
383 | bool QUrlQuery::hasQueryItem(const QString &key) const | - | ||||||||||||
384 | { | - | ||||||||||||
385 | if (!d
| 4-16 | ||||||||||||
386 | return executed 4 times by 1 test: false;return false; Executed by:
executed 4 times by 1 test: return false; Executed by:
| 4 | ||||||||||||
387 | return executed 16 times by 1 test: d->findKey(key) != d->itemList.constEnd();return d->findKey(key) != d->itemList.constEnd(); Executed by:
executed 16 times by 1 test: return d->findKey(key) != d->itemList.constEnd(); Executed by:
| 16 | ||||||||||||
388 | } | - | ||||||||||||
389 | void QUrlQuery::addQueryItem(const QString &key, const QString &value) | - | ||||||||||||
390 | { | - | ||||||||||||
391 | d->addQueryItem(key, value); | - | ||||||||||||
392 | } executed 80 times by 1 test: end of block Executed by:
| 80 | ||||||||||||
393 | QString QUrlQuery::queryItemValue(const QString &key, QUrl::ComponentFormattingOptions encoding) const | - | ||||||||||||
394 | { | - | ||||||||||||
395 | QString result; | - | ||||||||||||
396 | if (d
| 3-23 | ||||||||||||
397 | Map::const_iterator it = d->findKey(key); | - | ||||||||||||
398 | if (it != d->itemList.constEnd()
| 0-23 | ||||||||||||
399 | result = d->recodeToUser(it->second, encoding); executed 23 times by 2 tests: result = d->recodeToUser(it->second, encoding); Executed by:
| 23 | ||||||||||||
400 | } executed 23 times by 2 tests: end of block Executed by:
| 23 | ||||||||||||
401 | return executed 26 times by 2 tests: result;return result; Executed by:
executed 26 times by 2 tests: return result; Executed by:
| 26 | ||||||||||||
402 | } | - | ||||||||||||
403 | QStringList QUrlQuery::allQueryItemValues(const QString &key, QUrl::ComponentFormattingOptions encoding) const | - | ||||||||||||
404 | { | - | ||||||||||||
405 | QStringList result; | - | ||||||||||||
406 | if (d
| 3-12 | ||||||||||||
407 | QString encodedKey = d->recodeFromUser(key); | - | ||||||||||||
408 | int idx = d->findRecodedKey(encodedKey); | - | ||||||||||||
409 | while (idx < d->itemList.size()
| 12-19 | ||||||||||||
410 | result << d->recodeToUser(d->itemList.at(idx).second, encoding); | - | ||||||||||||
411 | idx = d->findRecodedKey(encodedKey, idx + 1); | - | ||||||||||||
412 | } executed 19 times by 1 test: end of block Executed by:
| 19 | ||||||||||||
413 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||
414 | return executed 15 times by 1 test: result;return result; Executed by:
executed 15 times by 1 test: return result; Executed by:
| 15 | ||||||||||||
415 | } | - | ||||||||||||
416 | void QUrlQuery::removeQueryItem(const QString &key) | - | ||||||||||||
417 | { | - | ||||||||||||
418 | if (d
| 0-6 | ||||||||||||
419 | Map::iterator it = d->findKey(key); | - | ||||||||||||
420 | if (it != d->itemList.end()
| 1-5 | ||||||||||||
421 | d->itemList.erase(it); executed 5 times by 1 test: d->itemList.erase(it); Executed by:
| 5 | ||||||||||||
422 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||
423 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||
424 | - | |||||||||||||
425 | - | |||||||||||||
426 | - | |||||||||||||
427 | - | |||||||||||||
428 | - | |||||||||||||
429 | - | |||||||||||||
430 | - | |||||||||||||
431 | void QUrlQuery::removeAllQueryItems(const QString &key) | - | ||||||||||||
432 | { | - | ||||||||||||
433 | if (d.constData()
| 0-3 | ||||||||||||
434 | QString encodedKey = d->recodeFromUser(key); | - | ||||||||||||
435 | Map::iterator it = d->itemList.begin(); | - | ||||||||||||
436 | while (it != d->itemList.end()
| 3-14 | ||||||||||||
437 | if (it->first == encodedKey
| 6-8 | ||||||||||||
438 | it = d->itemList.erase(it); executed 6 times by 1 test: it = d->itemList.erase(it); Executed by:
| 6 | ||||||||||||
439 | else | - | ||||||||||||
440 | ++ executed 8 times by 1 test: it;++it; Executed by:
executed 8 times by 1 test: ++it; Executed by:
| 8 | ||||||||||||
441 | } | - | ||||||||||||
442 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||
443 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||
444 | - | |||||||||||||
Switch to Source code | Preprocessed file |