| openPilotLog

ajson.h
1 /*
2 *openPilotLog - A FOSS Pilot Logbook Application
3 *Copyright (C) 2020-2021 Felix Turowsky
4 *
5 *This program is free software: you can redistribute it and/or modify
6 *it under the terms of the GNU General Public License as published by
7 *the Free Software Foundation, either version 3 of the License, or
8 *(at your option) any later version.
9 *
10 *This program is distributed in the hope that it will be useful,
11 *but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *GNU General Public License for more details.
14 *
15 *You should have received a copy of the GNU General Public License
16 *along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18 #ifndef AJSON_H
19 #define AJSON_H
20 #include "src/opl.h"
21 #include "src/database/adatabase.h"
22 #include <QJsonDocument>
23 #include <QJsonValue>
24 #include <QJsonObject>
25
29 class AJson
30 {
31 public:
32 AJson();
33 AJson(QFileInfo database_file);
34
42 static void exportDatabase();
43
47 static void importDatabase();
48
53 static QJsonDocument readFileToDoc(const QString &file_path);
54
58 static void writeDocToFile(const QJsonDocument &doc, const QString& file_name);
59
60 private:
61
65 const static QList<QPair<TableName_T, ADatabaseTable>> tables;
66
67 };
68
69 #endif // AJSON_H
AJson
The AJSON class is responsible for parsing the database (sqlite) to and from JSON.
Definition: ajson.h:30
AJson::readFileToDoc
static QJsonDocument readFileToDoc(const QString &file_path)
readToDocument reads data from a JSON file into a QJSonDocument
Definition: ajson.cpp:60
AJson::writeDocToFile
static void writeDocToFile(const QJsonDocument &doc, const QString &file_name)
writes a QJsonDocument to a file
Definition: ajson.cpp:71
AJson::exportDatabase
static void exportDatabase()
exportDatabase exports the currently active database to JSON.
Definition: ajson.cpp:28
AJson::importDatabase
static void importDatabase()
importDatabase imports a dataset from JSON. Files need to be at AStanardPaths::JSON for now.
Definition: ajson.cpp:42