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.
SWGPresetIdentifier.cpp
Go to the documentation of this file.
1 
14 #include "SWGPresetIdentifier.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  group_name = nullptr;
32  m_group_name_isSet = false;
33  center_frequency = 0L;
35  type = nullptr;
36  m_type_isSet = false;
37  name = nullptr;
38  m_name_isSet = false;
39 }
40 
42  this->cleanup();
43 }
44 
45 void
47  group_name = new QString("");
48  m_group_name_isSet = false;
49  center_frequency = 0L;
51  type = new QString("");
52  m_type_isSet = false;
53  name = new QString("");
54  m_name_isSet = false;
55 }
56 
57 void
59  if(group_name != nullptr) {
60  delete group_name;
61  }
62 
63  if(type != nullptr) {
64  delete type;
65  }
66  if(name != nullptr) {
67  delete name;
68  }
69 }
70 
73  QByteArray array (json.toStdString().c_str());
74  QJsonDocument doc = QJsonDocument::fromJson(array);
75  QJsonObject jsonObject = doc.object();
76  this->fromJsonObject(jsonObject);
77  return this;
78 }
79 
80 void
82  ::SWGSDRangel::setValue(&group_name, pJson["groupName"], "QString", "QString");
83 
84  ::SWGSDRangel::setValue(&center_frequency, pJson["centerFrequency"], "qint64", "");
85 
86  ::SWGSDRangel::setValue(&type, pJson["type"], "QString", "QString");
87 
88  ::SWGSDRangel::setValue(&name, pJson["name"], "QString", "QString");
89 
90 }
91 
92 QString
94 {
95  QJsonObject* obj = this->asJsonObject();
96 
97  QJsonDocument doc(*obj);
98  QByteArray bytes = doc.toJson();
99  delete obj;
100  return QString(bytes);
101 }
102 
103 QJsonObject*
105  QJsonObject* obj = new QJsonObject();
106  if(group_name != nullptr && *group_name != QString("")){
107  toJsonValue(QString("groupName"), group_name, obj, QString("QString"));
108  }
110  obj->insert("centerFrequency", QJsonValue(center_frequency));
111  }
112  if(type != nullptr && *type != QString("")){
113  toJsonValue(QString("type"), type, obj, QString("QString"));
114  }
115  if(name != nullptr && *name != QString("")){
116  toJsonValue(QString("name"), name, obj, QString("QString"));
117  }
118 
119  return obj;
120 }
121 
122 QString*
124  return group_name;
125 }
126 void
128  this->group_name = group_name;
129  this->m_group_name_isSet = true;
130 }
131 
132 qint64
134  return center_frequency;
135 }
136 void
138  this->center_frequency = center_frequency;
139  this->m_center_frequency_isSet = true;
140 }
141 
142 QString*
144  return type;
145 }
146 void
148  this->type = type;
149  this->m_type_isSet = true;
150 }
151 
152 QString*
154  return name;
155 }
156 void
158  this->name = name;
159  this->m_name_isSet = true;
160 }
161 
162 
163 bool
165  bool isObjectUpdated = false;
166  do{
167  if(group_name != nullptr && *group_name != QString("")){ isObjectUpdated = true; break;}
168  if(m_center_frequency_isSet){ isObjectUpdated = true; break;}
169  if(type != nullptr && *type != QString("")){ isObjectUpdated = true; break;}
170  if(name != nullptr && *name != QString("")){ isObjectUpdated = true; break;}
171  }while(false);
172  return isObjectUpdated;
173 }
174 }
175 
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
virtual void fromJsonObject(QJsonObject &json) override
virtual QJsonObject * asJsonObject() override
virtual SWGPresetIdentifier * fromJson(QString &jsonString) override
void setGroupName(QString *group_name)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void setCenterFrequency(qint64 center_frequency)
virtual QString asJson() override