-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
55 lines (48 loc) · 1.45 KB
/
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
50
51
52
53
54
55
#include <cstdio>
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include "json_reader.h"
#include "map_renderer.h"
//#include "request_handler.h"
#include "serialization.h"
#include "transport_catalogue.h"
using namespace std;
using namespace std::literals;
void PrintUsage(std::ostream& stream = std::cerr) {
stream << "Usage: transport_catalogue [make_base|process_requests]\n"sv;
}
int main(int argc, char* argv[]) {
if (argc != 2) {
PrintUsage();
return 1;
}
const std::string_view mode(argv[1]);
if (mode == "make_base"sv)
{
transport_catalogue::TransportCatalogue tc;
JsonReader jr;
MapRenderer mr;
jr.FillTransportCatalogue(std::cin, tc);
jr.ConnectMapRenderer(mr);
serializer::Path file_path = std::filesystem::path(jr.GetSerializationSettings().at("file"));
serializer::Serialize(tc, mr, jr.GetTransportRouter(), file_path);
}
else if (mode == "process_requests"sv)
{
transport_catalogue::TransportCatalogue tc;
JsonReader jr;
MapRenderer mr;
jr.FillTransportCatalogue(std::cin, tc);
serializer::Path file_path = std::filesystem::path(jr.GetSerializationSettings().at("file"));
serializer::Deserialize(file_path, tc, mr, jr.GetTransportRouter());
jr.GetStatRequest(std::cout, tc, mr);
}
else
{
PrintUsage();
return 1;
}
}