Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
86c531b3
Commit
86c531b3
authored
Jul 17, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config/Data: move std::chrono parsers from Global.hxx
parent
a5b14a2e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
23 deletions
+21
-23
Main.cxx
src/Main.cxx
+4
-3
Data.hxx
src/config/Data.hxx
+17
-0
Global.hxx
src/config/Global.hxx
+0
-20
No files found.
src/Main.cxx
View file @
86c531b3
...
...
@@ -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,7 +269,7 @@ glue_state_file_init()
}
const
auto
interval
=
config
_get_u
nsigned
(
ConfigOption
::
STATE_FILE_INTERVAL
,
config
.
GetU
nsigned
(
ConfigOption
::
STATE_FILE_INTERVAL
,
StateFile
::
DEFAULT_INTERVAL
);
instance
->
state_file
=
new
StateFile
(
std
::
move
(
path_fs
),
interval
,
...
...
@@ -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
))
{
...
...
src/config/Data.hxx
View file @
86c531b3
...
...
@@ -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
...
...
src/config/Global.hxx
View file @
86c531b3
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment