Apply clang-format to code base

This commit is contained in:
clang-format-bot 2022-09-22 21:26:05 +03:00 committed by ζeh Matt
parent f37d0be806
commit ddb0522bbf
No known key found for this signature in database
GPG key ID: 18CE582C71A225B0
2199 changed files with 118692 additions and 114392 deletions

View file

@ -27,15 +27,15 @@ namespace EsmLoader
template <class F>
auto returnAs(F&& f)
{
using Result = decltype(std::forward<F>(f)(ESM::Static {}));
using Result = decltype(std::forward<F>(f)(ESM::Static{}));
if constexpr (!std::is_same_v<Result, void>)
return Result {};
return Result{};
}
template <class T, class F>
auto withStatic(std::string_view refId, const std::vector<T>& values, F&& f)
{
const auto it = std::lower_bound(values.begin(), values.end(), refId, LessById {});
const auto it = std::lower_bound(values.begin(), values.end(), refId, LessById{});
if (it == values.end() || it->mId != refId)
return returnAs(std::forward<F>(f));
@ -48,11 +48,16 @@ namespace EsmLoader
{
switch (type)
{
case ESM::REC_ACTI: return withStatic(refId, content.mActivators, std::forward<F>(f));
case ESM::REC_CONT: return withStatic(refId, content.mContainers, std::forward<F>(f));
case ESM::REC_DOOR: return withStatic(refId, content.mDoors, std::forward<F>(f));
case ESM::REC_STAT: return withStatic(refId, content.mStatics, std::forward<F>(f));
default: break;
case ESM::REC_ACTI:
return withStatic(refId, content.mActivators, std::forward<F>(f));
case ESM::REC_CONT:
return withStatic(refId, content.mContainers, std::forward<F>(f));
case ESM::REC_DOOR:
return withStatic(refId, content.mDoors, std::forward<F>(f));
case ESM::REC_STAT:
return withStatic(refId, content.mStatics, std::forward<F>(f));
default:
break;
}
return returnAs(std::forward<F>(f));
@ -63,13 +68,13 @@ namespace EsmLoader
std::string_view getModel(const EsmData& content, std::string_view refId, ESM::RecNameInts type)
{
return withStatic(refId, type, content, [] (const auto& v) { return std::string_view(v.mModel); });
return withStatic(refId, type, content, [](const auto& v) { return std::string_view(v.mModel); });
}
ESM::Variant getGameSetting(const std::vector<ESM::GameSetting>& records, std::string_view id)
{
const std::string lower = Misc::StringUtils::lowerCase(id);
auto it = std::lower_bound(records.begin(), records.end(), lower, LessById {});
auto it = std::lower_bound(records.begin(), records.end(), lower, LessById{});
if (it == records.end() || it->mId != lower)
throw std::runtime_error("Game settings \"" + std::string(id) + "\" is not found");
return it->mValue;