MPD: config/ConfigGlobal.hxx Source File

MPD 0.20.15

ConfigGlobal.hxx
Go to the documentation of this file.
1 /*
2 * Copyright 2003-2017 The Music Player Daemon Project
3 * http://www.musicpd.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef MPD_CONFIG_GLOBAL_HXX
21 #define MPD_CONFIG_GLOBAL_HXX
22
23 #include "ConfigOption.hxx"
24 #include "Compiler.h"
25
26 #include <chrono>
27
28 class Path;
29 class AllocatedPath;
30 struct ConfigParam;
31 struct ConfigBlock;
32
33 void
34 config_global_init();
35
36 void
37 config_global_finish();
38
43 void
44 config_global_check();
45
46 void
47 ReadConfigFile(Path path);
48
49 gcc_pure
50 const ConfigParam *
51 config_get_param(enum ConfigOption option) noexcept;
52
53 gcc_pure
54 const ConfigBlock *
55 config_get_block(enum ConfigBlockOption option) noexcept;
56
64 const ConfigBlock *
65 config_find_block(ConfigBlockOption option, const char *key, const char *value);
66
67 const char *
68 config_get_string(enum ConfigOption option,
69 const char *default_value=nullptr) noexcept;
70
78 AllocatedPath
79 config_get_path(enum ConfigOption option);
80
81 unsigned
82 config_get_unsigned(enum ConfigOption option, unsigned default_value);
83
84 static inline std::chrono::steady_clock::duration
85 config_get_unsigned(ConfigOption option,
86 std::chrono::steady_clock::duration default_value)
87 {
88 // TODO: allow unit suffixes
89 auto u = config_get_unsigned(option, default_value.count());
90 return std::chrono::steady_clock::duration(u);
91 }
92
93 unsigned
94 config_get_positive(enum ConfigOption option, unsigned default_value);
95
96 static inline std::chrono::steady_clock::duration
97 config_get_positive(ConfigOption option,
98 std::chrono::steady_clock::duration default_value)
99 {
100 // TODO: allow unit suffixes
101 auto u = config_get_positive(option, default_value.count());
102 return std::chrono::steady_clock::duration(u);
103 }
104
105 bool config_get_bool(enum ConfigOption option, bool default_value);
106
107 #endif
ReadConfigFile
void ReadConfigFile(Path path)
ConfigOption.hxx
config_global_check
void config_global_check()
Call this function after all configuration has been evaluated.
AllocatedPath
A path name in the native file system character set.
Definition: AllocatedPath.hxx:38
config_get_positive
unsigned config_get_positive(enum ConfigOption option, unsigned default_value)
ConfigBlockOption
ConfigBlockOption
Definition: ConfigOption.hxx:84
config_get_param
gcc_pure const ConfigParam * config_get_param(enum ConfigOption option) noexcept
config_get_unsigned
unsigned config_get_unsigned(enum ConfigOption option, unsigned default_value)
ConfigBlock
Definition: Block.hxx:54
config_global_finish
void config_global_finish()
Path
A path name in the native file system character set.
Definition: Path.hxx:39
Compiler.h
config_global_init
void config_global_init()
config_get_string
const char * config_get_string(enum ConfigOption option, const char *default_value=nullptr) noexcept
config_get_path
AllocatedPath config_get_path(enum ConfigOption option)
Returns an optional configuration variable which contains an absolute path.
ConfigOption
ConfigOption
Definition: ConfigOption.hxx:31
config_get_bool
bool config_get_bool(enum ConfigOption option, bool default_value)
config_find_block
const ConfigBlock * config_find_block(ConfigBlockOption option, const char *key, const char *value)
Find a block with a matching attribute.
ConfigParam
Definition: Param.hxx:30
gcc_pure
#define gcc_pure
Definition: Compiler.h:116
config_get_block
gcc_pure const ConfigBlock * config_get_block(enum ConfigBlockOption option) noexcept