119 lines
5.4 KiB
C++
119 lines
5.4 KiB
C++
#ifndef FILE_MANAGER_H
|
|
#define FILE_MANAGER_H
|
|
|
|
#include <string>
|
|
|
|
#include "models/ward.h"
|
|
#include "models/patient.h"
|
|
#include "models/doctor.h"
|
|
#include "models/medicine.h"
|
|
#include "models/department.h"
|
|
#include "models/patient_case.h"
|
|
#include "models/check.h"
|
|
#include "models/payment.h"
|
|
#include "models/settlement.h"
|
|
#include "utils/linkedlist.hpp"
|
|
|
|
class FileManager {
|
|
public:
|
|
// Basic file operations
|
|
static bool readTextFile(const std::string& path, std::string& outContent, std::string& outError);
|
|
static bool writeTextFile(const std::string& path, const std::string& content, std::string& outError);
|
|
static bool createFile(const std::string& path, const std::string& initialContent, std::string& outError);
|
|
static bool deleteFile(const std::string& path, std::string& outError);
|
|
|
|
// JSON field operation: remove a field from root object or array of objects
|
|
static bool deleteJsonField(const std::string& path, const std::string& fieldName, std::string& outError);
|
|
|
|
// Ward/Bed <-> file
|
|
static bool loadWardListFromFile(const std::string& path,
|
|
LinkedList<std::string, Ward>& outList,
|
|
std::string& outError);
|
|
|
|
static bool saveWardListToFile(const std::string& path,
|
|
const LinkedList<std::string, Ward>& list,
|
|
std::string& outError,
|
|
int indent = 2);
|
|
|
|
// Patient <-> file
|
|
static bool loadPatientListFromFile(const std::string& path,
|
|
LinkedList<std::string, Patient>& outList,
|
|
std::string& outError);
|
|
|
|
static bool savePatientListToFile(const std::string& path,
|
|
const LinkedList<std::string, Patient>& list,
|
|
std::string& outError,
|
|
int indent = 2);
|
|
|
|
// Doctor <-> file
|
|
static bool loadDoctorListFromFile(const std::string& path,
|
|
LinkedList<std::string, Doctor>& outList,
|
|
std::string& outError);
|
|
|
|
static bool saveDoctorListToFile(const std::string& path,
|
|
const LinkedList<std::string, Doctor>& list,
|
|
std::string& outError,
|
|
int indent = 2);
|
|
|
|
// Medicine <-> file
|
|
static bool loadMedicineListFromFile(const std::string& path,
|
|
LinkedList<std::string, Medicine>& outList,
|
|
std::string& outError);
|
|
|
|
static bool saveMedicineListToFile(const std::string& path,
|
|
const LinkedList<std::string, Medicine>& list,
|
|
std::string& outError,
|
|
int indent = 2);
|
|
|
|
// Department <-> file
|
|
static bool loadDepartmentListFromFile(const std::string& path,
|
|
LinkedList<std::string, Department>& outList,
|
|
std::string& outError);
|
|
|
|
static bool saveDepartmentListToFile(const std::string& path,
|
|
const LinkedList<std::string, Department>& list,
|
|
std::string& outError,
|
|
int indent = 2);
|
|
|
|
// PatientCase <-> file
|
|
static bool loadPatientCaseListFromFile(const std::string& path,
|
|
LinkedList<std::string, PatientCase>& outList,
|
|
std::string& outError);
|
|
|
|
static bool savePatientCaseListToFile(const std::string& path,
|
|
const LinkedList<std::string, PatientCase>& list,
|
|
std::string& outError,
|
|
int indent = 2);
|
|
|
|
// Check <-> file
|
|
static bool loadCheckListFromFile(const std::string& path,
|
|
LinkedList<std::string, Check>& outList,
|
|
std::string& outError);
|
|
|
|
static bool saveCheckListToFile(const std::string& path,
|
|
const LinkedList<std::string, Check>& list,
|
|
std::string& outError,
|
|
int indent = 2);
|
|
|
|
// Payment <-> file
|
|
static bool loadPaymentListFromFile(const std::string& path,
|
|
LinkedList<std::string, Payment>& outList,
|
|
std::string& outError);
|
|
|
|
static bool savePaymentListToFile(const std::string& path,
|
|
const LinkedList<std::string, Payment>& list,
|
|
std::string& outError,
|
|
int indent = 2);
|
|
|
|
// Settlement <-> file
|
|
static bool loadSettlementListFromFile(const std::string& path,
|
|
LinkedList<std::string, Settlement>& outList,
|
|
std::string& outError);
|
|
|
|
static bool saveSettlementListToFile(const std::string& path,
|
|
const LinkedList<std::string, Settlement>& list,
|
|
std::string& outError,
|
|
int indent = 2);
|
|
};
|
|
|
|
#endif |