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.
SWGFrequencyRange.cpp
Go to the documentation of this file.
1 
14 #include "SWGFrequencyRange.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  min = 0L;
32  m_min_isSet = false;
33  max = 0L;
34  m_max_isSet = false;
35  step = 0;
36  m_step_isSet = false;
37 }
38 
40  this->cleanup();
41 }
42 
43 void
45  min = 0L;
46  m_min_isSet = false;
47  max = 0L;
48  m_max_isSet = false;
49  step = 0;
50  m_step_isSet = false;
51 }
52 
53 void
55 
56 
57 
58 }
59 
62  QByteArray array (json.toStdString().c_str());
63  QJsonDocument doc = QJsonDocument::fromJson(array);
64  QJsonObject jsonObject = doc.object();
65  this->fromJsonObject(jsonObject);
66  return this;
67 }
68 
69 void
70 SWGFrequencyRange::fromJsonObject(QJsonObject &pJson) {
71  ::SWGSDRangel::setValue(&min, pJson["min"], "qint64", "");
72 
73  ::SWGSDRangel::setValue(&max, pJson["max"], "qint64", "");
74 
75  ::SWGSDRangel::setValue(&step, pJson["step"], "qint32", "");
76 
77 }
78 
79 QString
81 {
82  QJsonObject* obj = this->asJsonObject();
83 
84  QJsonDocument doc(*obj);
85  QByteArray bytes = doc.toJson();
86  delete obj;
87  return QString(bytes);
88 }
89 
90 QJsonObject*
92  QJsonObject* obj = new QJsonObject();
93  if(m_min_isSet){
94  obj->insert("min", QJsonValue(min));
95  }
96  if(m_max_isSet){
97  obj->insert("max", QJsonValue(max));
98  }
99  if(m_step_isSet){
100  obj->insert("step", QJsonValue(step));
101  }
102 
103  return obj;
104 }
105 
106 qint64
108  return min;
109 }
110 void
112  this->min = min;
113  this->m_min_isSet = true;
114 }
115 
116 qint64
118  return max;
119 }
120 void
122  this->max = max;
123  this->m_max_isSet = true;
124 }
125 
126 qint32
128  return step;
129 }
130 void
132  this->step = step;
133  this->m_step_isSet = true;
134 }
135 
136 
137 bool
139  bool isObjectUpdated = false;
140  do{
141  if(m_min_isSet){ isObjectUpdated = true; break;}
142  if(m_max_isSet){ isObjectUpdated = true; break;}
143  if(m_step_isSet){ isObjectUpdated = true; break;}
144  }while(false);
145  return isObjectUpdated;
146 }
147 }
148 
virtual void fromJsonObject(QJsonObject &json) override
virtual QString asJson() override
virtual SWGFrequencyRange * fromJson(QString &jsonString) override
virtual QJsonObject * asJsonObject() override
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25