-
Notifications
You must be signed in to change notification settings - Fork 3
/
weather.cpp
43 lines (37 loc) · 1.29 KB
/
weather.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
#include "../include/weather.hpp"
#include <map>
#include <cstring>
class StrCompare {
public:
bool operator()(const char *str1, const char *str2) const {
return std::strcmp(str1, str2) < 0;
}
};
weather_t weatherForecast;
std::map<const char *, Weather_t, StrCompare> translationMap = {
{"Clear", CLEAR},
{"Clouds", CLOUDS},
{"Drizzle", DRIZZLE},
{"Fog", FOG},
{"Haze", HAZE},
{"Rain", RAIN},
{"Snow", SNOW},
{"Thunderstorm", THUNDERSTORM},
};
Weather_t translate_main_to_enum(const char *data) {
return translationMap[data];
}
std::map<Weather_Error_t, const char *> errorTranslationMap = {
{OK, "Pogoda pobrana"},
{EMPTY_LOCATION, "Nie podano lokalizacji"},
{GETHOSTBYNAME, "Nie udalo sie pobrac adresu serwera"},
{CONNECT, "Nie udalo sie polaczyc z serwerem"},
{SEND, "Nie udalo sie wyslac zapytania"},
{RECV_FAIL, "Nie udalo sie odebrac danych"},
{RECV_EMPTY, "Serwer nie zwrocil wynikow"},
{DOWNLOADING, "Pobieram..."},
{NO_CITY, "Nie znaleziono miasta"}
};
const char *error_to_string(Weather_Error_t err) {
return errorTranslationMap[err];
}