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.
SWGSoapySDRGainSetting.cpp
Go to the documentation of this file.
1 
14 #include "SWGSoapySDRGainSetting.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  range = nullptr;
34  m_range_isSet = false;
35 }
36 
38  this->cleanup();
39 }
40 
41 void
43  name = new QString("");
44  m_name_isSet = false;
45  range = new SWGRangeFloat();
46  m_range_isSet = false;
47 }
48 
49 void
51  if(name != nullptr) {
52  delete name;
53  }
54  if(range != nullptr) {
55  delete range;
56  }
57 }
58 
61  QByteArray array (json.toStdString().c_str());
62  QJsonDocument doc = QJsonDocument::fromJson(array);
63  QJsonObject jsonObject = doc.object();
64  this->fromJsonObject(jsonObject);
65  return this;
66 }
67 
68 void
70  ::SWGSDRangel::setValue(&name, pJson["name"], "QString", "QString");
71 
72  ::SWGSDRangel::setValue(&range, pJson["range"], "SWGRangeFloat", "SWGRangeFloat");
73 
74 }
75 
76 QString
78 {
79  QJsonObject* obj = this->asJsonObject();
80 
81  QJsonDocument doc(*obj);
82  QByteArray bytes = doc.toJson();
83  delete obj;
84  return QString(bytes);
85 }
86 
87 QJsonObject*
89  QJsonObject* obj = new QJsonObject();
90  if(name != nullptr && *name != QString("")){
91  toJsonValue(QString("name"), name, obj, QString("QString"));
92  }
93  if((range != nullptr) && (range->isSet())){
94  toJsonValue(QString("range"), range, obj, QString("SWGRangeFloat"));
95  }
96 
97  return obj;
98 }
99 
100 QString*
102  return name;
103 }
104 void
106  this->name = name;
107  this->m_name_isSet = true;
108 }
109 
112  return range;
113 }
114 void
116  this->range = range;
117  this->m_range_isSet = true;
118 }
119 
120 
121 bool
123  bool isObjectUpdated = false;
124  do{
125  if(name != nullptr && *name != QString("")){ isObjectUpdated = true; break;}
126  if(range != nullptr && range->isSet()){ isObjectUpdated = true; break;}
127  }while(false);
128  return isObjectUpdated;
129 }
130 }
131 
virtual SWGSoapySDRGainSetting * fromJson(QString &jsonString) override
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
virtual void fromJsonObject(QJsonObject &json) override
virtual bool isSet() override
virtual QJsonObject * asJsonObject() override