136 void writeLines(std::ostream &os, u32 tab_depth=0)
const;
143 const std::string &
get(
const std::string &name)
const;
144 bool getBool(
const std::string &name)
const;
145 u16
getU16(
const std::string &name)
const;
146 s16
getS16(
const std::string &name)
const;
147 u32
getU32(
const std::string &name)
const;
148 s32
getS32(
const std::string &name)
const;
149 u64
getU64(
const std::string &name)
const;
150 float getFloat(
const std::string &name)
const;
151 float getFloat(
const std::string &name,
float min,
float max)
const;
152 v2f getV2F(
const std::string &name)
const;
153 v3f getV3F(
const std::string &name)
const;
155 u32 *flagmask)
const;
161 std::vector<std::string>
getNames()
const;
163 bool exists(
const std::string &name)
const;
173 bool getNoEx(
const std::string &name, std::string &val)
const;
174 bool getFlag(
const std::string &name)
const;
175 bool getU16NoEx(
const std::string &name, u16 &val)
const;
176 bool getS16NoEx(
const std::string &name, s16 &val)
const;
177 bool getU32NoEx(
const std::string &name, u32 &val)
const;
178 bool getS32NoEx(
const std::string &name, s32 &val)
const;
179 bool getU64NoEx(
const std::string &name, u64 &val)
const;
180 bool getFloatNoEx(
const std::string &name,
float &val)
const;
197 bool setEntry(
const std::string &name,
const void *entry,
199 bool set(
const std::string &name,
const std::string &value);
200 bool setDefault(
const std::string &name,
const std::string &value);
202 bool setBool(
const std::string &name,
bool value);
203 bool setS16(
const std::string &name, s16 value);
204 bool setU16(
const std::string &name, u16 value);
205 bool setS32(
const std::string &name, s32 value);
206 bool setU64(
const std::string &name, u64 value);
207 bool setFloat(
const std::string &name,
float value);
208 bool setV2F(
const std::string &name,
v2f value);
209 bool setV3F(
const std::string &name,
v3f value);
210 bool setFlagStr(
const std::string &name, u32 flags,
215 bool remove(
const std::string &name);
240 std::string &name, std::string &value);
246 static std::string
getMultiline(std::istream &is,
size_t *num_lines=NULL);
247 static void printEntry(std::ostream &os,
const std::string &name,
278 static std::unordered_map<std::string, const FlagDesc *>
s_flags;
#define DISABLE_CLASS_COPY(C)
Definition basic_macros.h:26
Definition l_settings.h:13
Settings * getParent(int layer) const
Definition settings.cpp:44
SettingsHierarchy(Settings *fallback=nullptr)
Definition settings.cpp:30
std::vector< Settings * > layers
Definition settings.h:76
void onLayerCreated(int layer, Settings *obj)
Definition settings.cpp:57
Settings * getLayer(int layer) const
Definition settings.cpp:36
void onLayerRemoved(int layer)
Definition settings.cpp:75
Definition settings.h:109
v2f getV2F(const std::string &name) const
Definition settings.cpp:533
static bool checkValueValid(std::string_view value)
Definition settings.cpp:154
bool setGroup(const std::string &name, const Settings &group)
Definition settings.cpp:866
v3f getV3F(const std::string &name) const
Definition settings.cpp:544
SettingsCallbackMap m_callbacks
Definition settings.h:267
std::mutex m_callback_mutex
Definition settings.h:270
bool getFloatNoEx(const std::string &name, float &val) const
Definition settings.cpp:711
bool getFlag(const std::string &name) const
Definition settings.cpp:701
bool getU32NoEx(const std::string &name, u32 &val) const
Definition settings.cpp:743
bool getV3FNoEx(const std::string &name, v3f &val) const
Definition settings.cpp:786
void doCallbacks(const std::string &name) const
Definition settings.cpp:1067
bool setS32(const std::string &name, s32 value)
Definition settings.cpp:894
u64 getU64(const std::string &name) const
Definition settings.cpp:526
static std::unordered_map< std::string, const FlagDesc * > s_flags
Definition settings.h:278
bool getU64NoEx(const std::string &name, u64 &val) const
Definition settings.cpp:764
~Settings()
Definition settings.cpp:108
bool readConfigFile(const char *filename)
Definition settings.cpp:191
bool getS32NoEx(const std::string &name, s32 &val) const
Definition settings.cpp:753
bool setU16(const std::string &name, u16 value)
Definition settings.cpp:888
bool remove(const std::string &name)
Definition settings.cpp:959
int m_settingslayer
Definition settings.h:276
Settings * getGroup(const std::string &name) const
Definition settings.cpp:466
bool getS16NoEx(const std::string &name, s16 &val) const
Definition settings.cpp:733
bool getNoiseParamsFromValue(const std::string &name, NoiseParams &np) const
Definition settings.cpp:589
bool getGroupNoEx(const std::string &name, Settings *&val) const
Definition settings.cpp:679
int getLayer() const
Definition settings.h:232
u32 getU32(const std::string &name) const
Definition settings.cpp:502
s32 getS32(const std::string &name) const
Definition settings.cpp:507
bool getNoEx(const std::string &name, std::string &val) const
Definition settings.cpp:690
void writeLines(std::ostream &os, u32 tab_depth=0) const
Definition settings.cpp:241
void registerChangedCallback(const std::string &name, SettingsChangedCallback cbf, void *userdata=NULL)
Definition settings.cpp:1029
bool setDefault(const std::string &name, const std::string &value)
Definition settings.cpp:858
std::vector< std::string > getNames() const
Definition settings.cpp:661
const SettingsEntry & getEntry(const std::string &name) const
Definition settings.cpp:449
size_t deregisterAllChangedCallbacks(const void *userdata)
Definition settings.cpp:1036
bool getV2FNoEx(const std::string &name, v2f &val) const
Definition settings.cpp:775
bool updateConfigFile(const char *filename)
Definition settings.cpp:367
const std::string & get(const std::string &name) const
Definition settings.cpp:475
SettingsParseEvent parseConfigObject(const std::string &line, std::string &name, std::string &value)
Definition settings.cpp:979
bool getFlagStrNoEx(const std::string &name, u32 &val, const FlagDesc *flagdesc) const
Definition settings.cpp:797
bool setBool(const std::string &name, bool value)
Definition settings.cpp:876
float getFloat(const std::string &name) const
Definition settings.cpp:513
Settings * getParent() const
Definition settings.cpp:443
bool set(const std::string &name, const std::string &value)
Definition settings.cpp:847
static std::string getMultiline(std::istream &is, size_t *num_lines=NULL)
Definition settings.cpp:165
bool getBool(const std::string &name) const
Definition settings.cpp:484
bool setS16(const std::string &name, s16 value)
Definition settings.cpp:882
Settings(std::string_view end_tag="")
Definition settings.h:116
bool parseConfigLines(std::istream &is)
Definition settings.cpp:201
std::string m_end_tag
Definition settings.h:268
void clearNoLock()
Definition settings.cpp:1007
bool setFloat(const std::string &name, float value)
Definition settings.cpp:908
bool setEntry(const std::string &name, const void *entry, bool set_group)
Definition settings.cpp:819
std::mutex m_mutex
Definition settings.h:273
bool setNoiseParams(const std::string &name, const NoiseParams &np)
Definition settings.cpp:942
static void printEntry(std::ostream &os, const std::string &name, const SettingsEntry &entry, u32 tab_depth=0)
Definition settings.cpp:258
bool exists(const std::string &name) const
Definition settings.cpp:643
Settings & operator=(const Settings &other)
Definition settings.cpp:119
void removeSecureSettings()
Definition settings.cpp:1054
bool getNoiseParams(const std::string &name, NoiseParams &np) const
Definition settings.cpp:578
bool setV3F(const std::string &name, v3f value)
Definition settings.cpp:922
bool existsLocal(const std::string &name) const
Definition settings.cpp:653
u16 getU16(const std::string &name) const
Definition settings.cpp:490
static bool checkNameValid(std::string_view name)
Definition settings.cpp:139
bool setFlagStr(const std::string &name, u32 flags, const FlagDesc *flagdesc=nullptr, u32 flagmask=U32_MAX)
Definition settings.cpp:930
bool setV2F(const std::string &name, v2f value)
Definition settings.cpp:914
bool getU16NoEx(const std::string &name, u16 &val) const
Definition settings.cpp:722
SettingEntries m_settings
Definition settings.h:266
u32 getFlagStr(const std::string &name, const FlagDesc *flagdesc, u32 *flagmask) const
Definition settings.cpp:550
s16 getS16(const std::string &name) const
Definition settings.cpp:496
bool updateConfigObject(std::istream &is, std::ostream &os, u32 tab_depth=0)
Definition settings.cpp:281
SettingsHierarchy * m_hierarchy
Definition settings.h:275
static Settings * createLayer(SettingsLayer sl, std::string_view end_tag="")
Definition settings.cpp:85
bool getNoiseParamsFromGroup(const std::string &name, NoiseParams &np) const
Definition settings.cpp:619
bool setU64(const std::string &name, u64 value)
Definition settings.cpp:900
const FlagDesc * getFlagDescFallback(const std::string &name) const
Definition settings.cpp:1023
bool parseCommandLine(int argc, char *argv[], const std::map< std::string, ValueSpec > &allowed_options)
Definition settings.cpp:387
Definition test_settings.cpp:12
core::vector2d< f32 > v2f
Definition irr_v2d.h:11
core::vector3df v3f
Definition irr_v3d.h:11
#define U32_MAX
Definition irrlichttypes.h:29
static OptionList allowed_options
Definition main.cpp:121
Settings * g_settings
Definition settings.cpp:22
std::vector< std::pair< SettingsChangedCallback, void * > > SettingsCallbackList
Definition settings.h:30
std::unordered_map< std::string, SettingsEntry > SettingEntries
Definition settings.h:107
SettingsLayer
Definition settings.h:50
@ SL_GLOBAL
Definition settings.h:53
@ SL_GAME
Definition settings.h:52
@ SL_DEFAULTS
Definition settings.h:51
@ SL_TOTAL_COUNT
Definition settings.h:54
void(* SettingsChangedCallback)(const std::string &name, void *data)
Definition settings.h:23
std::string g_settings_path
Definition settings.cpp:24
SettingsParseEvent
Definition settings.h:39
@ SPE_KVPAIR
Definition settings.h:43
@ SPE_MULTILINE
Definition settings.h:46
@ SPE_GROUP
Definition settings.h:45
@ SPE_INVALID
Definition settings.h:41
@ SPE_COMMENT
Definition settings.h:42
@ SPE_END
Definition settings.h:44
@ SPE_NONE
Definition settings.h:40
std::unordered_map< std::string, SettingsCallbackList > SettingsCallbackMap
Definition settings.h:32
ValueType
Definition settings.h:34
@ VALUETYPE_FLAG
Definition settings.h:36
@ VALUETYPE_STRING
Definition settings.h:35
std::string value
Definition settings.h:102
SettingsEntry(const std::string &value_)
Definition settings.h:93
bool is_group
Definition settings.h:104
Settings * group
Definition settings.h:103
SettingsEntry(Settings *group_)
Definition settings.h:97
const char * help
Definition settings.h:87
ValueSpec(ValueType a_type, const char *a_help=NULL)
Definition settings.h:80
ValueType type
Definition settings.h:86