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
35 
36 void
38 
43 void
45 
46 void
47 ReadConfigFile(Path path);
48 
50 const ConfigParam *
51 config_get_param(enum ConfigOption option) noexcept;
52 
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 *
69  const char *default_value=nullptr) noexcept;
70 
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
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
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
void ReadConfigFile(Path path)
void config_global_check()
Call this function after all configuration has been evaluated.
A path name in the native file system character set.
unsigned config_get_positive(enum ConfigOption option, unsigned default_value)
ConfigBlockOption
gcc_pure const ConfigParam * config_get_param(enum ConfigOption option) noexcept
unsigned config_get_unsigned(enum ConfigOption option, unsigned default_value)
void config_global_finish()
A path name in the native file system character set.
Definition: Path.hxx:39
void config_global_init()
const char * config_get_string(enum ConfigOption option, const char *default_value=nullptr) noexcept
AllocatedPath config_get_path(enum ConfigOption option)
Returns an optional configuration variable which contains an absolute path.
ConfigOption
bool config_get_bool(enum ConfigOption option, bool default_value)
const ConfigBlock * config_find_block(ConfigBlockOption option, const char *key, const char *value)
Find a block with a matching attribute.
#define gcc_pure
Definition: Compiler.h:116
gcc_pure const ConfigBlock * config_get_block(enum ConfigBlockOption option) noexcept