Fix BaseLibrary GetCount, add functions that use std string.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-02-15 19:14:10 +01:00
parent d6ea16b467
commit 629567a2a5
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 8 additions and 1 deletions

View File

@ -24,8 +24,10 @@ namespace CreatureLib::Library {
}
inline void Insert(const char* key, const T* value) { _values.insert({Hash(key), value}); }
inline void Insert(const std::string& key, const T* value) { Insert(key.c_str(), value); }
inline void Delete(const char* key) { _values.erase(Hash(key)); }
inline void Delete(const std::string& key) { Delete(key.c_str()); }
bool TryGet(const char* name, const T*& out) const {
auto find = this->_values.find(Hash(name));
@ -36,14 +38,19 @@ namespace CreatureLib::Library {
out = find->second;
return true;
}
bool TryGet(const std::string& name, const T*& out) const {
return TryGet(name.c_str(), out);
}
inline const T* Get(const char* name) const { return _values.at(Hash(name)); }
inline const T* Get(const std::string& name) const { return Get(name.c_str()); }
inline const T* operator[](const char* name) const { return Get(name); }
inline const T* operator[](const std::string& name) const { return Get(name.c_str()); }
inline const std::unordered_map<uint32_t, const T*>& GetIterator() const { return _values; }
size_t GetCount() const { return _values.count(); }
size_t GetCount() const { return _values.size(); }
};
}