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.
SWGFrequencyBand.cpp
Go to the documentation of this file.
1 
14 #include "SWGFrequencyBand.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  lower_bound = 0;
34  m_lower_bound_isSet = false;
35  higher_bound = 0;
36  m_higher_bound_isSet = false;
37 }
38 
40  this->cleanup();
41 }
42 
43 void
45  name = new QString("");
46  m_name_isSet = false;
47  lower_bound = 0;
48  m_lower_bound_isSet = false;
49  higher_bound = 0;
50  m_higher_bound_isSet = false;
51 }
52 
53 void
55  if(name != nullptr) {
56  delete name;
57  }
58 
59 
60 }
61 
64  QByteArray array (json.toStdString().c_str());
65  QJsonDocument doc = QJsonDocument::fromJson(array);
66  QJsonObject jsonObject = doc.object();
67  this->fromJsonObject(jsonObject);
68  return this;
69 }
70 
71 void
72 SWGFrequencyBand::fromJsonObject(QJsonObject &pJson) {
73  ::SWGSDRangel::setValue(&name, pJson["name"], "QString", "QString");
74 
75  ::SWGSDRangel::setValue(&lower_bound, pJson["lowerBound"], "qint32", "");
76 
77  ::SWGSDRangel::setValue(&higher_bound, pJson["higherBound"], "qint32", "");
78 
79 }
80 
81 QString
83 {
84  QJsonObject* obj = this->asJsonObject();
85 
86  QJsonDocument doc(*obj);
87  QByteArray bytes = doc.toJson();
88  delete obj;
89  return QString(bytes);
90 }
91 
92 QJsonObject*
94  QJsonObject* obj = new QJsonObject();
95  if(name != nullptr && *name != QString("")){
96  toJsonValue(QString("name"), name, obj, QString("QString"));
97  }
99  obj->insert("lowerBound", QJsonValue(lower_bound));
100  }
102  obj->insert("higherBound", QJsonValue(higher_bound));
103  }
104 
105  return obj;
106 }
107 
108 QString*
110  return name;
111 }
112 void
114  this->name = name;
115  this->m_name_isSet = true;
116 }
117 
118 qint32
120  return lower_bound;
121 }
122 void
124  this->lower_bound = lower_bound;
125  this->m_lower_bound_isSet = true;
126 }
127 
128 qint32
130  return higher_bound;
131 }
132 void
134  this->higher_bound = higher_bound;
135  this->m_higher_bound_isSet = true;
136 }
137 
138 
139 bool
141  bool isObjectUpdated = false;
142  do{
143  if(name != nullptr && *name != QString("")){ isObjectUpdated = true; break;}
144  if(m_lower_bound_isSet){ isObjectUpdated = true; break;}
145  if(m_higher_bound_isSet){ isObjectUpdated = true; break;}
146  }while(false);
147  return isObjectUpdated;
148 }
149 }
150 
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setLowerBound(qint32 lower_bound)
virtual bool isSet() override
virtual QString asJson() override
virtual void fromJsonObject(QJsonObject &json) override
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
virtual QJsonObject * asJsonObject() override
void setHigherBound(qint32 higher_bound)
virtual SWGFrequencyBand * fromJson(QString &jsonString) override