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