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.
SWGRemoteSourceSettings.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  data_address = nullptr;
32  m_data_address_isSet = false;
33  data_port = 0;
34  m_data_port_isSet = false;
35  rgb_color = 0;
36  m_rgb_color_isSet = false;
37  title = nullptr;
38  m_title_isSet = false;
39  use_reverse_api = 0;
41  reverse_api_address = nullptr;
43  reverse_api_port = 0;
49 }
50 
52  this->cleanup();
53 }
54 
55 void
57  data_address = new QString("");
58  m_data_address_isSet = false;
59  data_port = 0;
60  m_data_port_isSet = false;
61  rgb_color = 0;
62  m_rgb_color_isSet = false;
63  title = new QString("");
64  m_title_isSet = false;
65  use_reverse_api = 0;
67  reverse_api_address = new QString("");
69  reverse_api_port = 0;
75 }
76 
77 void
79  if(data_address != nullptr) {
80  delete data_address;
81  }
82 
83 
84  if(title != nullptr) {
85  delete title;
86  }
87 
88  if(reverse_api_address != nullptr) {
89  delete reverse_api_address;
90  }
91 
92 
93 
94 }
95 
98  QByteArray array (json.toStdString().c_str());
99  QJsonDocument doc = QJsonDocument::fromJson(array);
100  QJsonObject jsonObject = doc.object();
101  this->fromJsonObject(jsonObject);
102  return this;
103 }
104 
105 void
107  ::SWGSDRangel::setValue(&data_address, pJson["dataAddress"], "QString", "QString");
108 
109  ::SWGSDRangel::setValue(&data_port, pJson["dataPort"], "qint32", "");
110 
111  ::SWGSDRangel::setValue(&rgb_color, pJson["rgbColor"], "qint32", "");
112 
113  ::SWGSDRangel::setValue(&title, pJson["title"], "QString", "QString");
114 
115  ::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", "");
116 
117  ::SWGSDRangel::setValue(&reverse_api_address, pJson["reverseAPIAddress"], "QString", "QString");
118 
119  ::SWGSDRangel::setValue(&reverse_api_port, pJson["reverseAPIPort"], "qint32", "");
120 
121  ::SWGSDRangel::setValue(&reverse_api_device_index, pJson["reverseAPIDeviceIndex"], "qint32", "");
122 
123  ::SWGSDRangel::setValue(&reverse_api_channel_index, pJson["reverseAPIChannelIndex"], "qint32", "");
124 
125 }
126 
127 QString
129 {
130  QJsonObject* obj = this->asJsonObject();
131 
132  QJsonDocument doc(*obj);
133  QByteArray bytes = doc.toJson();
134  delete obj;
135  return QString(bytes);
136 }
137 
138 QJsonObject*
140  QJsonObject* obj = new QJsonObject();
141  if(data_address != nullptr && *data_address != QString("")){
142  toJsonValue(QString("dataAddress"), data_address, obj, QString("QString"));
143  }
144  if(m_data_port_isSet){
145  obj->insert("dataPort", QJsonValue(data_port));
146  }
147  if(m_rgb_color_isSet){
148  obj->insert("rgbColor", QJsonValue(rgb_color));
149  }
150  if(title != nullptr && *title != QString("")){
151  toJsonValue(QString("title"), title, obj, QString("QString"));
152  }
154  obj->insert("useReverseAPI", QJsonValue(use_reverse_api));
155  }
156  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){
157  toJsonValue(QString("reverseAPIAddress"), reverse_api_address, obj, QString("QString"));
158  }
160  obj->insert("reverseAPIPort", QJsonValue(reverse_api_port));
161  }
163  obj->insert("reverseAPIDeviceIndex", QJsonValue(reverse_api_device_index));
164  }
166  obj->insert("reverseAPIChannelIndex", QJsonValue(reverse_api_channel_index));
167  }
168 
169  return obj;
170 }
171 
172 QString*
174  return data_address;
175 }
176 void
178  this->data_address = data_address;
179  this->m_data_address_isSet = true;
180 }
181 
182 qint32
184  return data_port;
185 }
186 void
188  this->data_port = data_port;
189  this->m_data_port_isSet = true;
190 }
191 
192 qint32
194  return rgb_color;
195 }
196 void
198  this->rgb_color = rgb_color;
199  this->m_rgb_color_isSet = true;
200 }
201 
202 QString*
204  return title;
205 }
206 void
208  this->title = title;
209  this->m_title_isSet = true;
210 }
211 
212 qint32
214  return use_reverse_api;
215 }
216 void
218  this->use_reverse_api = use_reverse_api;
219  this->m_use_reverse_api_isSet = true;
220 }
221 
222 QString*
224  return reverse_api_address;
225 }
226 void
228  this->reverse_api_address = reverse_api_address;
229  this->m_reverse_api_address_isSet = true;
230 }
231 
232 qint32
234  return reverse_api_port;
235 }
236 void
238  this->reverse_api_port = reverse_api_port;
239  this->m_reverse_api_port_isSet = true;
240 }
241 
242 qint32
245 }
246 void
248  this->reverse_api_device_index = reverse_api_device_index;
250 }
251 
252 qint32
255 }
256 void
258  this->reverse_api_channel_index = reverse_api_channel_index;
260 }
261 
262 
263 bool
265  bool isObjectUpdated = false;
266  do{
267  if(data_address != nullptr && *data_address != QString("")){ isObjectUpdated = true; break;}
268  if(m_data_port_isSet){ isObjectUpdated = true; break;}
269  if(m_rgb_color_isSet){ isObjectUpdated = true; break;}
270  if(title != nullptr && *title != QString("")){ isObjectUpdated = true; break;}
271  if(m_use_reverse_api_isSet){ isObjectUpdated = true; break;}
272  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){ isObjectUpdated = true; break;}
273  if(m_reverse_api_port_isSet){ isObjectUpdated = true; break;}
274  if(m_reverse_api_device_index_isSet){ isObjectUpdated = true; break;}
275  if(m_reverse_api_channel_index_isSet){ isObjectUpdated = true; break;}
276  }while(false);
277  return isObjectUpdated;
278 }
279 }
280 
virtual void fromJsonObject(QJsonObject &json) override
void setReverseApiPort(qint32 reverse_api_port)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setUseReverseApi(qint32 use_reverse_api)
virtual QJsonObject * asJsonObject() override
void setReverseApiAddress(QString *reverse_api_address)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
virtual SWGRemoteSourceSettings * fromJson(QString &jsonString) override
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)