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.
SWGDVSerialDevice.cpp
Go to the documentation of this file.
1 
14 #include "SWGDVSerialDevice.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  device_name = nullptr;
32  m_device_name_isSet = false;
33 }
34 
36  this->cleanup();
37 }
38 
39 void
41  device_name = new QString("");
42  m_device_name_isSet = false;
43 }
44 
45 void
47  if(device_name != nullptr) {
48  delete device_name;
49  }
50 }
51 
54  QByteArray array (json.toStdString().c_str());
55  QJsonDocument doc = QJsonDocument::fromJson(array);
56  QJsonObject jsonObject = doc.object();
57  this->fromJsonObject(jsonObject);
58  return this;
59 }
60 
61 void
62 SWGDVSerialDevice::fromJsonObject(QJsonObject &pJson) {
63  ::SWGSDRangel::setValue(&device_name, pJson["deviceName"], "QString", "QString");
64 
65 }
66 
67 QString
69 {
70  QJsonObject* obj = this->asJsonObject();
71 
72  QJsonDocument doc(*obj);
73  QByteArray bytes = doc.toJson();
74  delete obj;
75  return QString(bytes);
76 }
77 
78 QJsonObject*
80  QJsonObject* obj = new QJsonObject();
81  if(device_name != nullptr && *device_name != QString("")){
82  toJsonValue(QString("deviceName"), device_name, obj, QString("QString"));
83  }
84 
85  return obj;
86 }
87 
88 QString*
90  return device_name;
91 }
92 void
94  this->device_name = device_name;
95  this->m_device_name_isSet = true;
96 }
97 
98 
99 bool
101  bool isObjectUpdated = false;
102  do{
103  if(device_name != nullptr && *device_name != QString("")){ isObjectUpdated = true; break;}
104  }while(false);
105  return isObjectUpdated;
106 }
107 }
108 
void setDeviceName(QString *device_name)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
virtual void fromJsonObject(QJsonObject &json) override
virtual QJsonObject * asJsonObject() override
virtual QString asJson() override
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
virtual SWGDVSerialDevice * fromJson(QString &jsonString) override