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.
SWGLoggingInfo.cpp
Go to the documentation of this file.
1 
14 #include "SWGLoggingInfo.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  console_level = nullptr;
32  m_console_level_isSet = false;
33  file_level = nullptr;
34  m_file_level_isSet = false;
35  dump_to_file = 0;
36  m_dump_to_file_isSet = false;
37  file_name = nullptr;
38  m_file_name_isSet = false;
39 }
40 
42  this->cleanup();
43 }
44 
45 void
47  console_level = new QString("");
48  m_console_level_isSet = false;
49  file_level = new QString("");
50  m_file_level_isSet = false;
51  dump_to_file = 0;
52  m_dump_to_file_isSet = false;
53  file_name = new QString("");
54  m_file_name_isSet = false;
55 }
56 
57 void
59  if(console_level != nullptr) {
60  delete console_level;
61  }
62  if(file_level != nullptr) {
63  delete file_level;
64  }
65 
66  if(file_name != nullptr) {
67  delete file_name;
68  }
69 }
70 
72 SWGLoggingInfo::fromJson(QString &json) {
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
81 SWGLoggingInfo::fromJsonObject(QJsonObject &pJson) {
82  ::SWGSDRangel::setValue(&console_level, pJson["consoleLevel"], "QString", "QString");
83 
84  ::SWGSDRangel::setValue(&file_level, pJson["fileLevel"], "QString", "QString");
85 
86  ::SWGSDRangel::setValue(&dump_to_file, pJson["dumpToFile"], "qint32", "");
87 
88  ::SWGSDRangel::setValue(&file_name, pJson["fileName"], "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(console_level != nullptr && *console_level != QString("")){
107  toJsonValue(QString("consoleLevel"), console_level, obj, QString("QString"));
108  }
109  if(file_level != nullptr && *file_level != QString("")){
110  toJsonValue(QString("fileLevel"), file_level, obj, QString("QString"));
111  }
113  obj->insert("dumpToFile", QJsonValue(dump_to_file));
114  }
115  if(file_name != nullptr && *file_name != QString("")){
116  toJsonValue(QString("fileName"), file_name, obj, QString("QString"));
117  }
118 
119  return obj;
120 }
121 
122 QString*
124  return console_level;
125 }
126 void
128  this->console_level = console_level;
129  this->m_console_level_isSet = true;
130 }
131 
132 QString*
134  return file_level;
135 }
136 void
138  this->file_level = file_level;
139  this->m_file_level_isSet = true;
140 }
141 
142 qint32
144  return dump_to_file;
145 }
146 void
148  this->dump_to_file = dump_to_file;
149  this->m_dump_to_file_isSet = true;
150 }
151 
152 QString*
154  return file_name;
155 }
156 void
158  this->file_name = file_name;
159  this->m_file_name_isSet = true;
160 }
161 
162 
163 bool
165  bool isObjectUpdated = false;
166  do{
167  if(console_level != nullptr && *console_level != QString("")){ isObjectUpdated = true; break;}
168  if(file_level != nullptr && *file_level != QString("")){ isObjectUpdated = true; break;}
169  if(m_dump_to_file_isSet){ isObjectUpdated = true; break;}
170  if(file_name != nullptr && *file_name != QString("")){ isObjectUpdated = true; break;}
171  }while(false);
172  return isObjectUpdated;
173 }
174 }
175 
void setFileLevel(QString *file_level)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
virtual QJsonObject * asJsonObject() override
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
virtual bool isSet() override
virtual QString asJson() override
void setConsoleLevel(QString *console_level)
void setFileName(QString *file_name)
virtual void fromJsonObject(QJsonObject &json) override
virtual SWGLoggingInfo * fromJson(QString &jsonString) override
void setDumpToFile(qint32 dump_to_file)