From 0168b96b79db2627fdba77a8712956408aa081d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 4 Oct 2017 21:28:18 +0200 Subject: Add postgresql support --- src/utils/is_one_of.hpp | 17 +++++++++++++++++ src/utils/optional_bool.cpp | 8 ++++++++ src/utils/optional_bool.hpp | 4 +++- 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/utils/is_one_of.hpp create mode 100644 src/utils/optional_bool.cpp (limited to 'src/utils') diff --git a/src/utils/is_one_of.hpp b/src/utils/is_one_of.hpp new file mode 100644 index 0000000..4d6770e --- /dev/null +++ b/src/utils/is_one_of.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include + +template +struct is_one_of_implem { + static constexpr bool value = false; +}; + +template +struct is_one_of_implem { + static constexpr bool value = + std::is_same::value || is_one_of_implem::value; +}; + +template +constexpr bool is_one_of = is_one_of_implem::value; diff --git a/src/utils/optional_bool.cpp b/src/utils/optional_bool.cpp new file mode 100644 index 0000000..56fdca2 --- /dev/null +++ b/src/utils/optional_bool.cpp @@ -0,0 +1,8 @@ +#include + + +std::ostream& operator<<(std::ostream& os, const OptionalBool& o) +{ + os << o.to_string(); + return os; +} diff --git a/src/utils/optional_bool.hpp b/src/utils/optional_bool.hpp index 59bbbab..867aca2 100644 --- a/src/utils/optional_bool.hpp +++ b/src/utils/optional_bool.hpp @@ -20,7 +20,7 @@ struct OptionalBool this->is_set = false; } - std::string to_string() + std::string to_string() const { if (this->is_set == false) return "unset"; @@ -33,3 +33,5 @@ struct OptionalBool bool is_set{false}; bool value{false}; }; + +std::ostream& operator<<(std::ostream& os, const OptionalBool& o); -- cgit v1.2.3 From 7e64a2e361adcdbd2fce5ad76051a150b4de062d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 14 Jan 2018 21:46:49 +0100 Subject: Add a DEBUG_SQL_QUERIES to log info about the executed SQL queries fix #3324 --- src/utils/scopetimer.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/utils/scopetimer.hpp (limited to 'src/utils') diff --git a/src/utils/scopetimer.hpp b/src/utils/scopetimer.hpp new file mode 100644 index 0000000..7d3db9b --- /dev/null +++ b/src/utils/scopetimer.hpp @@ -0,0 +1,17 @@ +#include + +#include + +#include + +template +auto make_scope_timer(Callback cb) +{ + const auto start_time = std::chrono::steady_clock::now(); + return utils::make_scope_guard([start_time, cb = std::move(cb)]() + { + const auto now = std::chrono::steady_clock::now(); + const auto elapsed = now - start_time; + cb(elapsed); + }); +} -- cgit v1.2.3 From 33a5f1355d1250bf77184459a8d40a790e42814d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 24 Jan 2018 21:42:26 +0100 Subject: Remove a variable template usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because it’s only supported in gcc>=5.0 --- src/utils/is_one_of.hpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/utils') diff --git a/src/utils/is_one_of.hpp b/src/utils/is_one_of.hpp index 4d6770e..c706421 100644 --- a/src/utils/is_one_of.hpp +++ b/src/utils/is_one_of.hpp @@ -3,15 +3,12 @@ #include template -struct is_one_of_implem { +struct is_one_of { static constexpr bool value = false; }; template -struct is_one_of_implem { +struct is_one_of { static constexpr bool value = - std::is_same::value || is_one_of_implem::value; + std::is_same::value || is_one_of::value; }; - -template -constexpr bool is_one_of = is_one_of_implem::value; -- cgit v1.2.3 From e267512ad40c073bd5a5b37a4ee3378c80b9f523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 25 Jan 2018 02:17:20 +0100 Subject: Restore the is_one_of variable template --- src/utils/is_one_of.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/utils') diff --git a/src/utils/is_one_of.hpp b/src/utils/is_one_of.hpp index c706421..4d6770e 100644 --- a/src/utils/is_one_of.hpp +++ b/src/utils/is_one_of.hpp @@ -3,12 +3,15 @@ #include template -struct is_one_of { +struct is_one_of_implem { static constexpr bool value = false; }; template -struct is_one_of { +struct is_one_of_implem { static constexpr bool value = - std::is_same::value || is_one_of::value; + std::is_same::value || is_one_of_implem::value; }; + +template +constexpr bool is_one_of = is_one_of_implem::value; -- cgit v1.2.3 From 1ebd8a2321c454129d921dc71777f47b97b8db97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 4 Feb 2018 16:58:04 +0100 Subject: Fix conversion warnings on 32 bits --- src/utils/time.cpp | 3 ++- src/utils/time.hpp | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/utils') diff --git a/src/utils/time.cpp b/src/utils/time.cpp index bc2c18d..71306fd 100644 --- a/src/utils/time.cpp +++ b/src/utils/time.cpp @@ -9,9 +9,10 @@ namespace utils { -std::string to_string(const std::time_t& timestamp) +std::string to_string(const std::chrono::system_clock::time_point::rep& time) { constexpr std::size_t stamp_size = 21; + const std::time_t timestamp = static_cast(time); char date_buf[stamp_size]; if (std::strftime(date_buf, stamp_size, "%FT%TZ", std::gmtime(×tamp)) != stamp_size - 1) return ""; diff --git a/src/utils/time.hpp b/src/utils/time.hpp index c71cd9c..4b19634 100644 --- a/src/utils/time.hpp +++ b/src/utils/time.hpp @@ -2,9 +2,10 @@ #include #include +#include namespace utils { -std::string to_string(const std::time_t& timestamp); +std::string to_string(const std::chrono::system_clock::time_point::rep& timestamp); std::time_t parse_datetime(const std::string& stamp); -} \ No newline at end of file +} -- cgit v1.2.3