-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstops.h
53 lines (43 loc) · 1.17 KB
/
stops.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
#ifndef STOPS_H
#define STOPS_H
#include <string>
#include <iostream>
#include <fstream>
class Stops
{
public:
Stops() {}
bool load(const std::string& tourfile) {
std::ifstream infile(tourfile);
if (!infile)
return false;
std::string poi_info;
while (std::getline(infile, poi_info))
{
if (poi_info.empty())
break;
size_t delim_pos = poi_info.find('|');
if (delim_pos == std::string::npos || poi_info.find('|', delim_pos+1) != std::string::npos)
return false;
poi_data_.push_back({poi_info.substr(0, delim_pos), poi_info.substr(delim_pos+1)});
}
return true;
}
int size() const { return poi_data_.size(); }
bool get_poi_data(int index, std::string& poi, std::string& talking_points) const
{
if (index < 0 || index >= poi_data_.size())
return false;
poi = poi_data_[index].poi;
talking_points = poi_data_[index].talking_points;
return true;
}
private:
struct POI_DATA
{
std::string poi;
std::string talking_points;
};
std::vector<POI_DATA> poi_data_;
};
#endif // __STOPS_H__