FemaLocalSoftware/logs_r.h
2024-12-28 20:15:48 +03:00

61 lines
2.0 KiB
C++

#ifndef LOGS_R_H
#define LOGS_R_H
#include <QString>
#include <QJsonObject>
#include <QJsonArray>
#include <QList>
class LogsR {
public:
LogsR() = default;
LogsR(const QString& mark, const QString& message, const QString& sensorGroup,
const QString& sensorId, const QString& serial, int threatLevel, const QString& time)
: mark(mark), message(message), sensor_group(sensorGroup), sensor_id(sensorId),
serial(serial), threat_level(threatLevel), time(time) {}
void parseResponse(const QJsonObject& json) {
if (json.contains("mark") && json["mark"].isString()) {
mark = json["mark"].toString();
}
if (json.contains("message") && json["message"].isString()) {
message = json["message"].toString();
}
if (json.contains("sensor_group") && json["sensor_group"].isString()) {
sensor_group = json["sensor_group"].toString();
}
if (json.contains("sensor_id") && json["sensor_id"].isString()) {
sensor_id = json["sensor_id"].toString();
}
if (json.contains("serial") && json["serial"].isString()) {
serial = json["serial"].toString();
}
if (json.contains("threat_level") && json["threat_level"].isDouble()) {
threat_level = json["threat_level"].toInt();
}
if (json.contains("time") && json["time"].isString()) {
time = json["time"].toString();
}
}
QString getMark() const { return mark; }
QString getMessage() const { return message; }
QString getSensorGroup() const { return sensor_group; }
QString getSensorId() const { return sensor_id; }
QString getSerial() const { return serial; }
int getThreatLevel() const { return threat_level; }
QString getTime() const { return time; }
private:
QString mark;
QString message;
QString sensor_group;
QString sensor_id;
QString serial;
int threat_level;
QString time;
};
#endif // LOGS_R_H