use ints for the subaccounts and account ids

This commit is contained in:
DarthArgus
2016-12-31 23:59:15 +00:00
parent ddc83f77a0
commit bb842aa187
4 changed files with 2652 additions and 824 deletions
+2604 -770
View File
File diff suppressed because it is too large Load Diff
+16 -6
View File
@@ -1,5 +1,5 @@
/*
* Version: 1.5
* Version: 1.6
*
* This code is just a simple wrapper around nlohmann's wonderful json lib
* (https://github.com/nlohmann/json) and libcurl. While originally included directly,
@@ -55,13 +55,23 @@ std::string webAPI::getString(const std::string &slot) {
return std::string("");
}
std::vector<std::string> webAPI::getStringVector(const std::string &slot) {
std::unordered_map<int, std::string> webAPI::getStringMap(const std::string &slot) {
std::unordered_map<int, std::string> ret = std::unordered_map<int, std::string>();
if (!this->responseData.empty() && !slot.empty() && responseData.count(slot) &&
!this->responseData[slot].is_null()) {
return this->responseData[slot].get<std::vector<std::string>>();
}
nlohmann::json j = this->responseData[slot];
return std::vector<std::string>();
for (nlohmann::json::iterator it = j.begin(); it != j.end(); ++it) {
int k = std::stoi(it.key());
std::string val = it.value();
ret.insert({k, val});
}
}
return ret;
}
bool webAPI::submit(const int &reqType, const int &getPost, const int &respType) {
@@ -184,4 +194,4 @@ bool webAPI::processJSON() {
}
return false;
}
}
+3 -2
View File
@@ -1,5 +1,5 @@
/*
* Version: 1.5
* Version: 1.6
*
* This code is just a simple wrapper around nlohmann's wonderful json lib
* (https://github.com/nlohmann/json) and libcurl. While originally included directly,
@@ -24,6 +24,7 @@
#include <curl.h>
#else
#include <unordered_map>
#include <curl/curl.h>
#endif
@@ -63,7 +64,7 @@ namespace StellaBellum {
std::string getString(const std::string &slot);
// get a vector of strings from a given slot
std::vector<std::string> getStringVector(const std::string &slot);
std::unordered_map<int, std::string> getStringMap(const std::string &slot);
// set json key and value for request
template<typename T>