Added lots of security using asserts.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#ifndef CREATURELIB_BASELIBRARY_HPP
|
||||
#define CREATURELIB_BASELIBRARY_HPP
|
||||
|
||||
#include <Arbutils/Assert.hpp>
|
||||
#include <Arbutils/ConstString.hpp>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
@@ -21,21 +22,19 @@ namespace CreatureLib::Library {
|
||||
}
|
||||
|
||||
inline void Insert(const Arbutils::CaseInsensitiveConstString& key, const T* value) {
|
||||
AssertNotNull(value)
|
||||
_values.insert({key.GetHash(), value});
|
||||
}
|
||||
inline void Insert(uint32_t hashedKey, const T* value) { _values.insert({hashedKey, value}); }
|
||||
inline void Insert(uint32_t hashedKey, const T* value) {
|
||||
AssertNotNull(value)
|
||||
_values.insert({hashedKey, value});
|
||||
}
|
||||
|
||||
inline void Delete(const Arbutils::CaseInsensitiveConstString& key) { _values.erase(key.GetHash()); }
|
||||
inline void Delete(uint32_t hashedKey) { _values.erase({hashedKey}); }
|
||||
|
||||
bool TryGet(const Arbutils::CaseInsensitiveConstString& name, const T*& out) const {
|
||||
auto find = this->_values.find(name.GetHash());
|
||||
if (find == this->_values.end()) {
|
||||
out = nullptr;
|
||||
return false;
|
||||
}
|
||||
out = find->second;
|
||||
return true;
|
||||
return TryGet(name.GetHash(), out);
|
||||
}
|
||||
bool TryGet(uint32_t hashedKey, const T*& out) const {
|
||||
auto find = this->_values.find(hashedKey);
|
||||
|
||||
Reference in New Issue
Block a user