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.
SWGLocationInformation.cpp
Go to the documentation of this file.
1 
14 #include "SWGLocationInformation.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  latitude = 0.0f;
32  m_latitude_isSet = false;
33  longitude = 0.0f;
34  m_longitude_isSet = false;
35 }
36 
38  this->cleanup();
39 }
40 
41 void
43  latitude = 0.0f;
44  m_latitude_isSet = false;
45  longitude = 0.0f;
46  m_longitude_isSet = false;
47 }
48 
49 void
51 
52 
53 }
54 
57  QByteArray array (json.toStdString().c_str());
58  QJsonDocument doc = QJsonDocument::fromJson(array);
59  QJsonObject jsonObject = doc.object();
60  this->fromJsonObject(jsonObject);
61  return this;
62 }
63 
64 void
66  ::SWGSDRangel::setValue(&latitude, pJson["latitude"], "float", "");
67 
68  ::SWGSDRangel::setValue(&longitude, pJson["longitude"], "float", "");
69 
70 }
71 
72 QString
74 {
75  QJsonObject* obj = this->asJsonObject();
76 
77  QJsonDocument doc(*obj);
78  QByteArray bytes = doc.toJson();
79  delete obj;
80  return QString(bytes);
81 }
82 
83 QJsonObject*
85  QJsonObject* obj = new QJsonObject();
86  if(m_latitude_isSet){
87  obj->insert("latitude", QJsonValue(latitude));
88  }
90  obj->insert("longitude", QJsonValue(longitude));
91  }
92 
93  return obj;
94 }
95 
96 float
98  return latitude;
99 }
100 void
102  this->latitude = latitude;
103  this->m_latitude_isSet = true;
104 }
105 
106 float
108  return longitude;
109 }
110 void
112  this->longitude = longitude;
113  this->m_longitude_isSet = true;
114 }
115 
116 
117 bool
119  bool isObjectUpdated = false;
120  do{
121  if(m_latitude_isSet){ isObjectUpdated = true; break;}
122  if(m_longitude_isSet){ isObjectUpdated = true; break;}
123  }while(false);
124  return isObjectUpdated;
125 }
126 }
127 
virtual QJsonObject * asJsonObject() override
virtual SWGLocationInformation * fromJson(QString &jsonString) override
virtual void fromJsonObject(QJsonObject &json) override
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25