jsonhelper.h
/*
*openPilotLog - A FOSS Pilot Logbook Application
*Copyright (C) 2020-2022 Felix Turowsky
*
*This program is free software: you can redistribute it and/or modify
*it under the terms of the GNU General Public License as published by
*the Free Software Foundation, either version 3 of the License, or
*(at your option) any later version.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License
*along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef JSONHELPER_H
#define JSONHELPER_H
#include "src/opl.h"
#include <QJsonDocument>
#include <QJsonValue>
#include <QJsonObject>
class JsonHelper
{
public:
JsonHelper();
JsonHelper(QFileInfo database_file);
static void exportDatabase();
static void importDatabase();
static QJsonDocument readFileToDoc(const QString &file_path);
static void writeDocToFile(const QJsonDocument &doc, const QString& file_name);
private:
const static inline QList<OPL::DbTable> TABLES = {
OPL::DbTable::Tails,
OPL::DbTable::Pilots,
OPL::DbTable::Currencies,
OPL::DbTable::Flights,
};
};
#endif // JSONHELPER_H
JsonHelper
The JsonHelper class is responsible for parsing the database (sqlite) to and from JSON.
Definition: jsonhelper.h:29
JsonHelper::writeDocToFile
static void writeDocToFile(const QJsonDocument &doc, const QString &file_name)
writes a QJsonDocument to a file
Definition: jsonhelper.cpp:66
JsonHelper::importDatabase
static void importDatabase()
importDatabase imports a dataset from JSON. Files need to be at AStanardPaths::JSON for now.
Definition: jsonhelper.cpp:36
JsonHelper::exportDatabase
static void exportDatabase()
exportDatabase exports the currently active database to JSON.
Definition: jsonhelper.cpp:22
JsonHelper::readFileToDoc
static QJsonDocument readFileToDoc(const QString &file_path)
readToDocument reads data from a JSON file into a QJSonDocument
Definition: jsonhelper.cpp:55