config/Data: move std::chrono parsers from Global.hxx
This commit is contained in:
parent
a5b14a2ea7
commit
86c531b37d
@ -53,6 +53,7 @@
|
||||
#include "net/Init.hxx"
|
||||
#include "lib/icu/Init.hxx"
|
||||
#include "config/Global.hxx"
|
||||
#include "config/Data.hxx"
|
||||
#include "config/Param.hxx"
|
||||
#include "config/Defaults.hxx"
|
||||
#include "config/Option.hxx"
|
||||
@ -252,7 +253,7 @@ glue_sticker_init()
|
||||
}
|
||||
|
||||
static void
|
||||
glue_state_file_init()
|
||||
glue_state_file_init(const ConfigData &config)
|
||||
{
|
||||
auto path_fs = config_get_path(ConfigOption::STATE_FILE);
|
||||
if (path_fs.IsNull()) {
|
||||
@ -268,8 +269,8 @@ glue_state_file_init()
|
||||
}
|
||||
|
||||
const auto interval =
|
||||
config_get_unsigned(ConfigOption::STATE_FILE_INTERVAL,
|
||||
StateFile::DEFAULT_INTERVAL);
|
||||
config.GetUnsigned(ConfigOption::STATE_FILE_INTERVAL,
|
||||
StateFile::DEFAULT_INTERVAL);
|
||||
|
||||
instance->state_file = new StateFile(std::move(path_fs), interval,
|
||||
instance->partitions.front(),
|
||||
@ -609,7 +610,7 @@ try {
|
||||
}
|
||||
#endif
|
||||
|
||||
glue_state_file_init();
|
||||
glue_state_file_init(raw_config);
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
if (config_get_bool(ConfigOption::AUTO_UPDATE, false)) {
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "Option.hxx"
|
||||
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
|
||||
struct ConfigParam;
|
||||
struct ConfigBlock;
|
||||
@ -55,9 +56,25 @@ struct ConfigData {
|
||||
unsigned GetUnsigned(ConfigOption option,
|
||||
unsigned default_value) const;
|
||||
|
||||
std::chrono::steady_clock::duration
|
||||
GetUnsigned(ConfigOption option,
|
||||
std::chrono::steady_clock::duration default_value) const {
|
||||
// TODO: allow unit suffixes
|
||||
auto u = GetUnsigned(option, default_value.count());
|
||||
return std::chrono::steady_clock::duration(u);
|
||||
}
|
||||
|
||||
unsigned GetPositive(ConfigOption option,
|
||||
unsigned default_value) const;
|
||||
|
||||
std::chrono::steady_clock::duration
|
||||
GetPositive(ConfigOption option,
|
||||
std::chrono::steady_clock::duration default_value) const {
|
||||
// TODO: allow unit suffixes
|
||||
auto u = GetPositive(option, default_value.count());
|
||||
return std::chrono::steady_clock::duration(u);
|
||||
}
|
||||
|
||||
bool GetBool(ConfigOption option, bool default_value) const;
|
||||
|
||||
gcc_pure
|
||||
|
@ -23,8 +23,6 @@
|
||||
#include "Option.hxx"
|
||||
#include "Compiler.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
class Path;
|
||||
class AllocatedPath;
|
||||
struct ConfigData;
|
||||
@ -76,27 +74,9 @@ config_get_path(enum ConfigOption option);
|
||||
unsigned
|
||||
config_get_unsigned(enum ConfigOption option, unsigned default_value);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
unsigned
|
||||
config_get_positive(enum ConfigOption option, unsigned default_value);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
bool config_get_bool(enum ConfigOption option, bool default_value);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user