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.
SWGPerseusReport.cpp
Go to the documentation of this file.
1 
14 #include "SWGPerseusReport.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  sample_rates = nullptr;
32  m_sample_rates_isSet = false;
33 }
34 
36  this->cleanup();
37 }
38 
39 void
41  sample_rates = new QList<SWGSampleRate*>();
42  m_sample_rates_isSet = false;
43 }
44 
45 void
47  if(sample_rates != nullptr) {
48  auto arr = sample_rates;
49  for(auto o: *arr) {
50  delete o;
51  }
52  delete sample_rates;
53  }
54 }
55 
58  QByteArray array (json.toStdString().c_str());
59  QJsonDocument doc = QJsonDocument::fromJson(array);
60  QJsonObject jsonObject = doc.object();
61  this->fromJsonObject(jsonObject);
62  return this;
63 }
64 
65 void
66 SWGPerseusReport::fromJsonObject(QJsonObject &pJson) {
67 
68  ::SWGSDRangel::setValue(&sample_rates, pJson["sampleRates"], "QList", "SWGSampleRate");
69 }
70 
71 QString
73 {
74  QJsonObject* obj = this->asJsonObject();
75 
76  QJsonDocument doc(*obj);
77  QByteArray bytes = doc.toJson();
78  delete obj;
79  return QString(bytes);
80 }
81 
82 QJsonObject*
84  QJsonObject* obj = new QJsonObject();
85  if(sample_rates->size() > 0){
86  toJsonArray((QList<void*>*)sample_rates, obj, "sampleRates", "SWGSampleRate");
87  }
88 
89  return obj;
90 }
91 
92 QList<SWGSampleRate*>*
94  return sample_rates;
95 }
96 void
98  this->sample_rates = sample_rates;
99  this->m_sample_rates_isSet = true;
100 }
101 
102 
103 bool
105  bool isObjectUpdated = false;
106  do{
107  if(sample_rates->size() > 0){ isObjectUpdated = true; break;}
108  }while(false);
109  return isObjectUpdated;
110 }
111 }
112 
QList< SWGSampleRate * > * sample_rates
virtual SWGPerseusReport * fromJson(QString &jsonString) override
void setSampleRates(QList< SWGSampleRate *> *sample_rates)
virtual void fromJsonObject(QJsonObject &json) override
QList< SWGSampleRate * > * getSampleRates()
virtual bool isSet() override
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
virtual QJsonObject * asJsonObject() override
virtual QString asJson() override