]> git.lizzy.rs Git - minetest.git/blobdiff - src/settings.h
Do not shade inventory items with textures (#5869)
[minetest.git] / src / settings.h
index 0af861a58683b79db16e587097091ac341b6e34c..8c4f6e559e05cfedc9f0c21953d947a6b9f80c69 100644 (file)
@@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "util/string.h"
 #include "threading/mutex.h"
 #include <string>
-#include <map>
+#include "util/cpp11_container.h"
 #include <list>
 #include <set>
 
@@ -45,7 +45,7 @@ typedef std::vector<
        >
 > SettingsCallbackList;
 
-typedef std::map<std::string, SettingsCallbackList> SettingsCallbackMap;
+typedef UNORDERED_MAP<std::string, SettingsCallbackList> SettingsCallbackMap;
 
 enum ValueType {
        VALUETYPE_STRING,
@@ -74,30 +74,29 @@ struct ValueSpec {
 };
 
 struct SettingsEntry {
-       SettingsEntry()
-       {
-               group    = NULL;
-               is_group = false;
-       }
-
-       SettingsEntry(const std::string &value_)
-       {
-               value    = value_;
-               group    = NULL;
-               is_group = false;
-       }
-
-       SettingsEntry(Settings *group_)
-       {
-               group    = group_;
-               is_group = true;
-       }
+       SettingsEntry() :
+               group(NULL),
+               is_group(false)
+       {}
+
+       SettingsEntry(const std::string &value_) :
+               value(value_),
+               group(NULL),
+               is_group(false)
+       {}
+
+       SettingsEntry(Settings *group_) :
+               group(group_),
+               is_group(true)
+       {}
 
        std::string value;
        Settings *group;
        bool is_group;
 };
 
+typedef UNORDERED_MAP<std::string, SettingsEntry> SettingEntries;
+
 class Settings {
 public:
        Settings() {}
@@ -127,8 +126,6 @@ class Settings {
 
        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);
@@ -139,7 +136,7 @@ class Settings {
 
        const SettingsEntry &getEntry(const std::string &name) const;
        Settings *getGroup(const std::string &name) const;
-       std::string get(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;
@@ -231,8 +228,8 @@ class Settings {
 
        void doCallbacks(const std::string &name) const;
 
-       std::map<std::string, SettingsEntry> m_settings;
-       std::map<std::string, SettingsEntry> m_defaults;
+       SettingEntries m_settings;
+       SettingEntries m_defaults;
 
        SettingsCallbackMap m_callbacks;