1
0
Fork 0
AutoPointsPermis/LicenceOperations.h
Teo-CD 8f768ff9e0 Basic demonstrator
Works fine but can be slow, especially because of heavy IO.
2021-10-03 19:42:28 +01:00

36 lines
1.1 KiB
C++

//
// Created by trotfunky on 02/10/2021.
//
#ifndef AUTOPOINTSPERMIS_LICENCEOPERATIONS_H
#define AUTOPOINTSPERMIS_LICENCEOPERATIONS_H
#include <functional>
#include <iostream>
#include <sqlite3.h>
#include <string>
#include "db_info.h"
// Assign values directly to prevent starting from 0 without using a dummy value
enum class offenceClass {
One = 1,
Two = 2,
Three = 3,
Four = 4,
Five = 5
};
void dbError(const std::string& errorMessage, char* dbError);
/// Adds a new licence with 12 points and no counters running.
int addNewLicence(sqlite3* db, const std::string& licenceID);
/// Apply a new offence to an existing licence.
int applyOffence(sqlite3* db, const std::string& licenceID, int lostPoints, offenceClass offenceClass);
/// Apply the countdowns, check for completion and add points back.
/// Fetched columns : idHash, Points, Countdown, OnePointCoutdown, TenYearCountdown
int countdown(void* db, int columnCount, char** rowData, char** columnNames);
/// Resets all counters and maximum points for an existing licence
int reset(sqlite3* db, const std::string& idHash);
#endif //AUTOPOINTSPERMIS_LICENCEOPERATIONS_H