/
WeatherListener.cpp
60 lines (55 loc) 路 1.37 KB
/
WeatherListener.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
56
57
58
59
#include "WeatherListener.h"
void WeatherListener::key(String key) {
if (key == "icon") {
this->in_icon = true;
} else {
this->in_icon = false;
}
if (key == "temperatureMax") {
this->in_temperatureMax = true;
} else {
this->in_temperatureMax = false;
}
if (key == "temperatureMin") {
this->in_temperatureMin = true;
} else {
this->in_temperatureMin = false;
}
if (key == "data") {
this->in_data = true;
}
if (key == "summary") {
this->in_summary = true;
} else {
this->in_summary = false;
}
}
void WeatherListener::value(String value) {
if (this->in_data && this->in_icon && !this->got_icon) {
this->icon = value;
this->got_icon = true;
}
if (this->in_temperatureMax && !this->got_temperatureMax) {
this->temperatureMax = value.toInt();
this->got_temperatureMax = true;
}
if (this->in_temperatureMin && !this->got_temperatureMin) {
this->temperatureMin = value.toInt();
this->got_temperatureMin = true;
}
if (this->in_summary) {
if (this->in_data && !this->got_summary_daily) {
this->summary_daily = value;
this->got_summary_daily = true;
}
if (!this->in_data && !this->got_summary_weekly) {
this->summary_weekly = value;
this->got_summary_weekly = true;
}
}
}
void WeatherListener::endArray() {
if (this->in_data) {
this->in_data = false;
}
}