Fix BaseLibrary GetCount, add functions that use std string.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
d6ea16b467
commit
629567a2a5
|
@ -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 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 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 {
|
bool TryGet(const char* name, const T*& out) const {
|
||||||
auto find = this->_values.find(Hash(name));
|
auto find = this->_values.find(Hash(name));
|
||||||
|
@ -36,14 +38,19 @@ namespace CreatureLib::Library {
|
||||||
out = find->second;
|
out = find->second;
|
||||||
return true;
|
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 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 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; }
|
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(); }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue