44 lines
4.8 KiB
C++
44 lines
4.8 KiB
C++
#include "../Core.hpp"
|
|
|
|
#define BASELIBRARY(simpleName, fullname, returnType) \
|
|
export uint8_t simpleName##_Insert(fullname* p, const char* name, returnType* t) { \
|
|
Try(p->Insert(ArbUt::StringView::CalculateHash(name), t);) \
|
|
} \
|
|
\
|
|
export uint8_t simpleName##_InsertWithHash(fullname* p, uint32_t hashedKey, returnType* t) { \
|
|
Try(p->Insert(hashedKey, t);) \
|
|
} \
|
|
\
|
|
export uint8_t simpleName##_Delete(fullname* p, const char* name) { \
|
|
Try(p->Delete(ArbUt::StringView::CalculateHash(name));) \
|
|
} \
|
|
\
|
|
export uint8_t simpleName##_DeleteWithHash(fullname* p, uint32_t 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), o); \
|
|
out = o.GetRaw(); \
|
|
return v; \
|
|
} \
|
|
\
|
|
export bool simpleName##_TryGetWithHash(fullname* p, uint32_t hashedKey, const returnType*& out) { \
|
|
ArbUt::BorrowedPtr<const returnType> o; \
|
|
auto v = p->TryGet(hashedKey, o); \
|
|
out = o.GetRaw(); \
|
|
return v; \
|
|
} \
|
|
\
|
|
export uint8_t simpleName##_Get(fullname* p, const char* name, const returnType*& out) { \
|
|
Try(out = p->Get(ArbUt::StringView::CalculateHash(name)).GetRaw();) \
|
|
} \
|
|
\
|
|
export uint8_t simpleName##_GetWithHash(fullname* p, uint32_t hashedKey, const returnType*& out) { \
|
|
Try(out = p->Get(hashedKey).GetRaw();) \
|
|
} \
|
|
\
|
|
export size_t simpleName##_GetCount(fullname* p) { return p->GetCount(); } \
|
|
export uint8_t simpleName##_GetAtIndex(fullname* p, size_t index, const returnType*& out) { \
|
|
Try(out = p->GetAtIndex(index).GetRaw();) \
|
|
}
|