-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
49 lines (41 loc) · 975 Bytes
/
main.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
#include <iostream>
#include <fstream>
#include <string>
#include <pqxx/pqxx>
#include "MenuManager.h"
#include "AccountManager.h"
#include "User.h"
#include "Staff.h"
#include "BookSearch.h"
#include "extern.h"
using namespace std;
string connInfo;
MenuManager menuManager;
pqxx::connection* conn;
User* user = nullptr;
Staff* admin = nullptr;
void retrieveConnInfo(fstream& inputFile) {
inputFile.open("../../../../connInfo.txt");
if (inputFile.fail()) {
cout << "Error has occurred in retrieving the file." << endl;
exit(EXIT_FAILURE);
}
getline(inputFile, connInfo);
}
int setDatabaseConnection() {
try {
conn = new pqxx::connection(connInfo);
}
catch (exception const& e) {
cout << "Could not successfully connect to the database...\n";
cout << "Exception: " << e.what() << endl;
exit(EXIT_FAILURE);
}
}
int main() {
fstream inputFile;
retrieveConnInfo(inputFile);
setDatabaseConnection();
menuManager.beginMenuProcess();
return 0;
}