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.
SWGSoapySDRFrequencySetting.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  name = nullptr;
32  m_name_isSet = false;
33  ranges = nullptr;
34  m_ranges_isSet = false;
35 }
36 
38  this->cleanup();
39 }
40 
41 void
43  name = new QString("");
44  m_name_isSet = false;
45  ranges = new QList<SWGRangeFloat*>();
46  m_ranges_isSet = false;
47 }
48 
49 void
51  if(name != nullptr) {
52  delete name;
53  }
54  if(ranges != nullptr) {
55  auto arr = ranges;
56  for(auto o: *arr) {
57  delete o;
58  }
59  delete ranges;
60  }
61 }
62 
65  QByteArray array (json.toStdString().c_str());
66  QJsonDocument doc = QJsonDocument::fromJson(array);
67  QJsonObject jsonObject = doc.object();
68  this->fromJsonObject(jsonObject);
69  return this;
70 }
71 
72 void
74  ::SWGSDRangel::setValue(&name, pJson["name"], "QString", "QString");
75 
76 
77  ::SWGSDRangel::setValue(&ranges, pJson["ranges"], "QList", "SWGRangeFloat");
78 }
79 
80 QString
82 {
83  QJsonObject* obj = this->asJsonObject();
84 
85  QJsonDocument doc(*obj);
86  QByteArray bytes = doc.toJson();
87  delete obj;
88  return QString(bytes);
89 }
90 
91 QJsonObject*
93  QJsonObject* obj = new QJsonObject();
94  if(name != nullptr && *name != QString("")){
95  toJsonValue(QString("name"), name, obj, QString("QString"));
96  }
97  if(ranges->size() > 0){
98  toJsonArray((QList<void*>*)ranges, obj, "ranges", "SWGRangeFloat");
99  }
100 
101  return obj;
102 }
103 
104 QString*
106  return name;
107 }
108 void
110  this->name = name;
111  this->m_name_isSet = true;
112 }
113 
114 QList<SWGRangeFloat*>*
116  return ranges;
117 }
118 void
120  this->ranges = ranges;
121  this->m_ranges_isSet = true;
122 }
123 
124 
125 bool
127  bool isObjectUpdated = false;
128  do{
129  if(name != nullptr && *name != QString("")){ isObjectUpdated = true; break;}
130  if(ranges->size() > 0){ isObjectUpdated = true; break;}
131  }while(false);
132  return isObjectUpdated;
133 }
134 }
135 
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
virtual void fromJsonObject(QJsonObject &json) override
virtual SWGSoapySDRFrequencySetting * fromJson(QString &jsonString) override
void setRanges(QList< SWGRangeFloat *> *ranges)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void toJsonArray(QList< void *> *value, QJsonObject *output, QString innerName, QString innerType)
Definition: SWGHelpers.cpp:445