summaryrefslogtreecommitdiff
path: root/src/settings.h
Commit message (Expand)AuthorAge
* Fix issue Minetest crash when custom font path is not existMuhammad Rifqi Priyo Susanto2017-11-08
* Code modernization: src/p*, src/q*, src/r*, src/s* (partial) (#6282)Loïc Blot2017-08-19
* C++ modernize: Pragma once (#6264)Loïc Blot2017-08-17
* [CSM] Add flavour limits controlled by server (#5930)Loïc Blot2017-07-18
* Cpp11 initializers: last src root changeset (#6022)Loïc Blot2017-06-21
* Use C++11 mutexes only (remove compat code) (#5922)Loïc Blot2017-06-06
* C++11 patchset 2: remove util/cpp11.h and util/cpp11_container.h (#5821)Loïc Blot2017-06-04
* Fix various performance issues reported by cppcheck (#5628)Loïc Blot2017-04-21
* Some performance optimizations (#5424)Loïc Blot2017-03-22
* Replace various std::map with UNORDERED_MAP + various cleanupsLoic Blot2016-10-05
* Make some maps unordered to improve performanceLoic Blot2016-10-05
* Settings: Clean up settings changed callback codekwolekr2016-06-11
* Clean up threadingShadowNinja2015-08-23
* Settings: pass name to callbacks by referenceest312015-07-09
* Move globals from main.cpp to more sane locationsCraig Robbins2015-04-01
* Fix game minetest.conf default settingsest312015-03-18
* Settings fixes Make the GameGlobalShaderConstantSetter use the settings callb...gregorycu2015-01-25
* Revert "Make the GameGlobalShaderConstantSetter use the settings callback (8%...Craig Robbins2015-01-25
* Make the GameGlobalShaderConstantSetter use the settings callback (8% perf im...gregorycu2015-01-23
* Settings: Fail on invalid sequence and throw exception for LuaSettingskwolekr2014-12-12
* Settings: Sanitize value for multiline terminator tokenskwolekr2014-12-11
* Settings: Sanitize setting name everywhere, not just LuaSettingskwolekr2014-12-09
* Settings: Make setting entry group and values mutually exclusivekwolekr2014-12-09
* Settings: Various setting group fixes and enhancementskwolekr2014-12-04
* Use setting groups for NoiseParamskwolekr2014-12-02
* LuaSettings: Sanitize setting name stringskwolekr2014-11-30
* settings: Add setting groups and multiline entrieskwolekr2014-11-30
* Implement proper font handlingsapier2014-11-30
* Split settings into seperate source and header filesShadowNinja2014-09-21
* Fix Settings lockingShadowNinja2014-09-21
* Use const references for Settings methodsShadowNinja2014-09-21
* Make getters of the Settings class constCraig Robbins2014-09-21
* Bunch of small fixes (coding style, very unlikely errors, warning messages)sapier2014-04-19
* Add minetest.set_noiseparam_defaults() Lua APIkwolekr2014-02-15
* Make flag strings clear specified flag with 'no' prefixkwolekr2014-02-08
* Remove blank default values for emergequeue_limit_* settingskwolekr2014-02-05
* Revert "Fix settings to honor numeric conversion errors"kwolekr2014-02-05
* Fix settings to honor numeric conversion errorssapier2014-02-04
* Settings: Add no-exception variants of each get methodkwolekr2014-02-03
* Cleanup jthread and fix win32 buildsapier2013-12-01
* Always use builtin JThread librarykwolekr2013-09-15
* Omnicleanup: header cleanup, add ModApiUtil shared between game and mainmenuKahrl2013-08-14
* Dont write directly to files but rather write and copy a tmp filePilzAdam2013-08-13
* Remove no virtual dtor warnings, make MapgenParams contain actual NoiseParamskwolekr2013-05-19
* initial mapgen indev version with farscale feature and huge cavesproller2013-03-16
* Migrate to STL containers/algorithms.Ilya Zhuravlev2013-03-11
* Update Copyright YearsSfan52013-02-24
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
* Add flag string settings, flat map optionkwolekr2013-02-06
* Make sure that settings are written to config file when settings are removed.Jürgen Doser2013-01-22
d. Returns success. bool parseCommandLine(int argc, char *argv[], std::map<std::string, ValueSpec> &allowed_options); bool parseConfigLines(std::istream &is, const std::string &end = ""); void writeLines(std::ostream &os, u32 tab_depth=0) const; SettingsParseEvent parseConfigObject(const std::string &line, const std::string &end, std::string &name, std::string &value); bool updateConfigObject(std::istream &is, std::ostream &os, const std::string &end, u32 tab_depth=0); static bool checkNameValid(const std::string &name); static bool checkValueValid(const std::string &value); static std::string sanitizeName(const std::string &name); static std::string sanitizeValue(const std::string &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); /*********** * Getters * ***********/ const SettingsEntry &getEntry(const std::string &name) const; Settings *getGroup(const std::string &name) 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; s32 getS32(const std::string &name) const; u64 getU64(const std::string &name) const; float getFloat(const std::string &name) const; v2f getV2F(const std::string &name) const; v3f getV3F(const std::string &name) const; u32 getFlagStr(const std::string &name, const FlagDesc *flagdesc, u32 *flagmask) const; // N.B. if getStruct() is used to read a non-POD aggregate type, // the behavior is undefined. bool getStruct(const std::string &name, const std::string &format, void *out, size_t olen) 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; // return all keys used std::vector<std::string> getNames() const; bool exists(const std::string &name) const; /*************************************** * Getters that don't throw exceptions * ***************************************/ bool getEntryNoEx(const std::string &name, SettingsEntry &val) 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 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, v3f &val) const; // N.B. getFlagStrNoEx() does not set val, but merely modifies it. Thus, // val must be initialized before using getFlagStrNoEx(). The intention of // this is to simplify modifying a flags field from a default value. bool getFlagStrNoEx(const std::string &name, u32 &val, FlagDesc *flagdesc) const; /*********** * Setters * ***********/ // N.B. Groups not allocated with new must be set to NULL in the settings // tree before object destruction. bool setEntry(const std::string &name, const void *entry, bool set_group, bool set_default); 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, Settings *group); bool setGroupDefault(const std::string &name, 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, u32 flagmask); bool setNoiseParams(const std::string &name, const NoiseParams &np, bool set_default=false); // N.B. if setStruct() is used to write a non-POD aggregate type, // the behavior is undefined. bool setStruct(const std::string &name, const std::string &format, void *value); // remove a setting bool remove(const std::string &name); void clear(); void clearDefaults(); void updateValue(const Settings &other, const std::string &name); void update(const Settings &other); void registerChangedCallback(std::string name, setting_changed_callback cbf, void *userdata = NULL); void deregisterChangedCallback(std::string name, setting_changed_callback cbf, void *userdata = NULL); private: void updateNoLock(const Settings &other); void clearNoLock(); void clearDefaultsNoLock(); void doCallbacks(std::string name); std::map<std::string, SettingsEntry> m_settings; std::map<std::string, SettingsEntry> m_defaults; std::map<std::string, std::vector<std::pair<setting_changed_callback,void*> > > m_callbacks; mutable Mutex m_callbackMutex; mutable Mutex m_mutex; // All methods that access m_settings/m_defaults directly should lock this. }; #endif