Chatterino
SeventvEventAPIMessage.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include <boost/optional.hpp>
6 #include <magic_enum.hpp>
7 
8 #include <QJsonDocument>
9 #include <QJsonObject>
10 #include <QString>
11 
12 namespace chatterino {
13 
15  QJsonObject data;
16 
18 
19  SeventvEventAPIMessage(QJsonObject _json);
20 
21  template <class InnerClass>
22  boost::optional<InnerClass> toInner();
23 };
24 
25 template <class InnerClass>
26 boost::optional<InnerClass> SeventvEventAPIMessage::toInner()
27 {
28  return InnerClass{this->data};
29 }
30 
31 static boost::optional<SeventvEventAPIMessage> parseSeventvEventAPIBaseMessage(
32  const QString &blob)
33 {
34  QJsonDocument jsonDoc(QJsonDocument::fromJson(blob.toUtf8()));
35 
36  if (jsonDoc.isNull())
37  {
38  return boost::none;
39  }
40 
41  return SeventvEventAPIMessage(jsonDoc.object());
42 }
43 
44 } // namespace chatterino
SeventvEventAPIOpcode op
Definition: SeventvEventAPIMessage.hpp:17
QJsonObject data
Definition: SeventvEventAPIMessage.hpp:15
Definition: SeventvEventAPIMessage.hpp:14
Definition: Application.cpp:48
SeventvEventAPIMessage(QJsonObject _json)
Definition: SeventvEventAPIMessage.cpp:5
SeventvEventAPIOpcode
Definition: SeventvEventAPISubscription.hpp:20
boost::optional< InnerClass > toInner()
Definition: SeventvEventAPIMessage.hpp:26