aboutsummaryrefslogtreecommitdiffstats
path: root/src/config
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-01-21 22:36:13 +0100
committerMax Kellermann <max@duempel.org>2015-01-21 23:30:00 +0100
commit1c3f5517fabc264d7b37935bd37197cdd68250ba (patch)
tree509f68fe930e79bfa4c70a1cf2146a347f8acdef /src/config
parent10972da06030d57429dc2c86c21e37fd0aca88dc (diff)
downloadmpd-1c3f5517fabc264d7b37935bd37197cdd68250ba.tar.gz
mpd-1c3f5517fabc264d7b37935bd37197cdd68250ba.tar.xz
mpd-1c3f5517fabc264d7b37935bd37197cdd68250ba.zip
config/Option: convert to strictly-typed enum
Diffstat (limited to '')
-rw-r--r--src/config/ConfigFile.cxx2
-rw-r--r--src/config/ConfigOption.hxx128
-rw-r--r--src/config/ConfigPath.cxx2
-rw-r--r--src/config/ConfigTemplates.cxx4
-rw-r--r--src/config/Data.hxx2
5 files changed, 74 insertions, 64 deletions
diff --git a/src/config/ConfigFile.cxx b/src/config/ConfigFile.cxx
index 258482db9..e3b47bae6 100644
--- a/src/config/ConfigFile.cxx
+++ b/src/config/ConfigFile.cxx
@@ -175,7 +175,7 @@ ReadConfigFile(ConfigData &config_data, FILE *fp, Error &error)
"repeatable" flag */
const ConfigOption o = ParseConfigOptionName(name);
- if (o == CONF_MAX) {
+ if (o == ConfigOption::MAX) {
error.Format(config_file_domain,
"unrecognized parameter in config file at "
"line %i: %s\n", count, name);
diff --git a/src/config/ConfigOption.hxx b/src/config/ConfigOption.hxx
index 1c177acf0..c3f4c9aad 100644
--- a/src/config/ConfigOption.hxx
+++ b/src/config/ConfigOption.hxx
@@ -22,68 +22,78 @@
#include "Compiler.h"
-enum ConfigOption {
- CONF_MUSIC_DIR,
- CONF_PLAYLIST_DIR,
- CONF_FOLLOW_INSIDE_SYMLINKS,
- CONF_FOLLOW_OUTSIDE_SYMLINKS,
- CONF_DB_FILE,
- CONF_STICKER_FILE,
- CONF_LOG_FILE,
- CONF_PID_FILE,
- CONF_STATE_FILE,
- CONF_STATE_FILE_INTERVAL,
- CONF_RESTORE_PAUSED,
- CONF_USER,
- CONF_GROUP,
- CONF_BIND_TO_ADDRESS,
- CONF_PORT,
- CONF_LOG_LEVEL,
- CONF_ZEROCONF_NAME,
- CONF_ZEROCONF_ENABLED,
- CONF_PASSWORD,
- CONF_DEFAULT_PERMS,
- CONF_AUDIO_OUTPUT,
- CONF_AUDIO_OUTPUT_FORMAT,
- CONF_MIXER_TYPE,
- CONF_REPLAYGAIN,
- CONF_REPLAYGAIN_PREAMP,
- CONF_REPLAYGAIN_MISSING_PREAMP,
- CONF_REPLAYGAIN_LIMIT,
- CONF_VOLUME_NORMALIZATION,
- CONF_SAMPLERATE_CONVERTER,
- CONF_AUDIO_BUFFER_SIZE,
- CONF_BUFFER_BEFORE_PLAY,
- CONF_HTTP_PROXY_HOST,
- CONF_HTTP_PROXY_PORT,
- CONF_HTTP_PROXY_USER,
- CONF_HTTP_PROXY_PASSWORD,
- CONF_CONN_TIMEOUT,
- CONF_MAX_CONN,
- CONF_MAX_PLAYLIST_LENGTH,
- CONF_MAX_COMMAND_LIST_SIZE,
- CONF_MAX_OUTPUT_BUFFER_SIZE,
- CONF_FS_CHARSET,
- CONF_ID3V1_ENCODING,
- CONF_METADATA_TO_USE,
- CONF_SAVE_ABSOLUTE_PATHS,
- CONF_DECODER,
- CONF_INPUT,
- CONF_GAPLESS_MP3_PLAYBACK,
- CONF_PLAYLIST_PLUGIN,
- CONF_AUTO_UPDATE,
- CONF_AUTO_UPDATE_DEPTH,
- CONF_DESPOTIFY_USER,
- CONF_DESPOTIFY_PASSWORD,
- CONF_DESPOTIFY_HIGH_BITRATE,
- CONF_AUDIO_FILTER,
- CONF_DATABASE,
- CONF_NEIGHBORS,
- CONF_MAX
+#if defined(WIN32) && CLANG_OR_GCC_VERSION(4,7)
+/* "INPUT" is declared by winuser.h */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
+#endif
+
+enum class ConfigOption {
+ MUSIC_DIR,
+ PLAYLIST_DIR,
+ FOLLOW_INSIDE_SYMLINKS,
+ FOLLOW_OUTSIDE_SYMLINKS,
+ DB_FILE,
+ STICKER_FILE,
+ LOG_FILE,
+ PID_FILE,
+ STATE_FILE,
+ STATE_FILE_INTERVAL,
+ RESTORE_PAUSED,
+ USER,
+ GROUP,
+ BIND_TO_ADDRESS,
+ PORT,
+ LOG_LEVEL,
+ ZEROCONF_NAME,
+ ZEROCONF_ENABLED,
+ PASSWORD,
+ DEFAULT_PERMS,
+ AUDIO_OUTPUT,
+ AUDIO_OUTPUT_FORMAT,
+ MIXER_TYPE,
+ REPLAYGAIN,
+ REPLAYGAIN_PREAMP,
+ REPLAYGAIN_MISSING_PREAMP,
+ REPLAYGAIN_LIMIT,
+ VOLUME_NORMALIZATION,
+ SAMPLERATE_CONVERTER,
+ AUDIO_BUFFER_SIZE,
+ BUFFER_BEFORE_PLAY,
+ HTTP_PROXY_HOST,
+ HTTP_PROXY_PORT,
+ HTTP_PROXY_USER,
+ HTTP_PROXY_PASSWORD,
+ CONN_TIMEOUT,
+ MAX_CONN,
+ MAX_PLAYLIST_LENGTH,
+ MAX_COMMAND_LIST_SIZE,
+ MAX_OUTPUT_BUFFER_SIZE,
+ FS_CHARSET,
+ ID3V1_ENCODING,
+ METADATA_TO_USE,
+ SAVE_ABSOLUTE_PATHS,
+ DECODER,
+ INPUT,
+ GAPLESS_MP3_PLAYBACK,
+ PLAYLIST_PLUGIN,
+ AUTO_UPDATE,
+ AUTO_UPDATE_DEPTH,
+ DESPOTIFY_USER,
+ DESPOTIFY_PASSWORD,
+ DESPOTIFY_HIGH_BITRATE,
+ AUDIO_FILTER,
+ DATABASE,
+ NEIGHBORS,
+ MAX
};
+#if defined(WIN32) && CLANG_OR_GCC_VERSION(4,7)
+#pragma GCC diagnostic pop
+#endif
+
/**
- * @return #CONF_MAX if not found
+ * @return #ConfigOption::MAX if not found
*/
gcc_pure
enum ConfigOption
diff --git a/src/config/ConfigPath.cxx b/src/config/ConfigPath.cxx
index c10b3a1d5..fe42fdf60 100644
--- a/src/config/ConfigPath.cxx
+++ b/src/config/ConfigPath.cxx
@@ -70,7 +70,7 @@ GetHome(Error &error)
static AllocatedPath
GetConfiguredHome(Error &error)
{
- const char *user = config_get_string(CONF_USER, nullptr);
+ const char *user = config_get_string(ConfigOption::USER, nullptr);
return user != nullptr
? GetHome(user, error)
: GetHome(error);
diff --git a/src/config/ConfigTemplates.cxx b/src/config/ConfigTemplates.cxx
index 1949a5ff1..8f01d4104 100644
--- a/src/config/ConfigTemplates.cxx
+++ b/src/config/ConfigTemplates.cxx
@@ -84,7 +84,7 @@ const ConfigTemplate config_templates[] = {
static constexpr unsigned n_config_templates = ARRAY_SIZE(config_templates);
-static_assert(n_config_templates == unsigned(CONF_MAX),
+static_assert(n_config_templates == unsigned(ConfigOption::MAX),
"Wrong number of config_templates");
ConfigOption
@@ -94,5 +94,5 @@ ParseConfigOptionName(const char *name)
if (strcmp(config_templates[i].name, name) == 0)
return ConfigOption(i);
- return CONF_MAX;
+ return ConfigOption::MAX;
}
diff --git a/src/config/Data.hxx b/src/config/Data.hxx
index af1da956f..56e7d2553 100644
--- a/src/config/Data.hxx
+++ b/src/config/Data.hxx
@@ -27,7 +27,7 @@
struct config_param;
struct ConfigData {
- std::array<config_param *, std::size_t(CONF_MAX)> params;
+ std::array<config_param *, std::size_t(ConfigOption::MAX)> params;
void Clear();
};