2020-07-31 08:51:03 +00:00
|
|
|
#include "../Core.hpp"
|
2020-02-29 13:52:15 +00:00
|
|
|
|
|
|
|
#define BASELIBRARY(simpleName, fullname, returnType) \
|
2022-03-23 12:56:45 +00:00
|
|
|
export u8 simpleName##_Insert(fullname* p, const char* name, returnType* t) { \
|
2020-06-26 15:08:23 +00:00
|
|
|
Try(p->Insert(ArbUt::StringView::CalculateHash(name), t);) \
|
2020-02-29 13:52:15 +00:00
|
|
|
} \
|
|
|
|
\
|
2022-03-23 12:56:45 +00:00
|
|
|
export u8 simpleName##_InsertWithHash(fullname* p, u32 hashedKey, returnType* t) { Try(p->Insert(hashedKey, t);) } \
|
2020-02-29 13:52:15 +00:00
|
|
|
\
|
2022-03-23 12:56:45 +00:00
|
|
|
export u8 simpleName##_Delete(fullname* p, const char* name) { \
|
2020-06-26 15:08:23 +00:00
|
|
|
Try(p->Delete(ArbUt::StringView::CalculateHash(name));) \
|
2020-02-29 13:52:15 +00:00
|
|
|
} \
|
|
|
|
\
|
2022-03-23 12:56:45 +00:00
|
|
|
export u8 simpleName##_DeleteWithHash(fullname* p, u32 hashedKey) { Try(p->Delete(hashedKey);) } \
|
2020-02-29 13:52:15 +00:00
|
|
|
\
|
2020-03-25 18:07:36 +00:00
|
|
|
export bool simpleName##_TryGet(fullname* p, const char* name, const returnType*& out) { \
|
2020-05-26 16:31:06 +00:00
|
|
|
ArbUt::BorrowedPtr<const returnType> o; \
|
2020-12-12 11:42:28 +00:00
|
|
|
auto v = p->TryGet(ArbUt::StringView::CalculateHash(name)); \
|
2020-12-22 15:11:11 +00:00
|
|
|
if (!v.has_value()) { \
|
2020-12-12 11:42:28 +00:00
|
|
|
out = nullptr; \
|
|
|
|
return false; \
|
|
|
|
} else { \
|
|
|
|
out = v.value(); \
|
|
|
|
return true; \
|
|
|
|
} \
|
2020-02-29 13:52:15 +00:00
|
|
|
} \
|
|
|
|
\
|
2022-03-23 12:56:45 +00:00
|
|
|
export bool simpleName##_TryGetWithHash(fullname* p, u32 hashedKey, const returnType*& out) { \
|
2020-05-26 16:31:06 +00:00
|
|
|
ArbUt::BorrowedPtr<const returnType> o; \
|
2020-12-12 11:42:28 +00:00
|
|
|
auto v = p->TryGet(hashedKey); \
|
2020-12-22 15:11:11 +00:00
|
|
|
if (!v.has_value()) { \
|
2020-12-12 11:42:28 +00:00
|
|
|
out = nullptr; \
|
|
|
|
return false; \
|
|
|
|
} else { \
|
|
|
|
out = v.value(); \
|
|
|
|
return true; \
|
|
|
|
} \
|
2020-02-29 13:52:15 +00:00
|
|
|
} \
|
|
|
|
\
|
2022-03-23 12:56:45 +00:00
|
|
|
export u8 simpleName##_Get(fullname* p, const char* name, const returnType*& out) { \
|
2020-07-07 13:33:43 +00:00
|
|
|
Try(out = p->Get(ArbUt::StringView::CalculateHash(name)).GetRaw();) \
|
2020-02-29 13:52:15 +00:00
|
|
|
} \
|
|
|
|
\
|
2022-03-23 12:56:45 +00:00
|
|
|
export u8 simpleName##_GetWithHash(fullname* p, u32 hashedKey, const returnType*& out) { \
|
2020-07-07 13:33:43 +00:00
|
|
|
Try(out = p->Get(hashedKey).GetRaw();) \
|
2020-03-25 18:07:36 +00:00
|
|
|
} \
|
2020-02-29 13:52:15 +00:00
|
|
|
\
|
2020-08-10 15:01:21 +00:00
|
|
|
export size_t simpleName##_GetCount(fullname* p) { return p->GetCount(); } \
|
2022-03-23 12:56:45 +00:00
|
|
|
export u8 simpleName##_GetAtIndex(fullname* p, size_t index, const returnType*& out) { \
|
2020-08-10 15:01:21 +00:00
|
|
|
Try(out = p->GetAtIndex(index).GetRaw();) \
|
|
|
|
}
|