summaryrefslogtreecommitdiff
path: root/src/nameidmapping.h
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2017-06-03 14:55:10 -0400
committerShadowNinja <shadowninja@minetest.net>2017-06-03 14:55:10 -0400
commitcaecdb681c428c1aab9c0f7eec2570c0460f995c (patch)
treee5115982ea59bbf2343ba9b35bc4a0cfbb56f407 /src/nameidmapping.h
parent81d56b94919dceb7b2e51d70b21a7ca22f852bd5 (diff)
parent80dc961d24e1964e25d57039ddb2ba639f9f4d22 (diff)
downloadminetest-caecdb681c428c1aab9c0f7eec2570c0460f995c.tar.gz
minetest-caecdb681c428c1aab9c0f7eec2570c0460f995c.tar.bz2
minetest-caecdb681c428c1aab9c0f7eec2570c0460f995c.zip
Merge 0.4.16 into stable-0.4
Diffstat (limited to 'src/nameidmapping.h')
-rw-r--r--src/nameidmapping.h34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/nameidmapping.h b/src/nameidmapping.h
index 23838c8ff..a2f3a3062 100644
--- a/src/nameidmapping.h
+++ b/src/nameidmapping.h
@@ -32,51 +32,57 @@ public:
void serialize(std::ostream &os) const;
void deSerialize(std::istream &is);
- void clear(){
+ void clear()
+ {
m_id_to_name.clear();
m_name_to_id.clear();
}
- void set(u16 id, const std::string &name){
+
+ void set(u16 id, const std::string &name)
+ {
m_id_to_name[id] = name;
m_name_to_id[name] = id;
}
- void removeId(u16 id){
+ void removeId(u16 id)
+ {
std::string name;
bool found = getName(id, name);
- if(!found) return;
+ if (!found)
+ return;
m_id_to_name.erase(id);
m_name_to_id.erase(name);
}
- void eraseName(const std::string &name){
+ void eraseName(const std::string &name)
+ {
u16 id;
bool found = getId(name, id);
- if(!found) return;
+ if (!found)
+ return;
m_id_to_name.erase(id);
m_name_to_id.erase(name);
}
- bool getName(u16 id, std::string &result) const{
+ bool getName(u16 id, std::string &result) const
+ {
UNORDERED_MAP<u16, std::string>::const_iterator i;
i = m_id_to_name.find(id);
- if(i == m_id_to_name.end())
+ if (i == m_id_to_name.end())
return false;
result = i->second;
return true;
}
- bool getId(const std::string &name, u16 &result) const{
+ bool getId(const std::string &name, u16 &result) const
+ {
UNORDERED_MAP<std::string, u16>::const_iterator i;
i = m_name_to_id.find(name);
- if(i == m_name_to_id.end())
+ if (i == m_name_to_id.end())
return false;
result = i->second;
return true;
}
- u16 size() const{
- return m_id_to_name.size();
- }
+ 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;
};
#endif
-