Changeset View
Changeset View
Standalone View
Standalone View
src/private/scope.cpp
Show First 20 Lines • Show All 299 Lines • ▼ Show 20 Line(s) | 299 | { | |||
---|---|---|---|---|---|
300 | if (d->gidSet.size() != 1) { | 300 | if (d->gidSet.size() != 1) { | ||
301 | // TODO: Error hanlding! | 301 | // TODO: Error hanlding! | ||
302 | Q_ASSERT(d->gidSet.size() == 1); | 302 | Q_ASSERT(d->gidSet.size() == 1); | ||
303 | return QString(); | 303 | return QString(); | ||
304 | } | 304 | } | ||
305 | return d->gidSet.at(0); | 305 | return d->gidSet.at(0); | ||
306 | } | 306 | } | ||
307 | 307 | | |||
308 | QTextStream &Akonadi::Scope::HRID::toJson(QTextStream &stream) const | ||||
309 | { | ||||
310 | stream << "{\"ID\": " << id << ", \"RemoteID\": \"" << remoteId << "\"}"; | ||||
311 | return stream; | ||||
312 | } | ||||
313 | | ||||
314 | QTextStream &Scope::toJson(QTextStream& stream) const | ||||
315 | { | ||||
316 | stream << "{"; | ||||
317 | switch (scope()) { | ||||
318 | case Scope::Uid: | ||||
319 | stream << "\"UID\": \"" << uidSet().toImapSequenceSet() << "\""; | ||||
320 | break; | ||||
321 | case Scope::Rid: | ||||
322 | stream << "\"RID\": [\"" << ridSet().join(QStringLiteral("\" , \"")) << "\"]"; | ||||
323 | break; | ||||
324 | case Scope::Gid: | ||||
325 | stream << "\"GID\": [\"" << gidSet().join(QStringLiteral("\" , \"")) << "\"]"; | ||||
326 | break; | ||||
327 | case Scope::HierarchicalRid: | ||||
328 | { | ||||
329 | const auto &chain = hridChain(); | ||||
dvratil: const auto chain = hridChain();
for (const auto &hrid : chain) {
..
}
to prevent… | |||||
my compiler is unhappy with the const auto chain = hridChain(); line in the switch: /home/neon/kdepim/src/kde/pim/akonadi/src/private/scope.cpp: In member function 'QTextStream& Akonadi::Scope::toJson(QTextStream&) const': /home/neon/kdepim/src/kde/pim/akonadi/src/private/scope.cpp:339:5: error: jump to case label [-fpermissive] /home/neon/kdepim/src/kde/pim/akonadi/src/private/scope.cpp:329:21: note: crosses initialization of 'const QVector<Akonadi::Scope::HRID>& chain' /home/neon/kdepim/src/kde/pim/akonadi/src/private/scope.cpp:317:12: warning: enumeration value 'Invalid' not handled in switch [-Wswitch] knauss: my compiler is unhappy with the `const auto chain = hridChain();` line in the switch:
```… | |||||
That's normal, you should use curly braces around a case when you want to declare a variable inside case x : { int a = 5; } break; anthonyfieroni: That's normal, you should use curly braces around a case when you want to declare a variable… | |||||
330 | stream << "\"HRID\": ["; | ||||
331 | for (const auto &hrid : chain) { | ||||
332 | hrid.toJson(stream); | ||||
dvratil: Use the `chain` variable from above comment here | |||||
333 | stream << ","; | ||||
334 | } | ||||
335 | if (!chain.isEmpty()) { | ||||
336 | stream.seek(-1); | ||||
337 | } | ||||
338 | stream << "]"; | ||||
339 | } | ||||
340 | break; | ||||
341 | default: | ||||
342 | stream << "None"; | ||||
343 | } | ||||
344 | stream << "}"; | ||||
345 | return stream; | ||||
346 | } | ||||
347 | | ||||
308 | Protocol::DataStream &operator<<(Protocol::DataStream &stream, const Akonadi::Scope &scope) | 348 | Protocol::DataStream &operator<<(Protocol::DataStream &stream, const Akonadi::Scope &scope) | ||
309 | { | 349 | { | ||
310 | stream << (quint8) scope.d->scope; | 350 | stream << (quint8) scope.d->scope; | ||
311 | switch (scope.d->scope) { | 351 | switch (scope.d->scope) { | ||
312 | case Scope::Invalid: | 352 | case Scope::Invalid: | ||
313 | return stream; | 353 | return stream; | ||
314 | case Scope::Uid: | 354 | case Scope::Uid: | ||
315 | stream << scope.d->uidSet; | 355 | stream << scope.d->uidSet; | ||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |
to prevent detaching the returned container.