-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjson_reader.h
77 lines (63 loc) · 2.45 KB
/
json_reader.h
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#pragma once
#include <map>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include "geo.h"
#include "domain.h"
#include "json.h"
#include "json_builder.h"
#include "map_renderer.h"
//#include "request_handler.h"
#include "transport_catalogue.h"
#include "transport_router.h"
class RequestHandler;
class JsonReader {
public:
JsonReader() = default;
void FillTransportCatalogue(std::istream& input, transport_catalogue::TransportCatalogue& tc);
void ConnectMapRenderer(MapRenderer& mr);
void GetStatRequest(
std::ostream& out,
transport_catalogue::TransportCatalogue& tc,
MapRenderer& mr);
TransportRouter& GetTransportRouter();
std::unordered_map<std::string, std::string> GetSerializationSettings();
RoutingSettings GetRoutingSettings();
void SetRoutingSettings(RoutingSettings& rs);
private:
void ReadJson(std::istream& input);
json::Dict GetTransportCatalogeBusNode(
transport_catalogue::TransportCatalogue& tc,
json::Dict& request);
json::Dict GetTransportCatalogeStopNode(
transport_catalogue::TransportCatalogue& tc,
json::Dict& request);
json::Dict GetJsonMapNode(
transport_catalogue::TransportCatalogue& tc,
MapRenderer& mr,
json::Dict& request);
json::Dict GetTransportRouterNode(
//transport_catalogue::TransportCatalogue& tc,
json::Dict& request);
// secondary functions
void ParseBaseRequests(json::Array& base_requests);
domain::Bus ParseBaseRequestsOfBus(json::Dict& request);
domain::Stop ParseBaseRequestsOfStop(json::Dict& request);
void ParseStatRequests(json::Array& stat_requests);
void ParseRenderSettings(json::Dict& render_settings);
std::vector<double>& ParseRenderSettingsArray(std::vector<double>& setting, json::Array& array);
svg::Color& ParseRenderSettingsColor(svg::Color& setting, json::Node& array);
void ParseRoutingSettings(json::Dict& routing_settings);
void ParseSerializationSettings(json::Dict& serialization_settings);
private:
std::vector<domain::Bus> bus_request_;
std::vector<domain::Stop> stop_request_;
std::unordered_map<std::string, std::unordered_map<std::string, size_t>> distances_between_stops_;
std::vector<json::Dict> stat_requests_;
RenderSettings render_settings_;
RoutingSettings routing_settings_;
std::unordered_map<std::string, std::string> serialization_settings_;
TransportRouter tr_;
};