CreatureLib/CInterface/Library/BaseLibrary.cpp

41 lines
4.5 KiB
C++
Raw Normal View History

#include "../Core.hpp"
#define BASELIBRARY(simpleName, fullname, returnType) \
export uint8_t simpleName##_Insert(fullname* p, const char* name, returnType* t) { \
2020-05-26 16:31:06 +00:00
Try(p->Insert(ArbUt::CaseInsensitiveConstString::GetHash(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) { \
2020-05-26 16:31:06 +00:00
Try(p->Delete(ArbUt::CaseInsensitiveConstString::GetHash(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) { \
2020-05-26 16:31:06 +00:00
ArbUt::BorrowedPtr<const returnType> o; \
auto v = p->TryGet(ArbUt::CaseInsensitiveConstString::GetHash(name), o); \
2020-05-24 18:57:22 +00:00
out = o.operator->(); \
return v; \
} \
\
export bool simpleName##_TryGetWithHash(fullname* p, uint32_t hashedKey, const returnType*& out) { \
2020-05-26 16:31:06 +00:00
ArbUt::BorrowedPtr<const returnType> o; \
2020-05-24 18:57:22 +00:00
auto v = p->TryGet(hashedKey, o); \
out = o.operator->(); \
return v; \
} \
\
export uint8_t simpleName##_Get(fullname* p, const char* name, const returnType*& out) { \
2020-05-26 16:31:06 +00:00
Try(out = p->Get(ArbUt::CaseInsensitiveConstString::GetHash(name)).operator->();) \
} \
\
export uint8_t simpleName##_GetWithHash(fullname* p, uint32_t hashedKey, const returnType*& out) { \
2020-05-24 18:57:22 +00:00
Try(out = p->Get(hashedKey).operator->();) \
} \
\
export size_t simpleName##_GetCount(fullname* p) { return p->GetCount(); }