config/Global: add std::chrono::steady_clock::duration overload

This commit is contained in:
Max Kellermann 2016-12-28 01:12:38 +01:00
parent 018c5ef731
commit 3413d1bf23
1 changed files with 22 additions and 0 deletions

View File

@ -23,6 +23,8 @@
#include "ConfigOption.hxx" #include "ConfigOption.hxx"
#include "Compiler.h" #include "Compiler.h"
#include <chrono>
class Path; class Path;
class AllocatedPath; class AllocatedPath;
struct ConfigParam; struct ConfigParam;
@ -88,10 +90,30 @@ gcc_pure
unsigned unsigned
config_get_unsigned(enum ConfigOption option, unsigned default_value); 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 gcc_pure
unsigned unsigned
config_get_positive(enum ConfigOption option, unsigned default_value); 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 gcc_pure
bool config_get_bool(enum ConfigOption option, bool default_value); bool config_get_bool(enum ConfigOption option, bool default_value);