summaryrefslogtreecommitdiff
path: root/client/Config.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'client/Config.cpp')
-rw-r--r--client/Config.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/client/Config.cpp b/client/Config.cpp
index 472fdf4..62318df 100644
--- a/client/Config.cpp
+++ b/client/Config.cpp
@@ -1,4 +1,5 @@
+#include <algorithm>
#include <fstream>
#include "client.h"
#include "Config.h"
@@ -35,6 +36,61 @@ bool Config::IsConfigValid()
return configValid;
}
+vector<string> Config::GetCountries()
+{
+ vector<string> countries(genericProxy.size());
+ for (unsigned i = 0; i < genericProxy.size(); i++)
+ {
+ countries.push_back(genericProxy[i].country);
+ }
+ sort(countries.begin(), countries.end());
+ vector<string>::iterator end = unique(countries.begin(), countries.end());
+ countries.resize(end - countries.begin());
+ return countries;
+}
+
+vector<string> Config::GetStates(std::string &country)
+{
+ vector<string> states(genericProxy.size());
+ for (unsigned i = 0; i < genericProxy.size(); i++)
+ {
+ if ((genericProxy[i].state != "-") &&
+ (genericProxy[i].country == country))
+ {
+ states.push_back(genericProxy[i].state);
+ }
+ }
+ if (!states.empty())
+ {
+ sort(states.begin(), states.end());
+ vector<string>::iterator end = unique(states.begin(), states.end());
+ states.resize(end - states.begin());
+ }
+ return states;
+}
+
+vector<string> Config::GetCities(std::string &country)
+{
+ string defState = "-";
+ GetCities(country, defState);
+}
+
+vector<string> Config::GetCities(std::string &country, std::string &state)
+{
+ vector<string> cities(genericProxy.size());
+ for (unsigned i = 0; i < genericProxy.size(); i++)
+ {
+ if ((genericProxy[i].state == state) &&
+ (genericProxy[i].country == country))
+ {
+ cities.push_back(genericProxy[i].city);
+ }
+ }
+ sort(cities.begin(), cities.end());
+ vector<string>::iterator end = unique(cities.begin(), cities.end());
+ cities.resize(end - cities.begin());
+ return cities;
+}
int Config::ReadGenericProxy()
{