diff --git a/common.cpp b/common.cpp index c126743..4dd1bb5 100644 --- a/common.cpp +++ b/common.cpp @@ -172,11 +172,11 @@ void show_nested_histogram(const pCaches& fcc, std::string Cache::*ptr, std::str if (own.first.empty()) own.first = "[unknown]"; if (i < HIST_MAX) { std::map subhistogram; - std::vector> subpairs; for (auto el : fcc) if (el->*ptr == own.first && !(el->*ptr2).empty()) //TODO problem with [unknown] subhistogram[el->*ptr2]++; if (!subhistogram.empty()) { + std::vector> subpairs; std::cout << "
" << own.first << ": " << own.second << "\n"; std::copy(subhistogram.begin(), subhistogram.end(), std::back_inserter(subpairs)); if (sort_by_val) diff --git a/ocdb.cpp b/ocdb.cpp index 2ea0aba..32c1d95 100644 --- a/ocdb.cpp +++ b/ocdb.cpp @@ -12,7 +12,7 @@ using json = nlohmann::json; // using namespace std::literals::string_literals; OCdb::OCdb(const Service service) { - int res = 0; + int res; switch (service) { case ocpl: @@ -271,19 +271,19 @@ bool OCdb::update_log(const json& j) { return 1; sql = "INSERT INTO logs (uuid,"; - for (auto& i : fields) + for (const auto& i : fields) sql += i.first + ','; - for (auto& i : fields2) + for (const auto& i : fields2) sql += i.first + ','; sql.pop_back(); sql += ") VALUES ('" + uuid + "',"; - for (__attribute__((unused)) auto& i : fields) + for (__attribute__((unused)) const auto& i : fields) sql += "?,"; - for (__attribute__((unused)) auto& i : fields2) + for (__attribute__((unused)) const auto& i : fields2) sql += "?,"; sql.pop_back(); sql += ") ON CONFLICT(uuid) DO UPDATE SET "; - for (auto& i : fields) + for (const auto& i : fields) sql += i.first + "=excluded." + i.first + ','; sql.pop_back(); sql += ';'; @@ -295,10 +295,10 @@ bool OCdb::update_log(const json& j) { return 0; } int n = 1; - for (auto& i : fields) { + for (const auto& i : fields) { sqlite3_bind_text(stmt, n++, i.second.c_str(), -1, nullptr); } - for (auto& i : fields2) { + for (const auto& i : fields2) { sqlite3_bind_int(stmt, n++, i.second); } res = sqlite3_step(stmt); diff --git a/okapi.cpp b/okapi.cpp index e62e1ac..70ffa27 100644 --- a/okapi.cpp +++ b/okapi.cpp @@ -108,11 +108,11 @@ void Okapi::get_caches_json(const std::string& codes) const { curl_post(api_service, query); } -void Okapi::get_caches_ratings_json(const std::string& codes) const { - std::string api_service = url + OKAPI_caches; - std::string query = "consumer_key=" + key + "&cache_codes=" + codes + "&fields=code|recommendations|rating|status"; - curl_post(api_service, query); -} +// void Okapi::get_caches_ratings_json(const std::string& codes) const { +// std::string api_service = url + OKAPI_caches; +// std::string query = "consumer_key=" + key + "&cache_codes=" + codes + "&fields=code|recommendations|rating|status"; +// curl_post(api_service, query); +// } // Cache Okapi::get_cache(std::string code) { // std::string output = get_cache_json(code); @@ -355,10 +355,10 @@ std::string Okapi::get_changelog_json(int revision) const { } void Okapi::get_ftf(uint uid, Caches& cc) const { - std::string url = "https://opencaching.pl/UserProfile/getUserFtfsAjax/" + std::to_string(uid); + std::string ftf_url = "https://opencaching.pl/UserProfile/getUserFtfsAjax/" + std::to_string(uid); CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); + curl_easy_setopt(curl, CURLOPT_URL, ftf_url.c_str()); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, ""); curl_output.clear(); diff --git a/okapi.h b/okapi.h index 31b0af9..a559e71 100644 --- a/okapi.h +++ b/okapi.h @@ -23,7 +23,7 @@ private: void get_user_caches_json(const std::string& uuid, int count = 0, int offset = 0) const; // std::string get_cache_json(std::string code) const; void get_caches_json(const std::string& codes) const; - void get_caches_ratings_json(const std::string& codes) const; + // void get_caches_ratings_json(const std::string& codes) const; const static int MAX_LOGS = 1000; const static int MAX_CACHES = 500; @@ -43,7 +43,7 @@ private: constexpr static auto ocuk_url = "https://opencache.uk/okapi/"; public: - Okapi(const Service serv); + explicit Okapi(const Service serv); ~Okapi(); // Cache get_cache(std::string code); diff --git a/powertrail.h b/powertrail.h index f581d57..6596bd3 100644 --- a/powertrail.h +++ b/powertrail.h @@ -69,7 +69,7 @@ class Caches_in_Powertrails { public: std::unordered_map data; - Caches_in_Powertrails(const PowertrailDB& db); + explicit Caches_in_Powertrails(const PowertrailDB& db); Caches_in_Powertrails(){}; void read_from_json(std::string file); diff --git a/user.cpp b/user.cpp index e8c86a6..a2fe75e 100644 --- a/user.cpp +++ b/user.cpp @@ -198,7 +198,7 @@ void User::prepare_lists_of_caches() { } } -void User::header() { +void User::header() const { if (!ocpl_user.empty()) std::cout << "\"OCpl\" " << ocpl_user << "
\n"; if (!ocde_user.empty()) diff --git a/user.h b/user.h index e1fff10..8c4dbce 100644 --- a/user.h +++ b/user.h @@ -64,5 +64,5 @@ public: void get_caches(); void prepare_lists_of_caches(); // Prepare sorted list of caches, excluding moving caches - void header(); + void header() const; };