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.
SWGLocalOutputSettings.cpp
Go to the documentation of this file.
1 
14 #include "SWGLocalOutputSettings.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  use_reverse_api = 0;
33  reverse_api_address = nullptr;
35  reverse_api_port = 0;
39 }
40 
42  this->cleanup();
43 }
44 
45 void
47  use_reverse_api = 0;
49  reverse_api_address = new QString("");
51  reverse_api_port = 0;
55 }
56 
57 void
59 
60  if(reverse_api_address != nullptr) {
61  delete reverse_api_address;
62  }
63 
64 
65 }
66 
69  QByteArray array (json.toStdString().c_str());
70  QJsonDocument doc = QJsonDocument::fromJson(array);
71  QJsonObject jsonObject = doc.object();
72  this->fromJsonObject(jsonObject);
73  return this;
74 }
75 
76 void
78  ::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", "");
79 
80  ::SWGSDRangel::setValue(&reverse_api_address, pJson["reverseAPIAddress"], "QString", "QString");
81 
82  ::SWGSDRangel::setValue(&reverse_api_port, pJson["reverseAPIPort"], "qint32", "");
83 
84  ::SWGSDRangel::setValue(&reverse_api_device_index, pJson["reverseAPIDeviceIndex"], "qint32", "");
85 
86 }
87 
88 QString
90 {
91  QJsonObject* obj = this->asJsonObject();
92 
93  QJsonDocument doc(*obj);
94  QByteArray bytes = doc.toJson();
95  delete obj;
96  return QString(bytes);
97 }
98 
99 QJsonObject*
101  QJsonObject* obj = new QJsonObject();
103  obj->insert("useReverseAPI", QJsonValue(use_reverse_api));
104  }
105  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){
106  toJsonValue(QString("reverseAPIAddress"), reverse_api_address, obj, QString("QString"));
107  }
109  obj->insert("reverseAPIPort", QJsonValue(reverse_api_port));
110  }
112  obj->insert("reverseAPIDeviceIndex", QJsonValue(reverse_api_device_index));
113  }
114 
115  return obj;
116 }
117 
118 qint32
120  return use_reverse_api;
121 }
122 void
124  this->use_reverse_api = use_reverse_api;
125  this->m_use_reverse_api_isSet = true;
126 }
127 
128 QString*
130  return reverse_api_address;
131 }
132 void
134  this->reverse_api_address = reverse_api_address;
135  this->m_reverse_api_address_isSet = true;
136 }
137 
138 qint32
140  return reverse_api_port;
141 }
142 void
144  this->reverse_api_port = reverse_api_port;
145  this->m_reverse_api_port_isSet = true;
146 }
147 
148 qint32
151 }
152 void
154  this->reverse_api_device_index = reverse_api_device_index;
156 }
157 
158 
159 bool
161  bool isObjectUpdated = false;
162  do{
163  if(m_use_reverse_api_isSet){ isObjectUpdated = true; break;}
164  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){ isObjectUpdated = true; break;}
165  if(m_reverse_api_port_isSet){ isObjectUpdated = true; break;}
166  if(m_reverse_api_device_index_isSet){ isObjectUpdated = true; break;}
167  }while(false);
168  return isObjectUpdated;
169 }
170 }
171 
virtual QJsonObject * asJsonObject() override
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setReverseApiPort(qint32 reverse_api_port)
void setReverseApiAddress(QString *reverse_api_address)
virtual void fromJsonObject(QJsonObject &json) override
virtual SWGLocalOutputSettings * fromJson(QString &jsonString) override
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void setUseReverseApi(qint32 use_reverse_api)