From 48e43613d1d4e72a03e89252279eb67be8a7bf17 Mon Sep 17 00:00:00 2001 From: Tomasz Golinski Date: Mon, 25 Sep 2023 18:49:30 +0200 Subject: [PATCH] clang-format --- common.h | 12 ++++++++---- debug.cpp | 6 +++--- geofriends.cpp | 9 ++++----- geolist.cpp | 2 -- geostat.cpp | 25 ++++++++++++------------- geostat_cli.cpp | 20 ++++++++++---------- okapi.cpp | 12 ++++++------ okapi.h | 2 +- traildb.cpp | 2 +- user.cpp | 15 +++++++-------- user.h | 2 +- 11 files changed, 53 insertions(+), 54 deletions(-) diff --git a/common.h b/common.h index cf6e3f5..e734e98 100644 --- a/common.h +++ b/common.h @@ -45,11 +45,15 @@ uint find_streak(const Date_Caches& cc, std::time_t& start); uint get_num(char c, char* opt); -template void average_html(const Caches& cc, T Cache::*ptr, const std::string& caption); -template float average(const Caches& cc, T Cache::*ptr); +template +void average_html(const Caches& cc, T Cache::*ptr, const std::string& caption); +template +float average(const Caches& cc, T Cache::*ptr); -template void sum_html(const Caches& cc, T Cache::*ptr, const std::string& caption); -template T sum(const Caches& cc, T Cache::*ptr); +template +void sum_html(const Caches& cc, T Cache::*ptr, const std::string& caption); +template +T sum(const Caches& cc, T Cache::*ptr); int count_caches(const Caches& cc, std::string& codes, std::function test); diff --git a/debug.cpp b/debug.cpp index 2cb5b74..aef591b 100644 --- a/debug.cpp +++ b/debug.cpp @@ -12,9 +12,9 @@ Debug::Debug(int n) : lvl(n) { if (lvl > 1) indent.append("*** "); buffer << indent; -// std::time_t now = std::time(nullptr); -// std::string dt = std::ctime(&now); -// std::cout << dt << " "; + // std::time_t now = std::time(nullptr); + // std::string dt = std::ctime(&now); + // std::cout << dt << " "; } } diff --git a/geofriends.cpp b/geofriends.cpp index 418fd74..157bfa0 100644 --- a/geofriends.cpp +++ b/geofriends.cpp @@ -12,7 +12,6 @@ void show_usage() { } int main(int argc, char** argv) { - if (argc < 3) show_usage(); User user1, user2; @@ -22,7 +21,7 @@ int main(int argc, char** argv) { user2.use_oc = true; user1.get_caches(); user2.get_caches(); - + int cc_no1 = user1.caches_hidden; int cc_no2 = user2.caches_hidden; @@ -56,7 +55,7 @@ int main(int argc, char** argv) { std::cout << "\n"; -// const int LIST_MAX = 100; + // const int LIST_MAX = 100; short int n = 1; if (cc_no1 > 0) { @@ -82,7 +81,7 @@ int main(int argc, char** argv) { std::cout << "" << i->region << ""; std::cout << "\n"; n++; - // if (n > LIST_MAX) break; + // if (n > LIST_MAX) break; } std::cout << "\n"; } @@ -111,7 +110,7 @@ int main(int argc, char** argv) { std::cout << "" << i->region << ""; std::cout << "\n"; n++; - // if (n > LIST_MAX) break; + // if (n > LIST_MAX) break; } } std::cout << "\n"; diff --git a/geolist.cpp b/geolist.cpp index 3dfb7d2..516ae61 100644 --- a/geolist.cpp +++ b/geolist.cpp @@ -13,7 +13,6 @@ void show_usage() { } int main(int argc, char** argv) { - #include "config_user.h" if (argc == 1) show_usage(); @@ -104,4 +103,3 @@ int main(int argc, char** argv) { footer_html(); } - diff --git a/geostat.cpp b/geostat.cpp index 7917666..21e98c6 100644 --- a/geostat.cpp +++ b/geostat.cpp @@ -49,7 +49,6 @@ int main(int argc, char** argv) { if (argc == 1) show_usage(); - int o; while ((o = getopt(argc, argv, "qNOQD:o::p:d:u:n:r:k:i:f:H:s:m:etah?")) != -1) switch (o) { @@ -303,8 +302,8 @@ int main(int argc, char** argv) { show_histogram(user.cc, &Cache::owner, "Cache owners", 1); show_histogram(user.cc, &Cache::type, "Cache types", 1); show_histogram(user.cc, &Cache::size, "Cache sizes", 1); - // show_histogram(fcc, &Cache::region, "Regions", 1); - // show_histogram(fcc, &Cache::subregion, "Subregions", 1); +// show_histogram(fcc, &Cache::region, "Regions", 1); +// show_histogram(fcc, &Cache::subregion, "Subregions", 1); show_histogram(user.fcc, &Cache::country, "Countries", 1); show_nested_histogram(user.fcc, &Cache::region, &Cache::subregion, "Regions", 1); show_histogram(user.cc, &Cache::day_of_week, "Days of the week", 1, 0); @@ -527,7 +526,7 @@ int main(int argc, char** argv) { } std::cout << "\n"; - // D/T matrix +// D/T matrix n = 0; std::cout << "

Difficulty / terrain matrix

\n"; @@ -559,7 +558,7 @@ int main(int argc, char** argv) { std::cout << "Average terrain: " << average(user.cc, &Cache::terr) << "
\n"; std::cout << "\n"; - // Days matrix +// Days matrix n = 0; std::cout << "

Caching days matrix

\n"; @@ -609,7 +608,7 @@ int main(int argc, char** argv) { std::cout << "Total " << n << " days out of 366 (" << std::setprecision(3) << n / 3.66 << "%).\n"; std::cout << "\n"; - // Hidden months matrix +// Hidden months matrix n = 0; y_min = std::min_element(user.cc.begin(), user.cc.end(), [&](const Cache& a, const Cache& b) { return a.date_hidden_tm.tm_year < b.date_hidden_tm.tm_year; })->date_hidden_tm.tm_year; @@ -697,20 +696,20 @@ int main(int argc, char** argv) { std::cout << ""; std::cout << i->completed_perc << "% / " << i->treshold_perc << "%"; std::cout << ""; - if (!i->completed) - std::cout << i->needed; + if (!i->completed) + std::cout << i->needed; std::cout << ""; std::cout << ""; - if (i->active_caches_not_found && i->active_caches_not_found < UINT_MAX-1024) - std::cout << i->active_caches_not_found; + if (i->active_caches_not_found && i->active_caches_not_found < UINT_MAX - 1024) + std::cout << i->active_caches_not_found; std::cout << ""; std::cout << "\n"; n++; -// if (n > LIST_MAX) break; + // if (n > LIST_MAX) break; } std::cout << "\n"; -// show_histogram(tt, "Power trails (completion percentage)", 1); + // show_histogram(tt, "Power trails (completion percentage)", 1); std::cout << "
\n"; std::cout << "Number of completed power trails: " << std::count_if(user.tt.begin(), user.tt.end(), [&](const auto& a) { return a->completed; }) << "
\n"; std::cout << "Number of started power trails: " << user.tt.size() << "
\n"; @@ -737,7 +736,7 @@ int main(int argc, char** argv) { std::cout << "" << i->founds << ""; std::cout << "\n"; n++; -// if (n > LIST_MAX) break; + // if (n > LIST_MAX) break; } std::cout << "\n"; std::cout << "
\n"; diff --git a/geostat_cli.cpp b/geostat_cli.cpp index 3de6420..8ba92a1 100644 --- a/geostat_cli.cpp +++ b/geostat_cli.cpp @@ -65,12 +65,12 @@ int main(int argc, char** argv) { int o; while ((o = getopt(argc, argv, "qNOg:o::p:d:u:n:r:k:MDCH:s:m:etaLTYh?")) != -1) switch (o) { -// case 'd': -// Debug::set_debug_level(get_num('d',optarg)); -// break; -// case 'g': -// gpx_file = optarg; - break; +// case 'd': +// Debug::set_debug_level(get_num('d',optarg)); +// break; +// case 'g': +// gpx_file = optarg; + break; case 'o': user.use_oc = 1; if (optarg) { @@ -112,9 +112,9 @@ int main(int argc, char** argv) { case 'M': show_minmax = 1; break; - // case 'D': - // show_dist = 1; - // break; +// case 'D': +// show_dist = 1; +// break; case 'C': show_calendar = 1; break; @@ -224,7 +224,7 @@ int main(int argc, char** argv) { // if (show_dist) { // auto far = *std::max_element(user.fcc.begin(), user.fcc.end(), [&](const Cache* a, const Cache* b) { return a->distance() < b->distance(); }); // auto near = *std::min_element(user.fcc.begin(), user.fcc.end(), [&](const Cache* a, const Cache* b) { return a->distance() < b->distance(); }); - // + // // std::cout << "Nearest cache: " << near->distance() << " km\n"; // near->show(); // std::cout << "Furthest cache: " << far->distance() << " km\n"; diff --git a/okapi.cpp b/okapi.cpp index 48daab7..61de9a4 100644 --- a/okapi.cpp +++ b/okapi.cpp @@ -289,15 +289,15 @@ void Okapi::update_caches(Caches& cc) const { // void Okapi::update_caches_ratings(Caches& cc) const { // std::map pcc; // std::string code; -// +// // uint k; // std::string codes_list; // codes_list.reserve(MAX_CACHES * 8); // maximum of MAX_CACHES codes, 7 chars per code plus a separator -// +// // auto it = cc.begin(); // while (it != cc.end()) { // k = 0; -// +// // while (it != cc.end() && k < MAX_CACHES) { // codes_list += it->code; // codes_list += '|'; @@ -306,16 +306,16 @@ void Okapi::update_caches(Caches& cc) const { // k++; // } // codes_list.pop_back(); // remove trailing '|' -// +// // get_caches_ratings_json(codes_list); // json j = json::parse(curl_output); // codes_list.clear(); -// +// // for (auto& el : j.items()) { // code = el.value()["code"]; // pcc[code]->fav = el.value()["recommendations"]; // if (!el.value()["rating"].is_null()) pcc[code]->rating = el.value()["rating"]; -// +// // if (el.value()["status"] == "Available") // pcc[code]->status = ok; // else if (el.value()["status"] == "Temporarily unavailable") diff --git a/okapi.h b/okapi.h index a559e71..9e42d70 100644 --- a/okapi.h +++ b/okapi.h @@ -53,7 +53,7 @@ public: std::string get_changelog_json(int revision) const; void update_caches(Caches& cc) const; -// void update_caches_ratings(Caches& cc) const; + // void update_caches_ratings(Caches& cc) const; std::string get_uuid(const std::string& username, uint* id = nullptr) const; std::string get_profile_url(const std::string& uuid) const; void get_ftf(uint uid, Caches& cc) const; diff --git a/traildb.cpp b/traildb.cpp index 424d465..42befa7 100644 --- a/traildb.cpp +++ b/traildb.cpp @@ -12,7 +12,7 @@ using json = nlohmann::json; // } int main() { -// Debug::set_debug_level(5); + // Debug::set_debug_level(5); PowertrailDB T; for (int i = 1; i < 2000; i++) diff --git a/user.cpp b/user.cpp index b9f43b1..c558997 100644 --- a/user.cpp +++ b/user.cpp @@ -5,7 +5,6 @@ #include "debug.h" void User::get_caches() { - if (use_oc) { if (!ocpl_user_uuid.empty() || !ocpl_user.empty()) { Okapi OCpl(ocpl); @@ -29,7 +28,7 @@ void User::get_caches() { } for (const auto& i : tt_map) { i.second->completed_perc = (100 * i.second->found / i.second->caches.size()); - if (i.second->found >= i.second->treshold ) + if (i.second->found >= i.second->treshold) i.second->completed = 1; else i.second->needed = i.second->treshold - i.second->found; @@ -80,11 +79,11 @@ void User::get_caches() { } } -// if (!gpx_file.empty()) { -// GPX gpxfile(gpx_file); -// Caches tmp = gpxfile.get_user_caches(); -// std::copy(tmp.begin(), tmp.end(), std::back_inserter(cc)); -// } + // if (!gpx_file.empty()) { + // GPX gpxfile(gpx_file); + // Caches tmp = gpxfile.get_user_caches(); + // std::copy(tmp.begin(), tmp.end(), std::back_inserter(cc)); + // } if (use_ocdb) { if (!ocpl_user_uuid.empty() || !ocpl_user.empty()) { @@ -122,7 +121,7 @@ void User::get_caches() { Okapi OCde(ocde); OCde.update_caches(tmp); std::copy(tmp.begin(), tmp.end(), std::back_inserter(cc)); -// region_count = db.get_region_stats(); + // region_count = db.get_region_stats(); } else if (get_owned) { Caches tmp = db.get_user_caches_owned(ocde_user_uuid); Okapi OCde(ocde); diff --git a/user.h b/user.h index 8c4dbce..92e8cec 100644 --- a/user.h +++ b/user.h @@ -36,7 +36,7 @@ public: std::string ocnl_user; std::string ocro_user; std::string ocuk_user; -// std::string gpx_file; + // std::string gpx_file; bool get_not_found = 0; bool get_owned = 0;