From 3413d1bf23a7ba4f33d015d1ec5024c191fe08e5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 28 Dec 2016 01:12:38 +0100 Subject: [PATCH] config/Global: add std::chrono::steady_clock::duration overload --- src/config/ConfigGlobal.hxx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/config/ConfigGlobal.hxx b/src/config/ConfigGlobal.hxx index ca846be27..2b6bb7ea3 100644 --- a/src/config/ConfigGlobal.hxx +++ b/src/config/ConfigGlobal.hxx @@ -23,6 +23,8 @@ #include "ConfigOption.hxx" #include "Compiler.h" +#include + class Path; class AllocatedPath; struct ConfigParam; @@ -88,10 +90,30 @@ gcc_pure unsigned config_get_unsigned(enum ConfigOption option, unsigned default_value); +gcc_pure +static inline std::chrono::steady_clock::duration +config_get_unsigned(ConfigOption option, + std::chrono::steady_clock::duration default_value) +{ + // TODO: allow unit suffixes + auto u = config_get_unsigned(option, default_value.count()); + return std::chrono::steady_clock::duration(u); +} + gcc_pure unsigned config_get_positive(enum ConfigOption option, unsigned default_value); +gcc_pure +static inline std::chrono::steady_clock::duration +config_get_positive(ConfigOption option, + std::chrono::steady_clock::duration default_value) +{ + // TODO: allow unit suffixes + auto u = config_get_positive(option, default_value.count()); + return std::chrono::steady_clock::duration(u); +} + gcc_pure bool config_get_bool(enum ConfigOption option, bool default_value);