Some formatting and clang-format

sql-rework
Tomasz Golinski 2020-01-04 19:27:04 +01:00
rodzic e3087f3695
commit 958834553c
3 zmienionych plików z 14 dodań i 11 usunięć

Wyświetl plik

@ -28,7 +28,7 @@ void Cache::set_date(const std::tm* t) {
date_tm = *t;
std::mktime(&date_tm);
year = std::to_string(1900+date_tm.tm_year);
year = std::to_string(1900 + date_tm.tm_year);
std::strftime(tmp, 20, "(%m) %B", &date_tm);
mon = tmp;
day = std::to_string(date_tm.tm_mday);
@ -38,7 +38,7 @@ void Cache::set_date(const std::tm* t) {
std::strftime(tmp, 20, "%F", &date_tm);
date = tmp;
// date += std::to_string(date_tm.tm_hour) + ":" + std::to_string(date_tm.tm_min) + ":" + std::to_string(date_tm.tm_sec);
//date += std::to_string(date_tm.tm_hour) + ":" + std::to_string(date_tm.tm_min) + ":" + std::to_string(date_tm.tm_sec);
}
float cache_distance(const Cache& a, const Cache& b) {

Wyświetl plik

@ -68,7 +68,7 @@ void show_histogram(Caches* cc, std::string Cache::*ptr, std::string caption, bo
std::cout << "<dl class=\"histogram\">\n";
for (auto own : pairs) {
if (own.first.empty()) own.first = "[unknown]";
while ((n = own.first.find('&', n+1)) != std::string::npos)
while ((n = own.first.find('&', n + 1)) != std::string::npos)
own.first.replace(n, 1, "&amp;");
if (i < HIST_MAX)
@ -144,25 +144,30 @@ int main(int argc, char** argv) {
bool use_oc = 0;
bool use_ocpl_db = 0;
bool get_not_found = 0;
std::string ocpl_user;
std::string ocde_user;
std::string ocus_user;
std::string ocnl_user;
std::string ocro_user;
std::string ocuk_user;
std::string ocpl_user_profile;
std::string ocde_user_profile;
std::string ocus_user_profile;
std::string ocnl_user_profile;
std::string ocro_user_profile;
std::string ocuk_user_profile;
std::string ocpl_url = "https://opencaching.pl/okapi/";
std::string ocde_url = "https://www.opencaching.de/okapi/";
std::string ocus_url = "http://www.opencaching.us/okapi/";
std::string ocnl_url = "http://www.opencaching.nl/okapi/";
std::string ocro_url = "http://www.opencaching.ro/okapi/";
std::string ocuk_url = "https://opencache.uk/okapi/";
const std::string Database = "ocpl.sqlite";
std::string gpx_file;
#include "config_user.h"
@ -183,7 +188,7 @@ int main(int argc, char** argv) {
// std::cout << "Option \"-d\" requires a valid number as an argument\n";
// std::exit(EXIT_FAILURE);
// }
// break;
// break;
case 'g':
gpx_file = optarg;
break;
@ -376,7 +381,7 @@ int main(int argc, char** argv) {
dates[i.date]++;
if (i.type != "Moving" && i.type != "Own") {
tmp = i.date_tm;
sorted_caches.insert({std::mktime(&tmp), &i});
sorted_caches.insert({ std::mktime(&tmp), &i });
}
}
auto best_day = std::max_element(dates.begin(), dates.end(), [&](auto& a, auto& b) { return a.second < b.second; });
@ -396,10 +401,10 @@ int main(int argc, char** argv) {
int tot_dist = 0;
for (auto i = sorted_caches.begin(); i != std::prev(sorted_caches.end()); i++) {
// std::cout << "Distance between " << i->second->name << " and " << std::next(i)->second->name << " is " << cache_distance(*i->second, *std::next(i)->second) << "<br>";
//std::cout << "Distance between " << i->second->name << " and " << std::next(i)->second->name << " is " << cache_distance(*i->second, *std::next(i)->second) << "<br>";
tot_dist += cache_distance(*i->second, *std::next(i)->second);
}
std::cout << "Total distance between caches: <span class=\"value\">" << tot_dist << "</span> km (equivalent to <span class=\"value\">" << tot_dist/(2 * Pi * Earth_radius) << "x</span> trips around Earth)<br>\n";
std::cout << "Total distance between caches: <span class=\"value\">" << tot_dist << "</span> km (equivalent to <span class=\"value\">" << tot_dist / (2 * Pi * Earth_radius) << "x</span> trips around Earth)<br>\n";
std::cout << "Average distance between caches: <span class=\"value\">" << tot_dist / sorted_caches.size() << "</span> km<br>\n";
std::cout << "</div>\n";
}
@ -518,9 +523,8 @@ int main(int argc, char** argv) {
}
std::cout << "</table>\n";
std::cout << "<div class=\"basic_stats\">\n";
std::cout << "Total <span class=\"value\">" << n << "</span> combinations found out of 81 (" << std::setprecision(3) << n/0.81 << "%).\n";
std::cout << "Total <span class=\"value\">" << n << "</span> combinations found out of 81 (" << std::setprecision(3) << n / 0.81 << "%).\n";
std::cout << "</div>\n";
}
if (show_html) {

Wyświetl plik

@ -110,10 +110,9 @@ Caches Okapi::get_caches(std::vector<std::pair<std::string, std::tm>> codes) {
uint k = 0;
while (n < codes.size()) {
std::string codes_list;
codes_list.reserve(500*7);
codes_list.reserve(500 * 7);
k = 0;
// int n = (codes.size() > 500) ? 500 : cc.codes();
while (n < codes.size() && k < 500) {
codes_list += codes.at(n).first;
codes_list += '|';