D12736: Add toJson method for the protocol.

Anthony Fieroni noreply at phabricator.kde.org
Mon May 21 12:32:58 BST 2018


anthonyfieroni added inline comments.

INLINE COMMENTS

> protocol.cpp:203-205
> +         case Command::Invalid:
> +             stream << "Invalid";
> +             break;

You can make a helper macro like this

  #define case_label(x)    case Command::x: stream << #x; break
  
  swtich (mType)
  {
      case_label(Invalid);
      case_label(Hello);
      ...
  }
  
  #undef case_label

> knauss wrote in scope.cpp:329
> 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]

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;

REPOSITORY
  R165 Akonadi

REVISION DETAIL
  https://phabricator.kde.org/D12736

To: knauss, dvratil
Cc: anthonyfieroni, #kde_pim, dvasin, rodsevich, winterz, vkrause, mlaurent, knauss, dvratil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20180521/884f2d7a/attachment.html>


More information about the kde-pim mailing list