#include <settings.h>
Public Member Functions | |
| Settings (std::string_view end_tag="") | |
| Settings (std::string_view end_tag, SettingsHierarchy *h, int settings_layer) | |
| ~Settings () | |
| Settings & | operator= (const Settings &other) |
| bool | readConfigFile (const char *filename) |
| bool | updateConfigFile (const char *filename) |
| bool | parseCommandLine (int argc, char *argv[], const std::map< std::string, ValueSpec > &allowed_options) |
| bool | parseConfigLines (std::istream &is) |
| void | writeLines (std::ostream &os, u32 tab_depth=0) const |
| Settings * | getGroup (const std::string &name) const |
| const std::string & | get (const std::string &name) const |
| bool | getBool (const std::string &name) const |
| u16 | getU16 (const std::string &name) const |
| s16 | getS16 (const std::string &name) const |
| u32 | getU32 (const std::string &name) const |
| s32 | getS32 (const std::string &name) const |
| u64 | getU64 (const std::string &name) const |
| float | getFloat (const std::string &name) const |
| float | getFloat (const std::string &name, float min, float max) const |
| v2f | getV2F (const std::string &name) const |
| std::optional< v3f > | getV3F (const std::string &name) const |
| u32 | getFlagStr (const std::string &name, const FlagDesc *flagdesc, u32 *flagmask) const |
| bool | getNoiseParams (const std::string &name, NoiseParams &np) const |
| bool | getNoiseParamsFromValue (const std::string &name, NoiseParams &np) const |
| bool | getNoiseParamsFromGroup (const std::string &name, NoiseParams &np) const |
| std::vector< std::string > | getNames () const |
| bool | exists (const std::string &name) const |
| bool | existsLocal (const std::string &name) const |
| bool | getGroupNoEx (const std::string &name, Settings *&val) const |
| bool | getNoEx (const std::string &name, std::string &val) const |
| bool | getFlag (const std::string &name) const |
| bool | getU16NoEx (const std::string &name, u16 &val) const |
| bool | getS16NoEx (const std::string &name, s16 &val) const |
| bool | getU32NoEx (const std::string &name, u32 &val) const |
| bool | getS32NoEx (const std::string &name, s32 &val) const |
| bool | getU64NoEx (const std::string &name, u64 &val) const |
| bool | getFloatNoEx (const std::string &name, float &val) const |
| bool | getV2FNoEx (const std::string &name, v2f &val) const |
| bool | getV3FNoEx (const std::string &name, std::optional< v3f > &val) const |
| bool | getFlagStrNoEx (const std::string &name, u32 &val, const FlagDesc *flagdesc) const |
| bool | setEntry (const std::string &name, const void *entry, bool set_group) |
| bool | set (const std::string &name, const std::string &value) |
| bool | setDefault (const std::string &name, const std::string &value) |
| bool | setGroup (const std::string &name, const Settings &group) |
| bool | setBool (const std::string &name, bool value) |
| bool | setS16 (const std::string &name, s16 value) |
| bool | setU16 (const std::string &name, u16 value) |
| bool | setS32 (const std::string &name, s32 value) |
| bool | setU64 (const std::string &name, u64 value) |
| bool | setFloat (const std::string &name, float value) |
| bool | setV2F (const std::string &name, v2f value) |
| bool | setV3F (const std::string &name, v3f value) |
| bool | setFlagStr (const std::string &name, u32 flags, const FlagDesc *flagdesc=nullptr, u32 flagmask=U32_MAX) |
| bool | setNoiseParams (const std::string &name, const NoiseParams &np) |
| bool | remove (const std::string &name) |
| void | setDefault (const std::string &name, const FlagDesc *flagdesc, u32 flags) |
| const FlagDesc * | getFlagDescFallback (const std::string &name) const |
| void | registerChangedCallback (const std::string &name, SettingsChangedCallback cbf, void *userdata=NULL) |
| size_t | deregisterAllChangedCallbacks (const void *userdata) |
| void | removeSecureSettings () |
| int | getLayer () const |
Static Public Member Functions | |
| static Settings * | createLayer (SettingsLayer sl, std::string_view end_tag="") |
| static Settings * | getLayer (SettingsLayer sl) |
Private Member Functions | |
| SettingsParseEvent | parseConfigObject (const std::string &line, std::string &name, std::string &value) |
| bool | updateConfigObject (std::istream &is, std::ostream &os, u32 tab_depth=0) |
| Settings * | getParent () const |
| const SettingsEntry & | getEntry (const std::string &name) const |
| void | clearNoLock () |
| void | doCallbacks (const std::string &name) const |
Static Private Member Functions | |
| static bool | checkNameValid (std::string_view name) |
| static bool | checkValueValid (std::string_view value) |
| static std::string | getMultiline (std::istream &is, size_t *num_lines=NULL) |
| static void | printEntry (std::ostream &os, const std::string &name, const SettingsEntry &entry, u32 tab_depth=0) |
Private Attributes | |
| SettingEntries | m_settings |
| SettingsCallbackMap | m_callbacks |
| std::string | m_end_tag |
| std::mutex | m_callback_mutex |
| std::mutex | m_mutex |
| SettingsHierarchy * | m_hierarchy = nullptr |
| int | m_settingslayer = -1 |
Static Private Attributes | |
| static std::unordered_map< std::string, const FlagDesc * > | s_flags |
Friends | |
| class | TestSettings |
| class | LuaSettings |
|
inline |
References m_end_tag.
Referenced by createLayer(), getGroup(), getGroupNoEx(), getLayer(), getNoiseParamsFromGroup(), getParent(), operator=(), parseConfigLines(), setEntry(), setGroup(), setNoiseParams(), and updateConfigObject().
| Settings::Settings | ( | std::string_view | end_tag, |
| SettingsHierarchy * | h, | ||
| int | settings_layer ) |
References m_end_tag, m_hierarchy, and m_settingslayer.
| Settings::~Settings | ( | ) |
References clearNoLock(), m_hierarchy, m_mutex, and m_settingslayer.
|
staticprivate |
|
staticprivate |
|
private |
References m_settings.
Referenced by ~Settings(), and operator=().
|
static |
References Settings(), and g_hierarchy.
Referenced by Server::init(), init_common(), loadGameConfAndInitWorld(), TestMapSettingsManager::makeUserConfig(), set_default_settings(), TestSettings::testDefaults(), and TestSettings::testFlagDesc().
| size_t Settings::deregisterAllChangedCallbacks | ( | const void * | userdata | ) |
References m_callback_mutex, m_callbacks, and settings.
|
private |
References m_callback_mutex, and m_callbacks.
Referenced by remove(), and set().
| bool Settings::exists | ( | const std::string & | name | ) | const |
References existsLocal(), and getParent().
Referenced by Database_Redis::Database_Redis(), ServerMap::ServerMap(), PlayerDatabaseFiles::deSerialize(), game_configure_port(), get_game_from_cmdline(), get_world_from_cmdline(), getSubgameSpec(), getWorldGameId(), getWorldName(), ServerEnvironment::init(), ClientLauncher::init_args(), init_log_streams(), LuaSettings::l_get(), LuaSettings::l_get_bool(), LuaSettings::l_get_np_group(), ClientLauncher::launch_game(), loadGameConfAndInitWorld(), ServerEnvironment::loadMeta(), main(), migrate_map_database(), ServerEnvironment::migrateAuthDatabase(), Server::migrateModStorageDatabase(), ServerEnvironment::migratePlayersDatabase(), Server::openModStorageDatabase(), parseContentInfo(), parseModContents(), read_config_file(), and run_dedicated_server().
| bool Settings::existsLocal | ( | const std::string & | name | ) | const |
References m_mutex, and m_settings.
Referenced by exists(), and LuaSettings::l_has().
| const std::string & Settings::get | ( | const std::string & | name | ) | const |
References getEntry(), SettingsEntry::is_group, and SettingsEntry::value.
Referenced by Database_Redis::Database_Redis(), ServerMap::ServerMap(), ModConfiguration::addModsFromConfig(), compare_settings(), PlayerDatabaseFiles::deSerialize(), get_game_from_cmdline(), get_world_from_cmdline(), getBool(), getFlagStr(), getFloat(), getFloat(), getNoEx(), getS16(), getS32(), getSubgameSpec(), getU16(), getU32(), getU64(), getV2F(), getV3F(), getWorldGameId(), getWorldName(), ClientLauncher::init_args(), init_log_streams(), LuaSettings::l_get(), ClientLauncher::launch_game(), ServerEnvironment::loadMeta(), main(), migrate_map_database(), ServerEnvironment::migrateAuthDatabase(), Server::migrateModStorageDatabase(), ServerEnvironment::migratePlayersDatabase(), Server::openModStorageDatabase(), parseContentInfo(), parseModContents(), read_config_file(), recompress_map_database(), TestSettings::testAllSettings(), and TestSettings::testDefaults().
| bool Settings::getBool | ( | const std::string & | name | ) | const |
References get(), and is_yes().
Referenced by PlayerDatabaseFiles::deSerialize(), getFlag(), LuaSettings::l_get_bool(), and loadGameConfAndInitWorld().
|
private |
References getParent(), m_mutex, and m_settings.
Referenced by get(), getGroup(), and TestSettings::testAllSettings().
| bool Settings::getFlag | ( | const std::string & | name | ) | const |
References getBool().
Referenced by ClientLauncher::init_args(), main(), run_dedicated_server(), and setup_log_params().
| const FlagDesc * Settings::getFlagDescFallback | ( | const std::string & | name | ) | const |
References s_flags.
Referenced by getFlagStrNoEx(), LuaSettings::l_get_flags(), and setFlagStr().
| u32 Settings::getFlagStr | ( | const std::string & | name, |
| const FlagDesc * | flagdesc, | ||
| u32 * | flagmask ) const |
References get(), getParent(), m_settings, readFlagString(), stoi, and U32_MAX.
Referenced by getFlagStrNoEx(), and TestSettings::testFlagDesc().
| bool Settings::getFlagStrNoEx | ( | const std::string & | name, |
| u32 & | val, | ||
| const FlagDesc * | flagdesc ) const |
References getFlagDescFallback(), and getFlagStr().
Referenced by getNoiseParamsFromGroup(), and LuaSettings::l_get_flags().
| float Settings::getFloat | ( | const std::string & | name | ) | const |
Referenced by PlayerDatabaseFiles::deSerialize(), getFloatNoEx(), and TestSettings::testAllSettings().
| float Settings::getFloat | ( | const std::string & | name, |
| float | min, | ||
| float | max ) const |
| bool Settings::getFloatNoEx | ( | const std::string & | name, |
| float & | val ) const |
References getFloat().
Referenced by getNoiseParamsFromGroup().
| Settings * Settings::getGroup | ( | const std::string & | name | ) | const |
References Settings(), getEntry(), SettingsEntry::group, and SettingsEntry::is_group.
Referenced by getGroupNoEx(), and TestSettings::testAllSettings().
| bool Settings::getGroupNoEx | ( | const std::string & | name, |
| Settings *& | val ) const |
References Settings(), and getGroup().
Referenced by compare_settings(), getNoiseParamsFromGroup(), and TestSettings::testAllSettings().
|
inline |
References m_settingslayer.
Referenced by con::ConnectionSendThread::ConnectionSendThread(), FontEngine::initFont(), ModApiMapgen::l_set_noiseparams(), loadGameConfAndInitWorld(), TestMapSettingsManager::makeUserConfig(), setDefault(), TestSettings::testDefaults(), and TestMapSettingsManager::testMapMetaSaveLoad().
|
static |
References Settings(), and g_hierarchy.
Referenced by InputHandler::InputHandler(), TestMapSettingsManager::testMapSettingsManager(), and uninit_common().
|
staticprivate |
Referenced by parseConfigLines(), and updateConfigObject().
| std::vector< std::string > Settings::getNames | ( | ) | const |
References m_mutex, and m_settings.
Referenced by ModConfiguration::addModsFromConfig(), compare_settings(), LuaSettings::l_get_names(), and removeSecureSettings().
| bool Settings::getNoEx | ( | const std::string & | name, |
| std::string & | val ) const |
References get().
Referenced by compare_settings(), ServerMap::createDatabase(), getNoiseParamsFromValue(), ServerEnvironment::init(), ServerEnvironment::openAuthDatabase(), Server::openModStorageDatabase(), ServerEnvironment::openPlayerDatabase(), and setup_log_params().
| bool Settings::getNoiseParams | ( | const std::string & | name, |
| NoiseParams & | np ) const |
References getNoiseParamsFromGroup(), getNoiseParamsFromValue(), and getParent().
Referenced by LuaSettings::l_get_np_group(), and TestSettings::testAllSettings().
| bool Settings::getNoiseParamsFromGroup | ( | const std::string & | name, |
| NoiseParams & | np ) const |
References Settings(), flagdesc_noiseparams, NoiseParams::flags, getFlagStrNoEx(), getFloatNoEx(), getGroupNoEx(), getS32NoEx(), getU16NoEx(), getV3FNoEx(), NoiseParams::lacunarity, NOISE_FLAG_DEFAULTS, NoiseParams::octaves, NoiseParams::offset, NoiseParams::persist, NoiseParams::scale, NoiseParams::seed, and NoiseParams::spread.
Referenced by getNoiseParams().
| bool Settings::getNoiseParamsFromValue | ( | const std::string & | name, |
| NoiseParams & | np ) const |
References getNoEx(), NoiseParams::lacunarity, BasicStrfnd< T >::next(), NoiseParams::octaves, NoiseParams::offset, NoiseParams::persist, NoiseParams::scale, NoiseParams::seed, NoiseParams::spread, stof, and stoi.
Referenced by getNoiseParams().
|
private |
References Settings(), m_hierarchy, and m_settingslayer.
Referenced by exists(), getEntry(), getFlagStr(), and getNoiseParams().
| s16 Settings::getS16 | ( | const std::string & | name | ) | const |
Referenced by getS16NoEx(), and TestSettings::testAllSettings().
| bool Settings::getS16NoEx | ( | const std::string & | name, |
| s16 & | val ) const |
| s32 Settings::getS32 | ( | const std::string & | name | ) | const |
Referenced by getS32NoEx(), getSubgameSpec(), parseContentInfo(), parseModContents(), and TestSettings::testAllSettings().
| bool Settings::getS32NoEx | ( | const std::string & | name, |
| s32 & | val ) const |
References getS32().
Referenced by getNoiseParamsFromGroup().
| u16 Settings::getU16 | ( | const std::string & | name | ) | const |
Referenced by Database_Redis::Database_Redis(), PlayerDatabaseFiles::deSerialize(), game_configure_port(), and getU16NoEx().
| bool Settings::getU16NoEx | ( | const std::string & | name, |
| u16 & | val ) const |
References getU16().
Referenced by getNoiseParamsFromGroup(), and ServerEnvironment::init().
| u32 Settings::getU32 | ( | const std::string & | name | ) | const |
Referenced by getU32NoEx(), and ServerEnvironment::loadMeta().
| bool Settings::getU32NoEx | ( | const std::string & | name, |
| u32 & | val ) const |
| u64 Settings::getU64 | ( | const std::string & | name | ) | const |
References from_string(), and get().
Referenced by getU64NoEx(), and ServerEnvironment::loadMeta().
| bool Settings::getU64NoEx | ( | const std::string & | name, |
| u64 & | val ) const |
| v2f Settings::getV2F | ( | const std::string & | name | ) | const |
References get(), BasicStrfnd< T >::next(), and stof.
Referenced by getV2FNoEx().
| bool Settings::getV2FNoEx | ( | const std::string & | name, |
| v2f & | val ) const |
| std::optional< v3f > Settings::getV3F | ( | const std::string & | name | ) | const |
References get(), and str_to_v3f().
Referenced by PlayerDatabaseFiles::deSerialize(), getV3FNoEx(), and TestSettings::testAllSettings().
| bool Settings::getV3FNoEx | ( | const std::string & | name, |
| std::optional< v3f > & | val ) const |
References getV3F().
Referenced by getNoiseParamsFromGroup(), LuaSettings::l_get_pos(), and TestSettings::testAllSettings().
References Settings(), clearNoLock(), FATAL_ERROR_IF, m_callbacks, m_hierarchy, m_mutex, and m_settings.
| bool Settings::parseCommandLine | ( | int | argc, |
| char * | argv[], | ||
| const std::map< std::string, ValueSpec > & | allowed_options ) |
References allowed_options, errorstream, itos(), set(), and VALUETYPE_FLAG.
Referenced by get_cmdline_opts().
| bool Settings::parseConfigLines | ( | std::istream & | is | ) |
References Settings(), getMultiline(), m_end_tag, m_mutex, m_settings, parseConfigLines(), parseConfigObject(), SPE_COMMENT, SPE_END, SPE_GROUP, SPE_INVALID, SPE_KVPAIR, SPE_MULTILINE, and SPE_NONE.
Referenced by PlayerDatabaseFiles::deSerialize(), ServerEnvironment::loadMeta(), parseConfigLines(), readConfigFile(), and TestSettings::testAllSettings().
|
private |
References m_end_tag, SPE_COMMENT, SPE_END, SPE_GROUP, SPE_INVALID, SPE_KVPAIR, SPE_MULTILINE, SPE_NONE, and trim().
Referenced by parseConfigLines(), and updateConfigObject().
|
staticprivate |
References SettingsEntry::group, SettingsEntry::is_group, SettingsEntry::value, and writeLines().
Referenced by updateConfigObject(), and writeLines().
| bool Settings::readConfigFile | ( | const char * | filename | ) |
References parseConfigLines().
Referenced by ServerMap::ServerMap(), ModConfiguration::addModsFromConfig(), getAvailableGameIds(), getSubgameSpec(), getWorldGameId(), getWorldName(), ServerEnvironment::init(), loadGameConfAndInitWorld(), migrate_map_database(), ServerEnvironment::migrateAuthDatabase(), Server::migrateModStorageDatabase(), ServerEnvironment::migratePlayersDatabase(), Server::openModStorageDatabase(), parseContentInfo(), parseModContents(), and recompress_map_database().
| void Settings::registerChangedCallback | ( | const std::string & | name, |
| SettingsChangedCallback | cbf, | ||
| void * | userdata = NULL ) |
References m_callback_mutex, and m_callbacks.
| bool Settings::remove | ( | const std::string & | name | ) |
References doCallbacks(), m_mutex, and m_settings.
Referenced by ModConfiguration::addModsFromConfig(), LuaSettings::l_remove(), and removeSecureSettings().
| void Settings::removeSecureSettings | ( | ) |
References errorstream, getNames(), and remove().
Referenced by loadGameConfAndInitWorld().
| bool Settings::set | ( | const std::string & | name, |
| const std::string & | value ) |
References doCallbacks(), and setEntry().
Referenced by get_env_opts(), ServerEnvironment::init(), LuaSettings::l_set(), loadGameConfAndInitWorld(), TestMapSettingsManager::makeUserConfig(), migrate_map_database(), ServerEnvironment::migrateAuthDatabase(), Server::migrateModStorageDatabase(), ServerEnvironment::migratePlayersDatabase(), parseCommandLine(), ServerEnvironment::saveMeta(), PlayerDatabaseFiles::serialize(), setBool(), setFlagStr(), setFloat(), setS16(), setS32(), setU16(), setU64(), setV2F(), setV3F(), TestSettings::testAllSettings(), TestServerModManager::testCreation(), TestSettings::testDefaults(), TestSettings::testFlagDesc(), and TestMapSettingsManager::testMapMetaSaveLoad().
| bool Settings::setBool | ( | const std::string & | name, |
| bool | value ) |
References set().
Referenced by LuaSettings::l_set_bool(), and loadGameConfAndInitWorld().
| void Settings::setDefault | ( | const std::string & | name, |
| const FlagDesc * | flagdesc, | ||
| u32 | flags ) |
References s_flags, setDefault(), U32_MAX, and writeFlagString().
| bool Settings::setDefault | ( | const std::string & | name, |
| const std::string & | value ) |
References FATAL_ERROR_IF, g_hierarchy, getLayer(), m_hierarchy, and SL_DEFAULTS.
Referenced by setDefault(), and TestSettings::testFlagDesc().
| bool Settings::setEntry | ( | const std::string & | name, |
| const void * | entry, | ||
| bool | set_group ) |
References Settings(), checkNameValid(), checkValueValid(), SettingsEntry::group, SettingsEntry::is_group, m_end_tag, m_mutex, m_settings, and SettingsEntry::value.
Referenced by set(), setGroup(), and setNoiseParams().
| bool Settings::setFlagStr | ( | const std::string & | name, |
| u32 | flags, | ||
| const FlagDesc * | flagdesc = nullptr, | ||
| u32 | flagmask = U32_MAX ) |
References getFlagDescFallback(), set(), and writeFlagString().
Referenced by setNoiseParams().
| bool Settings::setFloat | ( | const std::string & | name, |
| float | value ) |
Referenced by PlayerDatabaseFiles::serialize(), setNoiseParams(), and TestSettings::testAllSettings().
| bool Settings::setGroup | ( | const std::string & | name, |
| const Settings & | group ) |
References Settings(), and setEntry().
Referenced by TestSettings::testAllSettings().
| bool Settings::setNoiseParams | ( | const std::string & | name, |
| const NoiseParams & | np ) |
References Settings(), flagdesc_noiseparams, NoiseParams::flags, NoiseParams::lacunarity, NoiseParams::octaves, NoiseParams::offset, NoiseParams::persist, NoiseParams::scale, NoiseParams::seed, setEntry(), setFlagStr(), setFloat(), setS32(), setU16(), setV3F(), and NoiseParams::spread.
Referenced by LuaSettings::l_set_np_group(), and TestSettings::testAllSettings().
| bool Settings::setS16 | ( | const std::string & | name, |
| s16 | value ) |
Referenced by TestSettings::testAllSettings().
| bool Settings::setS32 | ( | const std::string & | name, |
| s32 | value ) |
Referenced by PlayerDatabaseFiles::serialize(), and setNoiseParams().
| bool Settings::setU16 | ( | const std::string & | name, |
| u16 | value ) |
Referenced by PlayerDatabaseFiles::serialize(), and setNoiseParams().
| bool Settings::setU64 | ( | const std::string & | name, |
| u64 | value ) |
References set().
Referenced by ServerEnvironment::saveMeta().
| bool Settings::setV2F | ( | const std::string & | name, |
| v2f | value ) |
| bool Settings::setV3F | ( | const std::string & | name, |
| v3f | value ) |
References set().
Referenced by LuaSettings::l_set_pos(), PlayerDatabaseFiles::serialize(), setNoiseParams(), and TestSettings::testAllSettings().
| bool Settings::updateConfigFile | ( | const char * | filename | ) |
References m_mutex, fs::safeWriteToFile(), and updateConfigObject().
Referenced by ServerMap::ServerMap(), ModConfiguration::addModsFromConfig(), ServerEnvironment::init(), LuaSettings::l_write(), loadGameConfAndInitWorld(), migrate_map_database(), ServerEnvironment::migrateAuthDatabase(), Server::migrateModStorageDatabase(), ServerEnvironment::migratePlayersDatabase(), and TestServerModManager::testCreation().
|
private |
References Settings(), getMultiline(), m_end_tag, m_settings, parseConfigObject(), printEntry(), sanity_check, SPE_END, SPE_GROUP, SPE_KVPAIR, SPE_MULTILINE, and updateConfigObject().
Referenced by TestSettings::testAllSettings(), updateConfigFile(), and updateConfigObject().
| void Settings::writeLines | ( | std::ostream & | os, |
| u32 | tab_depth = 0 ) const |
References m_end_tag, m_mutex, m_settings, and printEntry().
Referenced by printEntry(), ServerEnvironment::saveMeta(), and PlayerDatabaseFiles::serialize().
|
friend |
References LuaSettings.
Referenced by LuaSettings.
|
friend |
References TestSettings.
Referenced by TestSettings.
|
mutableprivate |
Referenced by deregisterAllChangedCallbacks(), doCallbacks(), and registerChangedCallback().
|
private |
Referenced by deregisterAllChangedCallbacks(), doCallbacks(), operator=(), and registerChangedCallback().
|
private |
Referenced by Settings(), Settings(), parseConfigLines(), parseConfigObject(), setEntry(), updateConfigObject(), and writeLines().
|
private |
Referenced by Settings(), ~Settings(), getParent(), operator=(), and setDefault().
|
mutableprivate |
Referenced by ~Settings(), existsLocal(), getEntry(), getNames(), operator=(), parseConfigLines(), remove(), setEntry(), updateConfigFile(), and writeLines().
|
private |
Referenced by clearNoLock(), existsLocal(), getEntry(), getFlagStr(), getNames(), operator=(), parseConfigLines(), remove(), setEntry(), updateConfigObject(), and writeLines().
|
private |
Referenced by Settings(), ~Settings(), getLayer(), and getParent().
|
staticprivate |
Referenced by getFlagDescFallback(), and setDefault().