52 lines
5.7 KiB
C++
52 lines
5.7 KiB
C++
#include "../Core.hpp"
|
|
|
|
#define BASELIBRARY(simpleName, fullname, returnType) \
|
|
export u8 simpleName##_Insert(fullname* p, const char* name, returnType* t) { \
|
|
Try(p->Insert(ArbUt::StringView::CalculateHash(name), t);) \
|
|
} \
|
|
\
|
|
export u8 simpleName##_InsertWithHash(fullname* p, u32 hashedKey, returnType* t) { Try(p->Insert(hashedKey, t);) } \
|
|
\
|
|
export u8 simpleName##_Delete(fullname* p, const char* name) { \
|
|
Try(p->Delete(ArbUt::StringView::CalculateHash(name));) \
|
|
} \
|
|
\
|
|
export u8 simpleName##_DeleteWithHash(fullname* p, u32 hashedKey) { Try(p->Delete(hashedKey);) } \
|
|
\
|
|
export bool simpleName##_TryGet(fullname* p, const char* name, const returnType*& out) { \
|
|
ArbUt::BorrowedPtr<const returnType> o; \
|
|
auto v = p->TryGet(ArbUt::StringView::CalculateHash(name)); \
|
|
if (!v.has_value()) { \
|
|
out = nullptr; \
|
|
return false; \
|
|
} else { \
|
|
out = v.value(); \
|
|
return true; \
|
|
} \
|
|
} \
|
|
\
|
|
export bool simpleName##_TryGetWithHash(fullname* p, u32 hashedKey, const returnType*& out) { \
|
|
ArbUt::BorrowedPtr<const returnType> o; \
|
|
auto v = p->TryGet(hashedKey); \
|
|
if (!v.has_value()) { \
|
|
out = nullptr; \
|
|
return false; \
|
|
} else { \
|
|
out = v.value(); \
|
|
return true; \
|
|
} \
|
|
} \
|
|
\
|
|
export u8 simpleName##_Get(fullname* p, const char* name, const returnType*& out) { \
|
|
Try(out = p->Get(ArbUt::StringView::CalculateHash(name)).GetRaw();) \
|
|
} \
|
|
\
|
|
export u8 simpleName##_GetWithHash(fullname* p, u32 hashedKey, const returnType*& out) { \
|
|
Try(out = p->Get(hashedKey).GetRaw();) \
|
|
} \
|
|
\
|
|
export size_t simpleName##_GetCount(fullname* p) { return p->GetCount(); } \
|
|
export u8 simpleName##_GetAtIndex(fullname* p, size_t index, const returnType*& out) { \
|
|
Try(out = p->GetAtIndex(index).GetRaw();) \
|
|
}
|