Use std::optional for BaseLibrary TryGet.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -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) { \
|
||||
|
||||
Reference in New Issue
Block a user