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