-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
61 lines (53 loc) · 2.18 KB
/
Copy pathmain.cpp
File metadata and controls
61 lines (53 loc) · 2.18 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
#include "DB.h"
#include "GalaxyQueryExporter.h"
#include "GalaxyQueryLoader.h"
#include "InterpreterQuery.h"
#include <algorithm>
#include <iostream>
#include <memory>
#include <ranges>
#include <string>
auto main() -> int {
std::string const logo = R"(
$$$$$$\ $$$$$$\ $$\ $$$$$$\ $$\ $$ $$\ $$\ $$$$$$\ $$\ $$\ $$$$$$$$\ $$$$$$$\ $$\ $$\
$$ __$$\ $$ __$$\ $$ | $$ __$$\ $$ | $$ |\$$\ $$ |$$ __$$\ $$ | $$ |$$ _____|$$ __$$\\$$\ $$ |
$$ / \__|$$ / $$ |$$ | $$ / $$ |\$$\ $$ | \$$\ $$ / $$ / $$ |$$ | $$ |$$ | $$ | $$ |\$$\ $$ /
$$ |$$$$\ $$$$$$$$ |$$ | $$$$$$$$ | \$$$$ / \$$$$ / $$ | $$ |$$ | $$ |$$$$$\ $$$$$$$ | \$$$$ /
$$ |\_$$ |$$ __$$ |$$ | $$ __$$ | $$ $$< \$$ / $$ | $$ |$$ | $$ |$$ __| $$ __$$< \$$ /
$$ | $$ |$$ | $$ |$$ | $$ | $$ |$$ /\$$\ $$ | $$ $$\$$ |$$ | $$ |$$ | $$ | $$ | $$ |
\$$$$$$ |$$ | $$ |$$$$$$$$\ $$ | $$ |$$ / $$ | $$ | \$$$$$$ / \$$$$$$ |$$$$$$$$\ $$ | $$ | $$ |
\______/ \__| \__|\________|\__| \__|\__| \__| \__| \___$$$\ \______/ \________|\__| \__| \__|
\___|
)";
std::cout << logo << std::endl;
auto db = GalaxyQueryLoader::loadDb();
if (db) {
std::cout << std::format("Your database: {} has been loaded.",
db->getDbName())
<< std::endl;
}
std::string query;
std::cout << "Start typing" << std::endl;
while (std::getline(std::cin, query) && query != "END" && query != "end") {
try {
std::ranges::transform(query, query.begin(), ::toupper);
if (query == "SAVE") {
std::cout << "Saving changes to a file." << std::endl;
if (db) {
GalaxyQueryExporter::saveToFile(*db);
} else {
GalaxyQueryExporter::saveToFile(nullptr);
}
std::cout << "Start typing" << std::endl;
continue;
}
if (!query.empty()) {
InterpreterQuery::processQuery(db, query);
}
} catch (const std::exception &ex) {
std::cout << ex.what() << std::endl;
}
std::cout << "Start typing" << std::endl;
}
return 0;
}