forked from foldynl/QLog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJsonFormat.cpp
63 lines (49 loc) · 1.47 KB
/
JsonFormat.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <QJsonDocument>
#include <QSqlRecord>
#include "JsonFormat.h"
#include "core/debug.h"
MODULE_IDENTIFICATION("qlog.logformat.jsonformat");
void JsonFormat::exportStart()
{
FCT_IDENTIFICATION;
data = QJsonArray();
}
void JsonFormat::exportContact(const QSqlRecord& record, QMap<QString, QString>*applTags)
{
FCT_IDENTIFICATION;
qCDebug(function_parameters)<<record;
contact = QJsonObject();
writeSQLRecord(record, applTags);
data.append(contact);
}
void JsonFormat::exportEnd()
{
FCT_IDENTIFICATION;
QJsonObject msg;
QJsonObject headerData;
headerData["adif_ver"] = ADIF_VERSION_STRING;
headerData["programid"] = PROGRAMID_STRING;
headerData["programversion"] = VERSION;
headerData["created_timestamp"] = QDateTime::currentDateTimeUtc().toString("yyyyMMdd hhmmss");
msg["header"] = headerData;
msg["records"] = data;
QJsonDocument doc(msg);
stream << doc.toJson();
}
void JsonFormat::writeField(const QString &name,
bool presenceCondition,
const QString &value,
const QString &type)
{
FCT_IDENTIFICATION;
qCDebug(function_parameters)<< name
<< presenceCondition
<< value
<< type;
if (value.isEmpty() || !presenceCondition) return;
contact[name] = value;
}
bool JsonFormat::importNext(QSqlRecord&)
{
return false;
}