27 #include "examples/protos/route_guide.grpc.pb.h"
29 #include "route_guide.grpc.pb.h"
39 size_t start_position = argv_1.find(arg_str);
40 if (start_position != std::string::npos) {
41 start_position += arg_str.size();
42 if (argv_1[start_position] ==
' ' || argv_1[start_position] ==
'=') {
43 db_path = argv_1.substr(start_position + 1);
48 db_path =
"cpp/route_guide/route_guide_db.json";
50 db_path =
"route_guide_db.json";
53 std::ifstream db_file(db_path);
54 if (!db_file.is_open()) {
55 std::cout <<
"Failed to open " << db_path << std::endl;
59 db << db_file.rdbuf();
70 db_.erase(std::remove_if(
db_.begin(),
db_.end(), isspace),
db_.end());
87 feature->mutable_location()->set_latitude(
temp);
92 feature->mutable_location()->set_longitude(
temp);
102 feature->set_name(
db_.substr(name_start,
current_ - name_start - 1));
144 feature_list->clear();
147 std::remove_if(db_content.begin(), db_content.end(), isspace),
152 while (!
parser.Finished()) {
153 feature_list->push_back(
Feature());
154 if (!
parser.TryParseOne(&feature_list->back())) {
155 std::cout <<
"Error parsing the db file";
156 feature_list->clear();
160 std::cout <<
"DB parsed, loaded " << feature_list->size() <<
" features."