MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

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);
52
53 gcc_pure
54 const ConfigBlock *
55 config_get_block(enum ConfigBlockOption option);
56
64 gcc_pure
65 const ConfigBlock *
66 config_find_block(ConfigBlockOption option, const char *key, const char *value);
67
68 /* Note on gcc_pure: Some of the functions declared pure are not
69 really pure in strict sense. They have side effect such that they
70 validate parameter's value and signal an error if it's invalid.
71 However, if the argument was already validated or we don't care
72 about the argument at all, this may be ignored so in the end, we
73 should be fine with calling those functions pure. */
74
75 gcc_pure
76 const char *
77 config_get_string(enum ConfigOption option, const char *default_value=nullptr);
78
86 AllocatedPath
87 config_get_path(enum ConfigOption option);
88
89 gcc_pure
90 unsigned
91 config_get_unsigned(enum ConfigOption option, unsigned default_value);
92
93 gcc_pure
94 static inline std::chrono::steady_clock::duration
95 config_get_unsigned(ConfigOption option,
96 std::chrono::steady_clock::duration default_value)
97 {
98 // TODO: allow unit suffixes
99 auto u = config_get_unsigned(option, default_value.count());
100 return std::chrono::steady_clock::duration(u);
101 }
102
103 gcc_pure
104 unsigned
105 config_get_positive(enum ConfigOption option, unsigned default_value);
106
107 gcc_pure
108 static inline std::chrono::steady_clock::duration
109 config_get_positive(ConfigOption option,
110 std::chrono::steady_clock::duration default_value)
111 {
112 // TODO: allow unit suffixes
113 auto u = config_get_positive(option, default_value.count());
114 return std::chrono::steady_clock::duration(u);
115 }
116
117 gcc_pure
118 bool config_get_bool(enum ConfigOption option, bool default_value);
119
120 #endif
config_get_param
gcc_pure const ConfigParam * config_get_param(enum ConfigOption option)
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
ConfigBlockOption
ConfigBlockOption
Definition: ConfigOption.hxx:84
config_get_block
gcc_pure const ConfigBlock * config_get_block(enum ConfigBlockOption option)
ConfigBlock
Definition: Block.hxx:57
config_global_finish
void config_global_finish()
config_find_block
gcc_pure const ConfigBlock * config_find_block(ConfigBlockOption option, const char *key, const char *value)
Find a block with a matching attribute.
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_positive
gcc_pure unsigned config_get_positive(enum ConfigOption option, unsigned default_value)
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_string
gcc_pure const char * config_get_string(enum ConfigOption option, const char *default_value=nullptr)
config_get_unsigned
gcc_pure unsigned config_get_unsigned(enum ConfigOption option, unsigned default_value)
ConfigParam
Definition: Param.hxx:30
gcc_pure
#define gcc_pure
Definition: Compiler.h:116
config_get_bool
gcc_pure bool config_get_bool(enum ConfigOption option, bool default_value)