-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTerritory.cpp
51 lines (43 loc) · 1.59 KB
/
Territory.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
#include <iostream>
#include <fstream>
#include "../include/route4me.h"
#define KEY "11111111111111111111111111111111"
using namespace std;
int main()
{
// global init
CRoute4Me::init();
ifstream inf("territory.json");
if(!inf.is_open()) {
cout << "Cannot find a file with territory" << endl;
return -1;
}
Json::Value territory_data;
inf >> territory_data;
CRoute4Me route(KEY);
if (route.add_territory(territory_data) == 0) {
cout << "Added territory:" << endl << Json::FastWriter().write(route.get_json_resp()) << endl;
}
else {
cout << "Failed adding territory: " << Json::FastWriter().write(route.get_json_resp()) << endl;
}
if (route.get_territory("DCBBBF90D8E9399B99C4D6FF11ED999F") == 0) {
cout << "Found territories:" << endl << Json::FastWriter().write(route.get_json_resp()) << endl;
}
else {
cout << "No territories found: " << Json::FastWriter().write(route.get_json_resp()) << endl;
}
if (route.remove_territory("DCBBBF90D8E9399B99C4D6FF11ED999F") == 0) {
cout << "Remove territory:" << endl << Json::FastWriter().write(route.get_json_resp()) << endl;
}
else {
cout << "Failed to remove territory: " << Json::FastWriter().write(route.get_json_resp()) << endl;
}
if (route.get_all_territories() == 0) {
cout << "Found territories:" << endl << Json::FastWriter().write(route.get_json_resp()) << endl;
}
else {
cout << "No territories found: " << Json::FastWriter().write(route.get_json_resp()) << endl;
}
CRoute4Me::cleanup();
}