]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/nameidmapping.h
Fix BSD iconv declaration
[dragonfireclient.git] / src / nameidmapping.h
index a2f3a30623da8e571f38e60cb9aab1970082157e..3acb43ef120db7b0bed345872a008400f4c8127a 100644 (file)
@@ -17,14 +17,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
-#ifndef NAMEIDMAPPING_HEADER
-#define NAMEIDMAPPING_HEADER
+#pragma once
 
 #include <string>
 #include <iostream>
 #include <set>
+#include <unordered_map>
 #include "irrlichttypes_bloated.h"
-#include "util/cpp11_container.h"
+
+typedef std::unordered_map<u16, std::string> IdToNameMap;
+typedef std::unordered_map<std::string, u16> NameToIdMap;
 
 class NameIdMapping
 {
@@ -43,6 +45,7 @@ class NameIdMapping
                m_id_to_name[id] = name;
                m_name_to_id[name] = id;
        }
+
        void removeId(u16 id)
        {
                std::string name;
@@ -52,6 +55,7 @@ class NameIdMapping
                m_id_to_name.erase(id);
                m_name_to_id.erase(name);
        }
+
        void eraseName(const std::string &name)
        {
                u16 id;
@@ -63,7 +67,7 @@ class NameIdMapping
        }
        bool getName(u16 id, std::string &result) const
        {
-               UNORDERED_MAP<u16, std::string>::const_iterator i;
+               IdToNameMap::const_iterator i;
                i = m_id_to_name.find(id);
                if (i == m_id_to_name.end())
                        return false;
@@ -72,7 +76,7 @@ class NameIdMapping
        }
        bool getId(const std::string &name, u16 &result) const
        {
-               UNORDERED_MAP<std::string, u16>::const_iterator i;
+               NameToIdMap::const_iterator i;
                i = m_name_to_id.find(name);
                if (i == m_name_to_id.end())
                        return false;
@@ -80,9 +84,8 @@ class NameIdMapping
                return true;
        }
        u16 size() const { return m_id_to_name.size(); }
+
 private:
-       UNORDERED_MAP<u16, std::string> m_id_to_name;
-       UNORDERED_MAP<std::string, u16> m_name_to_id;
+       IdToNameMap m_id_to_name;
+       NameToIdMap m_name_to_id;
 };
-
-#endif