SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
SWGInstanceChannelsResponse.cpp
Go to the documentation of this file.
1 
15 
16 #include "SWGHelpers.h"
17 
18 #include <QJsonDocument>
19 #include <QJsonArray>
20 #include <QObject>
21 #include <QDebug>
22 
23 namespace SWGSDRangel {
24 
26  init();
27  this->fromJson(*json);
28 }
29 
31  channelcount = 0;
32  m_channelcount_isSet = false;
33  channels = nullptr;
34  m_channels_isSet = false;
35 }
36 
38  this->cleanup();
39 }
40 
41 void
43  channelcount = 0;
44  m_channelcount_isSet = false;
45  channels = new QList<SWGChannelListItem*>();
46  m_channels_isSet = false;
47 }
48 
49 void
51 
52  if(channels != nullptr) {
53  auto arr = channels;
54  for(auto o: *arr) {
55  delete o;
56  }
57  delete channels;
58  }
59 }
60 
63  QByteArray array (json.toStdString().c_str());
64  QJsonDocument doc = QJsonDocument::fromJson(array);
65  QJsonObject jsonObject = doc.object();
66  this->fromJsonObject(jsonObject);
67  return this;
68 }
69 
70 void
72  ::SWGSDRangel::setValue(&channelcount, pJson["channelcount"], "qint32", "");
73 
74 
75  ::SWGSDRangel::setValue(&channels, pJson["channels"], "QList", "SWGChannelListItem");
76 }
77 
78 QString
80 {
81  QJsonObject* obj = this->asJsonObject();
82 
83  QJsonDocument doc(*obj);
84  QByteArray bytes = doc.toJson();
85  delete obj;
86  return QString(bytes);
87 }
88 
89 QJsonObject*
91  QJsonObject* obj = new QJsonObject();
93  obj->insert("channelcount", QJsonValue(channelcount));
94  }
95  if(channels->size() > 0){
96  toJsonArray((QList<void*>*)channels, obj, "channels", "SWGChannelListItem");
97  }
98 
99  return obj;
100 }
101 
102 qint32
104  return channelcount;
105 }
106 void
108  this->channelcount = channelcount;
109  this->m_channelcount_isSet = true;
110 }
111 
112 QList<SWGChannelListItem*>*
114  return channels;
115 }
116 void
118  this->channels = channels;
119  this->m_channels_isSet = true;
120 }
121 
122 
123 bool
125  bool isObjectUpdated = false;
126  do{
127  if(m_channelcount_isSet){ isObjectUpdated = true; break;}
128  if(channels->size() > 0){ isObjectUpdated = true; break;}
129  }while(false);
130  return isObjectUpdated;
131 }
132 }
133 
virtual SWGInstanceChannelsResponse * fromJson(QString &jsonString) override
void setChannels(QList< SWGChannelListItem *> *channels)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void toJsonArray(QList< void *> *value, QJsonObject *output, QString innerName, QString innerType)
Definition: SWGHelpers.cpp:445
virtual void fromJsonObject(QJsonObject &json) override