aboutsummaryrefslogtreecommitdiff
path: root/core/src/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/Utils')
-rw-r--r--core/src/Utils/Enum.hpp110
-rw-r--r--core/src/Utils/I18n.cpp60
-rw-r--r--core/src/Utils/I18n.hpp21
-rw-r--r--core/src/Utils/RTTI.hpp15
-rw-r--r--core/src/Utils/ScopeGuard.hpp12
-rw-r--r--core/src/Utils/Sigslot.cpp57
-rw-r--r--core/src/Utils/Sigslot.hpp45
-rw-r--r--core/src/Utils/StandardDirectories.cpp12
-rw-r--r--core/src/Utils/Time.cpp6
-rw-r--r--core/src/Utils/Time.hpp2
-rw-r--r--core/src/Utils/Variant.hpp14
-rw-r--r--core/src/Utils/Vector.hpp3
12 files changed, 249 insertions, 108 deletions
diff --git a/core/src/Utils/Enum.hpp b/core/src/Utils/Enum.hpp
index e774b01..1fb9661 100644
--- a/core/src/Utils/Enum.hpp
+++ b/core/src/Utils/Enum.hpp
@@ -3,7 +3,8 @@
#include <compare>
template <class TSelf>
-struct BasicEnum {
+struct BasicEnum
+{
using Self = TSelf;
using ValueType = int;
@@ -14,24 +15,42 @@ struct BasicEnum {
BasicEnum(int value)
: value{ value } {}
- /// Comparsion between 2 values of enum. Useful for situations like `a == b` where both a and b are TSelf.
- friend auto operator<=>(const TSelf& a, const TSelf& b) { return a.value <=> b.value; }
- /// Comparsion between a enum and a raw value. Useful for situations like `a == TSelf::Option` where a is a enum and TSelf::Option is a raw value.
- friend auto operator<=>(const TSelf& self, int value) { return self.value <=> value; }
+ /// Comparison between 2 values of enum. Useful for situations like `a == b` where both a and b are TSelf.
+ friend auto operator<=>(const TSelf& a, const TSelf& b)
+ {
+ return a.value <=> b.value;
+ }
+
+ /// Comparison between a enum and a raw value. Useful for situations like `a == TSelf::Option` where a is a enum and TSelf::Option is a raw value.
+ friend auto operator<=>(const TSelf& self, int value)
+ {
+ return self.value <=> value;
+ }
- operator int() const { return value; }
- operator bool() const { return value; }
+ operator int() const
+ {
+ return value;
+ }
+
+ operator bool() const
+ {
+ return value;
+ }
};
#define ENUM(Name) struct Name : public BasicEnum<Name>
-#define ENUM_MEMBERS() \
- enum Enum : int; \
- operator Enum() const { return (Enum)value; } \
- using BasicEnum<Self>::BasicEnum; \
+#define ENUM_MEMBERS() \
+ enum Enum : int; \
+ operator Enum() const \
+ { \
+ return (Enum)value; \
+ } \
+ using BasicEnum<Self>::BasicEnum; \
enum Enum : int
template <class TSelf>
-struct BasicFlag {
+struct BasicFlag
+{
using Self = TSelf;
using ValueType = int;
@@ -42,9 +61,16 @@ struct BasicFlag {
BasicFlag(int value)
: value{ value } {}
- bool IsSet(TSelf mask) const { return (value & mask.value) == mask.value; }
- bool IsSetExclusive(TSelf mask) const { return value == mask.value; }
- void Set(TSelf mask, bool state) {
+ bool IsSet(TSelf mask) const
+ {
+ return (value & mask.value) == mask.value;
+ }
+ bool IsSetExclusive(TSelf mask) const
+ {
+ return value == mask.value;
+ }
+ void Set(TSelf mask, bool state)
+ {
if (state) {
value = (int)(value | mask.value);
} else {
@@ -53,29 +79,61 @@ struct BasicFlag {
}
/// Comparsion between 2 values of flag. Useful for situations like `a == b` where both a and b are TSelf.
- friend bool operator==(const TSelf& a, const TSelf& b) { return a.value == b.value; }
- friend auto operator<=>(const TSelf& a, const TSelf& b) { return a.value <=> b.value; }
+ friend bool operator==(const TSelf& a, const TSelf& b)
+ {
+ return a.value == b.value;
+ }
+
+ friend auto operator<=>(const TSelf& a, const TSelf& b)
+ {
+ return a.value <=> b.value;
+ }
+
/// Comparsion between a flag and a raw value. Useful for situations like `a == TSelf::Option` where a is a flag and TSelf::Option is a raw value.
- friend bool operator==(const TSelf& self, int value) { return self.value == value; }
- friend auto operator<=>(const TSelf& self, int value) { return self.value <=> value; }
+ friend bool operator==(const TSelf& self, int value)
+ {
+ return self.value == value;
+ }
+
+ friend auto operator<=>(const TSelf& self, int value)
+ {
+ return self.value <=> value;
+ }
+
+ friend TSelf operator&(const TSelf& a, const TSelf& b)
+ {
+ return TSelf(a.value & b.value);
+ }
- friend TSelf operator&(const TSelf& a, const TSelf& b) { return TSelf(a.value & b.value); }
- friend TSelf operator|(const TSelf& a, const TSelf& b) { return TSelf(a.value | b.value); }
- friend TSelf operator^(const TSelf& a, const TSelf& b) { return TSelf(a.value ^ b.value); }
+ friend TSelf operator|(const TSelf& a, const TSelf& b)
+ {
+ return TSelf(a.value | b.value);
+ }
- TSelf operator~() const { return TSelf(~value); }
+ friend TSelf operator^(const TSelf& a, const TSelf& b)
+ {
+ return TSelf(a.value ^ b.value);
+ }
+
+ TSelf operator~() const
+ {
+ return TSelf(~value);
+ }
- TSelf& operator&=(int that) {
+ TSelf& operator&=(int that)
+ {
value = value & that;
return *this;
}
- TSelf& operator|=(int that) {
+ TSelf& operator|=(int that)
+ {
value = value | that;
return *this;
}
- TSelf& operator^=(int that) {
+ TSelf& operator^=(int that)
+ {
value = value ^ that;
return *this;
}
diff --git a/core/src/Utils/I18n.cpp b/core/src/Utils/I18n.cpp
index edc5469..e5131cc 100644
--- a/core/src/Utils/I18n.cpp
+++ b/core/src/Utils/I18n.cpp
@@ -14,15 +14,18 @@ using namespace std::literals::string_view_literals;
namespace {
-struct LanguageInfo {
+struct LanguageInfo
+{
std::string CodeName;
std::string LocaleName;
fs::path File;
};
-class I18nState {
+class I18nState
+{
public:
- static I18nState& Get() {
+ static I18nState& Get()
+ {
static I18nState instance;
return instance;
}
@@ -33,19 +36,22 @@ public:
LanguageInfo* CurrentLanguage = nullptr;
bool Unloaded = false;
- void Unload() {
+ void Unload()
+ {
Unloaded = true;
CurrentEntries = {};
}
- void EnsureLoaded() {
+ void EnsureLoaded()
+ {
if (Unloaded) {
Unloaded = false;
Reload();
}
}
- void Reload() {
+ void Reload()
+ {
if (!CurrentLanguage) return;
std::ifstream ifs(CurrentLanguage->File);
@@ -65,7 +71,8 @@ public:
}
};
-std::string FindLocalizedName(const fs::path& localeFile) {
+std::string FindLocalizedName(const fs::path& localeFile)
+{
std::ifstream ifs(localeFile);
if (!ifs) {
throw std::runtime_error("Failed to open locale file.");
@@ -82,7 +89,8 @@ std::string FindLocalizedName(const fs::path& localeFile) {
} // namespace
-void I18n::Init() {
+void I18n::Init()
+{
auto& state = I18nState::Get();
auto dir = fs::current_path() / "locale";
@@ -106,7 +114,8 @@ void I18n::Init() {
}
}
-void I18n::Shutdown() {
+void I18n::Shutdown()
+{
auto& state = I18nState::Get();
state.LocaleInfos.clear();
state.CurrentEntries.clear();
@@ -114,18 +123,21 @@ void I18n::Shutdown() {
state.Unloaded = false;
}
-void I18n::Unload() {
+void I18n::Unload()
+{
auto& state = I18nState::Get();
state.Unload();
OnUnload();
}
-std::string_view I18n::GetLanguage() {
+std::string_view I18n::GetLanguage()
+{
auto& state = I18nState::Get();
return state.CurrentLanguage->CodeName;
}
-bool I18n::SetLanguage(std::string_view lang) {
+bool I18n::SetLanguage(std::string_view lang)
+{
auto& state = I18nState::Get();
if (state.CurrentLanguage &&
state.CurrentLanguage->CodeName == lang)
@@ -142,7 +154,8 @@ bool I18n::SetLanguage(std::string_view lang) {
return true;
}
-std::optional<std::string_view> I18n::Lookup(std::string_view key) {
+std::optional<std::string_view> I18n::Lookup(std::string_view key)
+{
auto& state = I18nState::Get();
state.EnsureLoaded();
@@ -154,7 +167,8 @@ std::optional<std::string_view> I18n::Lookup(std::string_view key) {
}
}
-std::string_view I18n::LookupUnwrap(std::string_view key) {
+std::string_view I18n::LookupUnwrap(std::string_view key)
+{
auto o = Lookup(key);
if (!o) {
std::string msg;
@@ -166,7 +180,8 @@ std::string_view I18n::LookupUnwrap(std::string_view key) {
return o.value();
}
-std::string_view I18n::LookupLanguage(std::string_view lang) {
+std::string_view I18n::LookupLanguage(std::string_view lang)
+{
auto& state = I18nState::Get();
auto iter = state.LocaleInfos.find(lang);
if (iter != state.LocaleInfos.end()) {
@@ -177,18 +192,22 @@ std::string_view I18n::LookupLanguage(std::string_view lang) {
}
BasicTranslation::BasicTranslation(std::string_view key)
- : mContent{ I18n::LookupUnwrap(key) } {
+ : mContent{ I18n::LookupUnwrap(key) }
+{
}
-const std::string& BasicTranslation::GetString() const {
+const std::string& BasicTranslation::GetString() const
+{
return mContent;
}
-const char* BasicTranslation::Get() const {
+const char* BasicTranslation::Get() const
+{
return mContent.c_str();
}
-FormattedTranslation::FormattedTranslation(std::string_view key) {
+FormattedTranslation::FormattedTranslation(std::string_view key)
+{
auto src = I18n::LookupUnwrap(key);
mMinimumResultLen = 0;
@@ -259,7 +278,8 @@ FormattedTranslation::FormattedTranslation(std::string_view key) {
}
}
-std::string FormattedTranslation::Format(std::span<Argument> args) {
+std::string FormattedTranslation::Format(std::span<Argument> args)
+{
if (args.size() != mNumArguments) {
throw std::runtime_error("Invalid number of arguments for FormattedTranslation::Format, expected " + std::to_string(mNumArguments) + " but found " + std::to_string(args.size()) + ".");
}
diff --git a/core/src/Utils/I18n.hpp b/core/src/Utils/I18n.hpp
index a4dd225..6285d60 100644
--- a/core/src/Utils/I18n.hpp
+++ b/core/src/Utils/I18n.hpp
@@ -11,7 +11,8 @@
#include <variant>
#include <vector>
-class I18n {
+class I18n
+{
public:
static inline Signal<> OnLanguageChange{};
static inline Signal<> OnUnload{};
@@ -37,19 +38,23 @@ public:
static std::string_view LookupLanguage(std::string_view lang);
};
-struct StringArgument {
+struct StringArgument
+{
std::string Value;
};
-struct IntArgument {
+struct IntArgument
+{
int Value;
};
-struct FloatArgument {
+struct FloatArgument
+{
double Value;
};
-class BasicTranslation {
+class BasicTranslation
+{
private:
std::string mContent;
@@ -59,7 +64,8 @@ public:
const char* Get() const;
};
-class FormattedTranslation {
+class FormattedTranslation
+{
public:
using Element = std::variant<std::string, int>;
using Argument = std::string;
@@ -74,7 +80,8 @@ public:
std::string Format(std::span<Argument> args);
};
-class NumericTranslation {
+class NumericTranslation
+{
public:
// TODO
};
diff --git a/core/src/Utils/RTTI.hpp b/core/src/Utils/RTTI.hpp
index bc0d289..86b1e2c 100644
--- a/core/src/Utils/RTTI.hpp
+++ b/core/src/Utils/RTTI.hpp
@@ -3,13 +3,15 @@
#include <cassert>
template <class T, class TBase>
-bool is_a(TBase* t) {
+bool is_a(TBase* t)
+{
assert(t != nullptr);
return T::IsInstance(t);
}
template <class T, class TBase>
-bool is_a_nullable(TBase* t) {
+bool is_a_nullable(TBase* t)
+{
if (t) {
return is_a<T, TBase>(t);
} else {
@@ -18,7 +20,8 @@ bool is_a_nullable(TBase* t) {
}
template <class T, class TBase>
-T* dyn_cast(TBase* t) {
+T* dyn_cast(TBase* t)
+{
assert(t != nullptr);
if (T::IsInstance(t)) {
return static_cast<T*>(t);
@@ -28,7 +31,8 @@ T* dyn_cast(TBase* t) {
}
template <class T, class TBase>
-const T* dyn_cast(const TBase* t) {
+const T* dyn_cast(const TBase* t)
+{
assert(t != nullptr);
if (T::IsInstance(t)) {
return static_cast<const T*>(t);
@@ -38,7 +42,8 @@ const T* dyn_cast(const TBase* t) {
}
template <class T, class TBase>
-T* dyn_cast_nullable(TBase* t) {
+T* dyn_cast_nullable(TBase* t)
+{
if (!t) return nullptr;
return dyn_cast<T, TBase>(t);
}
diff --git a/core/src/Utils/ScopeGuard.hpp b/core/src/Utils/ScopeGuard.hpp
index ed8d4ea..28ffd0b 100644
--- a/core/src/Utils/ScopeGuard.hpp
+++ b/core/src/Utils/ScopeGuard.hpp
@@ -5,7 +5,8 @@
#include <utility>
template <class TCleanupFunc>
-class ScopeGuard {
+class ScopeGuard
+{
private:
TCleanupFunc mFunc;
bool mDismissed = false;
@@ -18,16 +19,19 @@ public:
/// would work. It is highly discourage and unlikely that one would want to use ScopeGuard as a function
/// parameter, so the normal argument that implicit conversion are harmful doesn't really apply here.
ScopeGuard(TCleanupFunc func)
- : mFunc{ std::move(func) } {
+ : mFunc{ std::move(func) }
+ {
}
- ~ScopeGuard() {
+ ~ScopeGuard()
+ {
if (!mDismissed) {
mFunc();
}
}
- void Dismiss() noexcept {
+ void Dismiss() noexcept
+ {
mDismissed = true;
}
};
diff --git a/core/src/Utils/Sigslot.cpp b/core/src/Utils/Sigslot.cpp
index 14deece..1132dfb 100644
--- a/core/src/Utils/Sigslot.cpp
+++ b/core/src/Utils/Sigslot.cpp
@@ -2,23 +2,28 @@
#include <doctest/doctest.h>
-bool SignalStub::Connection::IsOccupied() const {
+bool SignalStub::Connection::IsOccupied() const
+{
return id != InvalidId;
}
SignalStub::SignalStub(IWrapper& wrapper)
- : mWrapper{ &wrapper } {
+ : mWrapper{ &wrapper }
+{
}
-SignalStub::~SignalStub() {
+SignalStub::~SignalStub()
+{
RemoveAllConnections();
}
-std::span<const SignalStub::Connection> SignalStub::GetConnections() const {
+std::span<const SignalStub::Connection> SignalStub::GetConnections() const
+{
return mConnections;
}
-SignalStub::Connection& SignalStub::InsertConnection(SlotGuard* guard) {
+SignalStub::Connection& SignalStub::InsertConnection(SlotGuard* guard)
+{
Connection* result;
int size = static_cast<int>(mConnections.size());
for (int i = 0; i < size; ++i) {
@@ -42,7 +47,8 @@ setup:
return *result;
}
-void SignalStub::RemoveConnection(int id) {
+void SignalStub::RemoveConnection(int id)
+{
if (id >= 0 && id < mConnections.size()) {
auto& conn = mConnections[id];
if (conn.IsOccupied()) {
@@ -58,24 +64,29 @@ void SignalStub::RemoveConnection(int id) {
}
}
-void SignalStub::RemoveConnectionFor(SlotGuard& guard) {
+void SignalStub::RemoveConnectionFor(SlotGuard& guard)
+{
guard.RemoveConnectionFor(*this);
}
-void SignalStub::RemoveAllConnections() {
+void SignalStub::RemoveAllConnections()
+{
for (size_t i = 0; i < mConnections.size(); ++i) {
RemoveConnection(i);
}
}
-SlotGuard::SlotGuard() {
+SlotGuard::SlotGuard()
+{
}
-SlotGuard::~SlotGuard() {
+SlotGuard::~SlotGuard()
+{
DisconnectAll();
}
-void SlotGuard::DisconnectAll() {
+void SlotGuard::DisconnectAll()
+{
for (auto& conn : mConnections) {
if (conn.stub) {
// Also calls SlotGuard::removeConnection, our copy of the data will be cleared in it
@@ -84,7 +95,8 @@ void SlotGuard::DisconnectAll() {
}
}
-int SlotGuard::InsertConnection(SignalStub& stub, int stubId) {
+int SlotGuard::InsertConnection(SignalStub& stub, int stubId)
+{
int size = static_cast<int>(mConnections.size());
for (int i = 0; i < size; ++i) {
auto& conn = mConnections[i];
@@ -102,7 +114,8 @@ int SlotGuard::InsertConnection(SignalStub& stub, int stubId) {
return size;
}
-void SlotGuard::RemoveConnectionFor(SignalStub& stub) {
+void SlotGuard::RemoveConnectionFor(SignalStub& stub)
+{
for (auto& conn : mConnections) {
if (conn.stub == &stub) {
conn.stub->RemoveConnection(conn.stubId);
@@ -110,11 +123,13 @@ void SlotGuard::RemoveConnectionFor(SignalStub& stub) {
}
}
-void SlotGuard::RemoveConnection(int slotId) {
+void SlotGuard::RemoveConnection(int slotId)
+{
mConnections[slotId] = {};
}
-TEST_CASE("Signal connect and disconnect") {
+TEST_CASE("Signal connect and disconnect")
+{
Signal<> sig;
int counter = 0;
@@ -131,7 +146,8 @@ TEST_CASE("Signal connect and disconnect") {
CHECK(counter == 2);
}
-TEST_CASE("Signal with parameters") {
+TEST_CASE("Signal with parameters")
+{
Signal<int> sig;
int counter = 0;
@@ -151,7 +167,8 @@ TEST_CASE("Signal with parameters") {
CHECK(counter == 5);
}
-TEST_CASE("Signal disconnectAll()") {
+TEST_CASE("Signal disconnectAll()")
+{
Signal<> sig;
int counter1 = 0;
@@ -173,7 +190,8 @@ TEST_CASE("Signal disconnectAll()") {
CHECK(counter2 == 2);
}
-TEST_CASE("SlotGuard auto-disconnection") {
+TEST_CASE("SlotGuard auto-disconnection")
+{
int counter1 = 0;
int counter2 = 0;
Signal<> sig;
@@ -197,7 +215,8 @@ TEST_CASE("SlotGuard auto-disconnection") {
CHECK(counter2 == 2);
}
-TEST_CASE("Signal destruct before SlotGuard") {
+TEST_CASE("Signal destruct before SlotGuard")
+{
int counter = 0;
SlotGuard guard;
diff --git a/core/src/Utils/Sigslot.hpp b/core/src/Utils/Sigslot.hpp
index 2a191b4..5638f12 100644
--- a/core/src/Utils/Sigslot.hpp
+++ b/core/src/Utils/Sigslot.hpp
@@ -8,21 +8,25 @@
#include <utility>
#include <vector>
-class SignalStub {
+class SignalStub
+{
public:
/// Non-template interface for Signal<T...> to implement (a barrier to stop template
/// arguments propagation).
- class IWrapper {
+ class IWrapper
+ {
public:
virtual ~IWrapper() = default;
virtual void RemoveFunction(int id) = 0;
};
- enum {
+ enum
+ {
InvalidId = -1,
};
- struct Connection {
+ struct Connection
+ {
SlotGuard* guard;
int slotId;
int id = InvalidId; // If `InvalidId`, then this "spot" is unused
@@ -55,7 +59,8 @@ private:
};
template <class... TArgs>
-class Signal : public SignalStub::IWrapper {
+class Signal : public SignalStub::IWrapper
+{
private:
// Must be in this order so that mFunctions is still intact when mStub's destructor runs
std::vector<std::function<void(TArgs...)>> mFunctions;
@@ -63,7 +68,8 @@ private:
public:
Signal()
- : mStub(*this) {
+ : mStub(*this)
+ {
}
virtual ~Signal() = default;
@@ -73,7 +79,8 @@ public:
Signal(Signal&&) = default;
Signal& operator=(Signal&&) = default;
- void operator()(TArgs... args) {
+ void operator()(TArgs... args)
+ {
for (auto& conn : mStub.GetConnections()) {
if (conn.IsOccupied()) {
mFunctions[conn.id](std::forward<TArgs>(args)...);
@@ -82,7 +89,8 @@ public:
}
template <class TFunction>
- int Connect(TFunction slot) {
+ int Connect(TFunction slot)
+ {
auto& conn = mStub.InsertConnection();
mFunctions.resize(std::max(mFunctions.size(), (size_t)conn.id + 1));
mFunctions[conn.id] = std::move(slot);
@@ -90,26 +98,31 @@ public:
}
template <class TFunction>
- int Connect(SlotGuard& guard, TFunction slot) {
+ int Connect(SlotGuard& guard, TFunction slot)
+ {
auto& conn = mStub.InsertConnection(&guard);
mFunctions.resize(std::max(mFunctions.size(), (size_t)conn.id + 1));
mFunctions[conn.id] = std::move(slot);
return conn.id;
}
- void Disconnect(int id) {
+ void Disconnect(int id)
+ {
mStub.RemoveConnection(id);
}
- void DisconnectFor(SlotGuard& guard) {
+ void DisconnectFor(SlotGuard& guard)
+ {
mStub.RemoveConnectionFor(guard);
}
- void DisconnectAll() {
+ void DisconnectAll()
+ {
mStub.RemoveAllConnections();
}
- virtual void RemoveFunction(int id) {
+ virtual void RemoveFunction(int id)
+ {
mFunctions[id] = {};
}
};
@@ -117,9 +130,11 @@ public:
/// Automatic disconnection mechanism for Signal<>.
/// Bind connection to this guard by using the Connect(SlotGuard&, TFunction) overload.
/// Either DisconnectAll() or the destructor disconnects all connections bound to this guard.
-class SlotGuard {
+class SlotGuard
+{
private:
- struct Connection {
+ struct Connection
+ {
SignalStub* stub = nullptr;
int stubId = SignalStub::InvalidId;
};
diff --git a/core/src/Utils/StandardDirectories.cpp b/core/src/Utils/StandardDirectories.cpp
index 7defc5d..e7d3657 100644
--- a/core/src/Utils/StandardDirectories.cpp
+++ b/core/src/Utils/StandardDirectories.cpp
@@ -12,7 +12,8 @@ namespace fs = std::filesystem;
# pragma comment(lib, "shell32.lib")
# pragma comment(lib, "ole32.lib")
-static fs::path GetAppDataRoaming() {
+static fs::path GetAppDataRoaming()
+{
PWSTR path = nullptr;
HRESULT hr = SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_CREATE, nullptr, &path);
if (SUCCEEDED(hr)) {
@@ -33,7 +34,8 @@ static fs::path GetAppDataRoaming() {
#elif PLATFORM_LINUX
# include <cstdlib>
-static fs::path GetEnvVar(const char* name, const char* backup) {
+static fs::path GetEnvVar(const char* name, const char* backup)
+{
if (const char* path = std::getenv(name)) {
fs::path dataDir(path);
fs::create_directories(dataDir);
@@ -47,7 +49,8 @@ static fs::path GetEnvVar(const char* name, const char* backup) {
#endif
-const std::filesystem::path& StandardDirectories::UserData() {
+const std::filesystem::path& StandardDirectories::UserData()
+{
static auto userDataDir = []() -> fs::path {
#if PLATFORM_WIN32
return GetAppDataRoaming();
@@ -60,7 +63,8 @@ const std::filesystem::path& StandardDirectories::UserData() {
return userDataDir;
}
-const std::filesystem::path& StandardDirectories::UserConfig() {
+const std::filesystem::path& StandardDirectories::UserConfig()
+{
static auto userConfigDir = []() -> fs::path {
#if PLATFORM_WIN32
return GetAppDataRoaming();
diff --git a/core/src/Utils/Time.cpp b/core/src/Utils/Time.cpp
index d8e0bd1..bbdc313 100644
--- a/core/src/Utils/Time.cpp
+++ b/core/src/Utils/Time.cpp
@@ -2,7 +2,8 @@
#include <ctime>
-std::string StringifyTimePoint(std::chrono::time_point<std::chrono::system_clock> tp) {
+std::string StringifyTimePoint(std::chrono::time_point<std::chrono::system_clock> tp)
+{
auto t = std::chrono::system_clock::to_time_t(tp);
char data[32];
@@ -14,7 +15,8 @@ std::string StringifyTimePoint(std::chrono::time_point<std::chrono::system_clock
return std::string(data);
}
-std::string StringifyTimeStamp(int64_t timeStamp) {
+std::string StringifyTimeStamp(int64_t timeStamp)
+{
if (timeStamp == 0) {
return "";
}
diff --git a/core/src/Utils/Time.hpp b/core/src/Utils/Time.hpp
index 1f5a048..13e12a1 100644
--- a/core/src/Utils/Time.hpp
+++ b/core/src/Utils/Time.hpp
@@ -1,7 +1,7 @@
#pragma once
-#include <string>
#include <chrono>
+#include <string>
std::string StringifyTimePoint(std::chrono::time_point<std::chrono::system_clock> tp);
std::string StringifyTimeStamp(int64_t timeStamp);
diff --git a/core/src/Utils/Variant.hpp b/core/src/Utils/Variant.hpp
index 7fdb2dc..df2f882 100644
--- a/core/src/Utils/Variant.hpp
+++ b/core/src/Utils/Variant.hpp
@@ -4,16 +4,21 @@
#include <variant>
template <class... Ts>
-struct Overloaded : Ts... { using Ts::operator()...; };
+struct Overloaded : Ts...
+{
+ using Ts::operator()...;
+};
template <class... Ts>
Overloaded(Ts...) -> Overloaded<Ts...>;
template <class... Args>
-struct VariantCastProxy {
+struct VariantCastProxy
+{
std::variant<Args...> v;
template <class... ToArgs>
- operator std::variant<ToArgs...>() const {
+ operator std::variant<ToArgs...>() const
+ {
return std::visit(
[](auto&& arg) -> std::variant<ToArgs...> { return arg; },
v);
@@ -22,6 +27,7 @@ struct VariantCastProxy {
/// Use snake_case naming to align with `static_cast`, `dynamic_cast`, etc..
template <class... Args>
-auto variant_cast(std::variant<Args...> v) -> VariantCastProxy<Args...> {
+auto variant_cast(std::variant<Args...> v) -> VariantCastProxy<Args...>
+{
return { std::move(v) };
}
diff --git a/core/src/Utils/Vector.hpp b/core/src/Utils/Vector.hpp
index 372d484..61fa520 100644
--- a/core/src/Utils/Vector.hpp
+++ b/core/src/Utils/Vector.hpp
@@ -1,6 +1,7 @@
#pragma once
-struct Vec2i {
+struct Vec2i
+{
int x = 0;
int y = 0;
};