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.
SWGChannelListItem.cpp
Go to the documentation of this file.
1 
14 #include "SWGChannelListItem.h"
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  name = nullptr;
32  m_name_isSet = false;
33  id_uri = nullptr;
34  m_id_uri_isSet = false;
35  id = nullptr;
36  m_id_isSet = false;
37  direction = 0;
38  m_direction_isSet = false;
39  version = nullptr;
40  m_version_isSet = false;
41  index = 0;
42  m_index_isSet = false;
43 }
44 
46  this->cleanup();
47 }
48 
49 void
51  name = new QString("");
52  m_name_isSet = false;
53  id_uri = new QString("");
54  m_id_uri_isSet = false;
55  id = new QString("");
56  m_id_isSet = false;
57  direction = 0;
58  m_direction_isSet = false;
59  version = new QString("");
60  m_version_isSet = false;
61  index = 0;
62  m_index_isSet = false;
63 }
64 
65 void
67  if(name != nullptr) {
68  delete name;
69  }
70  if(id_uri != nullptr) {
71  delete id_uri;
72  }
73  if(id != nullptr) {
74  delete id;
75  }
76 
77  if(version != nullptr) {
78  delete version;
79  }
80 
81 }
82 
85  QByteArray array (json.toStdString().c_str());
86  QJsonDocument doc = QJsonDocument::fromJson(array);
87  QJsonObject jsonObject = doc.object();
88  this->fromJsonObject(jsonObject);
89  return this;
90 }
91 
92 void
94  ::SWGSDRangel::setValue(&name, pJson["name"], "QString", "QString");
95 
96  ::SWGSDRangel::setValue(&id_uri, pJson["idURI"], "QString", "QString");
97 
98  ::SWGSDRangel::setValue(&id, pJson["id"], "QString", "QString");
99 
100  ::SWGSDRangel::setValue(&direction, pJson["direction"], "qint32", "");
101 
102  ::SWGSDRangel::setValue(&version, pJson["version"], "QString", "QString");
103 
104  ::SWGSDRangel::setValue(&index, pJson["index"], "qint32", "");
105 
106 }
107 
108 QString
110 {
111  QJsonObject* obj = this->asJsonObject();
112 
113  QJsonDocument doc(*obj);
114  QByteArray bytes = doc.toJson();
115  delete obj;
116  return QString(bytes);
117 }
118 
119 QJsonObject*
121  QJsonObject* obj = new QJsonObject();
122  if(name != nullptr && *name != QString("")){
123  toJsonValue(QString("name"), name, obj, QString("QString"));
124  }
125  if(id_uri != nullptr && *id_uri != QString("")){
126  toJsonValue(QString("idURI"), id_uri, obj, QString("QString"));
127  }
128  if(id != nullptr && *id != QString("")){
129  toJsonValue(QString("id"), id, obj, QString("QString"));
130  }
131  if(m_direction_isSet){
132  obj->insert("direction", QJsonValue(direction));
133  }
134  if(version != nullptr && *version != QString("")){
135  toJsonValue(QString("version"), version, obj, QString("QString"));
136  }
137  if(m_index_isSet){
138  obj->insert("index", QJsonValue(index));
139  }
140 
141  return obj;
142 }
143 
144 QString*
146  return name;
147 }
148 void
150  this->name = name;
151  this->m_name_isSet = true;
152 }
153 
154 QString*
156  return id_uri;
157 }
158 void
160  this->id_uri = id_uri;
161  this->m_id_uri_isSet = true;
162 }
163 
164 QString*
166  return id;
167 }
168 void
170  this->id = id;
171  this->m_id_isSet = true;
172 }
173 
174 qint32
176  return direction;
177 }
178 void
180  this->direction = direction;
181  this->m_direction_isSet = true;
182 }
183 
184 QString*
186  return version;
187 }
188 void
190  this->version = version;
191  this->m_version_isSet = true;
192 }
193 
194 qint32
196  return index;
197 }
198 void
200  this->index = index;
201  this->m_index_isSet = true;
202 }
203 
204 
205 bool
207  bool isObjectUpdated = false;
208  do{
209  if(name != nullptr && *name != QString("")){ isObjectUpdated = true; break;}
210  if(id_uri != nullptr && *id_uri != QString("")){ isObjectUpdated = true; break;}
211  if(id != nullptr && *id != QString("")){ isObjectUpdated = true; break;}
212  if(m_direction_isSet){ isObjectUpdated = true; break;}
213  if(version != nullptr && *version != QString("")){ isObjectUpdated = true; break;}
214  if(m_index_isSet){ isObjectUpdated = true; break;}
215  }while(false);
216  return isObjectUpdated;
217 }
218 }
219 
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
virtual void fromJsonObject(QJsonObject &json) override
virtual QString asJson() override
virtual SWGChannelListItem * fromJson(QString &jsonString) override
virtual QJsonObject * asJsonObject() override
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25