Use std::optional for BaseLibrary TryGet.
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
2020-12-12 12:42:28 +01:00
parent 5c39694f19
commit 185ec40ba5
4 changed files with 28 additions and 17 deletions

View File

@@ -17,16 +17,26 @@
\
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; \
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, uint32_t hashedKey, const returnType*& out) { \
ArbUt::BorrowedPtr<const returnType> o; \
auto v = p->TryGet(hashedKey, o); \
out = o.GetRaw(); \
return v; \
auto v = p->TryGet(hashedKey); \
if (v.has_value()) { \
out = nullptr; \
return false; \
} else { \
out = v.value(); \
return true; \
} \
} \
\
export uint8_t simpleName##_Get(fullname* p, const char* name, const returnType*& out) { \