summaryrefslogtreecommitdiff
path: root/src/nameidmapping.h
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-04-23 09:52:40 +0200
committerGitHub <noreply@github.com>2017-04-23 09:52:40 +0200
commit91a9382c25328075d1a27593b22b0a75863951e1 (patch)
treec0806621a7af000f31360a78d486d8e25f3bf52f /src/nameidmapping.h
parent0c34fe20a101f3e9297b3ffab4e8b736a55a558f (diff)
downloadminetest-91a9382c25328075d1a27593b22b0a75863951e1.tar.gz
minetest-91a9382c25328075d1a27593b22b0a75863951e1.tar.bz2
minetest-91a9382c25328075d1a27593b22b0a75863951e1.zip
Pass clang-format on various cpp/header files (#5559)
Diffstat (limited to 'src/nameidmapping.h')
-rw-r--r--src/nameidmapping.h30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/nameidmapping.h b/src/nameidmapping.h
index a0336864b..a2f3a3062 100644
--- a/src/nameidmapping.h
+++ b/src/nameidmapping.h
@@ -38,47 +38,51 @@ public:
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
-