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.
SWGFileInputReport.cpp
Go to the documentation of this file.
1 
14 #include "SWGFileInputReport.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  file_name = nullptr;
32  m_file_name_isSet = false;
33  sample_rate = 0;
34  m_sample_rate_isSet = false;
35  sample_size = 0;
36  m_sample_size_isSet = false;
37  absolute_time = nullptr;
38  m_absolute_time_isSet = false;
39  elapsed_time = nullptr;
40  m_elapsed_time_isSet = false;
41  duration_time = nullptr;
42  m_duration_time_isSet = false;
43 }
44 
46  this->cleanup();
47 }
48 
49 void
51  file_name = new QString("");
52  m_file_name_isSet = false;
53  sample_rate = 0;
54  m_sample_rate_isSet = false;
55  sample_size = 0;
56  m_sample_size_isSet = false;
57  absolute_time = new QString("");
58  m_absolute_time_isSet = false;
59  elapsed_time = new QString("");
60  m_elapsed_time_isSet = false;
61  duration_time = new QString("");
62  m_duration_time_isSet = false;
63 }
64 
65 void
67  if(file_name != nullptr) {
68  delete file_name;
69  }
70 
71 
72  if(absolute_time != nullptr) {
73  delete absolute_time;
74  }
75  if(elapsed_time != nullptr) {
76  delete elapsed_time;
77  }
78  if(duration_time != nullptr) {
79  delete duration_time;
80  }
81 }
82 
85  QByteArray array (json.toStdString().c_str());
86  QJsonDocument doc = QJsonDocument::fromJson(array);
87  QJsonObject jsonObject = doc.object();
88  this->fromJsonObject(jsonObject);
89  return this;
90 }
91 
92 void
94  ::SWGSDRangel::setValue(&file_name, pJson["fileName"], "QString", "QString");
95 
96  ::SWGSDRangel::setValue(&sample_rate, pJson["sampleRate"], "qint32", "");
97 
98  ::SWGSDRangel::setValue(&sample_size, pJson["sampleSize"], "qint32", "");
99 
100  ::SWGSDRangel::setValue(&absolute_time, pJson["absoluteTime"], "QString", "QString");
101 
102  ::SWGSDRangel::setValue(&elapsed_time, pJson["elapsedTime"], "QString", "QString");
103 
104  ::SWGSDRangel::setValue(&duration_time, pJson["durationTime"], "QString", "QString");
105 
106 }
107 
108 QString
110 {
111  QJsonObject* obj = this->asJsonObject();
112 
113  QJsonDocument doc(*obj);
114  QByteArray bytes = doc.toJson();
115  delete obj;
116  return QString(bytes);
117 }
118 
119 QJsonObject*
121  QJsonObject* obj = new QJsonObject();
122  if(file_name != nullptr && *file_name != QString("")){
123  toJsonValue(QString("fileName"), file_name, obj, QString("QString"));
124  }
126  obj->insert("sampleRate", QJsonValue(sample_rate));
127  }
129  obj->insert("sampleSize", QJsonValue(sample_size));
130  }
131  if(absolute_time != nullptr && *absolute_time != QString("")){
132  toJsonValue(QString("absoluteTime"), absolute_time, obj, QString("QString"));
133  }
134  if(elapsed_time != nullptr && *elapsed_time != QString("")){
135  toJsonValue(QString("elapsedTime"), elapsed_time, obj, QString("QString"));
136  }
137  if(duration_time != nullptr && *duration_time != QString("")){
138  toJsonValue(QString("durationTime"), duration_time, obj, QString("QString"));
139  }
140 
141  return obj;
142 }
143 
144 QString*
146  return file_name;
147 }
148 void
150  this->file_name = file_name;
151  this->m_file_name_isSet = true;
152 }
153 
154 qint32
156  return sample_rate;
157 }
158 void
160  this->sample_rate = sample_rate;
161  this->m_sample_rate_isSet = true;
162 }
163 
164 qint32
166  return sample_size;
167 }
168 void
170  this->sample_size = sample_size;
171  this->m_sample_size_isSet = true;
172 }
173 
174 QString*
176  return absolute_time;
177 }
178 void
180  this->absolute_time = absolute_time;
181  this->m_absolute_time_isSet = true;
182 }
183 
184 QString*
186  return elapsed_time;
187 }
188 void
190  this->elapsed_time = elapsed_time;
191  this->m_elapsed_time_isSet = true;
192 }
193 
194 QString*
196  return duration_time;
197 }
198 void
200  this->duration_time = duration_time;
201  this->m_duration_time_isSet = true;
202 }
203 
204 
205 bool
207  bool isObjectUpdated = false;
208  do{
209  if(file_name != nullptr && *file_name != QString("")){ isObjectUpdated = true; break;}
210  if(m_sample_rate_isSet){ isObjectUpdated = true; break;}
211  if(m_sample_size_isSet){ isObjectUpdated = true; break;}
212  if(absolute_time != nullptr && *absolute_time != QString("")){ isObjectUpdated = true; break;}
213  if(elapsed_time != nullptr && *elapsed_time != QString("")){ isObjectUpdated = true; break;}
214  if(duration_time != nullptr && *duration_time != QString("")){ isObjectUpdated = true; break;}
215  }while(false);
216  return isObjectUpdated;
217 }
218 }
219 
void setFileName(QString *file_name)
void setAbsoluteTime(QString *absolute_time)
void setSampleRate(qint32 sample_rate)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
virtual QString asJson() override
void setDurationTime(QString *duration_time)
void setElapsedTime(QString *elapsed_time)
virtual void fromJsonObject(QJsonObject &json) override
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
virtual SWGFileInputReport * fromJson(QString &jsonString) override
void setSampleSize(qint32 sample_size)
virtual QJsonObject * asJsonObject() override