diff --git a/.clang-format b/.clang-format index 441c990..2093ef7 100644 --- a/.clang-format +++ b/.clang-format @@ -14,6 +14,7 @@ ColumnLimit: 100 FixNamespaceComments: false IndentAccessModifiers: false IndentExternBlock: Indent +IndentPPDirectives: BeforeHash NamespaceIndentation: All SkipMacroDefinitionBody: true SpaceBeforeCpp11BracedList: true diff --git a/include/util/macros.h b/include/util/macros.h index 4a2e07a..64be55e 100644 --- a/include/util/macros.h +++ b/include/util/macros.h @@ -1,10 +1,27 @@ #pragma once +/** + * @brief Allows for rust-style function definitions + */ #define fn auto +/** + * @brief Allows for easy getter creation + * + * @param class_name The class to use + * @param type Type of the getter + * @param name Name of the getter + */ #define DEFINE_GETTER(class_name, type, name) \ fn class_name::get##name() const -> type { return m_##name; } +/** + * @brief Helper for making reflect-cpp impls + * + * @param struct_name The struct name + * @param lower_name The arg name + * @param ... Values of the class to convert + */ #define DEF_IMPL(struct_name, lower_name, ...) \ struct struct_name##Impl { \ __VA_ARGS__; \ diff --git a/src/config/config.cpp b/src/config/config.cpp index df02270..0a2ba94 100644 --- a/src/config/config.cpp +++ b/src/config/config.cpp @@ -8,9 +8,7 @@ DEFINE_GETTER(Weather, const std::string, ApiKey) DEFINE_GETTER(Weather, const std::string, Units) Weather::Weather(Location location, std::string api_key, std::string units) - : m_Location(std::move(location)), - m_ApiKey(std::move(api_key)), - m_Units(std::move(units)) {} + : m_Location(std::move(location)), m_ApiKey(std::move(api_key)), m_Units(std::move(units)) {} fn WeatherImpl::from_class(const Weather& weather) noexcept -> WeatherImpl { return { @@ -20,9 +18,7 @@ fn WeatherImpl::from_class(const Weather& weather) noexcept -> WeatherImpl { }; } -fn WeatherImpl::to_class() const -> Weather { - return {location, api_key, units}; -} +fn WeatherImpl::to_class() const -> Weather { return {location, api_key, units}; } // ------------ // ------------- @@ -32,9 +28,7 @@ DEFINE_GETTER(General, const std::string, Name) General::General(std::string name) : m_Name(std::move(name)) {} -fn GeneralImpl::from_class(const General& general) -> GeneralImpl { - return {general.getName()}; -} +fn GeneralImpl::from_class(const General& general) -> GeneralImpl { return {general.getName()}; } fn GeneralImpl::to_class() const -> General { return {name}; } // ------------- @@ -50,9 +44,7 @@ fn NowPlayingImpl::from_class(const NowPlaying& now_playing) -> NowPlayingImpl { return {.enabled = now_playing.getEnabled()}; } -fn NowPlayingImpl::to_class() const -> NowPlaying { - return {enabled.value_or(false)}; -} +fn NowPlayingImpl::to_class() const -> NowPlaying { return {enabled.value_or(false)}; } // ---------------- // ------------ @@ -63,13 +55,10 @@ DEFINE_GETTER(Config, const NowPlaying, NowPlaying) DEFINE_GETTER(Config, const Weather, Weather) Config::Config(General general, NowPlaying now_playing, Weather weather) - : m_General(std::move(general)), - m_NowPlaying(now_playing), - m_Weather(std::move(weather)) {} + : m_General(std::move(general)), m_NowPlaying(now_playing), m_Weather(std::move(weather)) {} fn Config::getInstance() -> const Config& { - static const auto* INSTANCE = - new Config(rfl::toml::load("./config.toml").value()); + static const auto* INSTANCE = new Config(rfl::toml::load("./config.toml").value()); return *INSTANCE; } @@ -81,7 +70,5 @@ fn ConfigImpl::from_class(const Config& config) -> ConfigImpl { }; } -fn ConfigImpl::to_class() const -> Config { - return {general, now_playing, weather}; -} +fn ConfigImpl::to_class() const -> Config { return {general, now_playing, weather}; } // ------------ diff --git a/src/config/config.h b/src/config/config.h index fe34a54..c0d3478 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -46,7 +46,7 @@ class Config { [[nodiscard]] fn getNowPlaying() const -> const NowPlaying; }; -// Reflect-CPP Stuff +// reflect-cpp Stuff DEF_IMPL(General, general, std::string name) DEF_IMPL(NowPlaying, now_playing, std::optional enabled) DEF_IMPL(Config, config, General general; NowPlaying now_playing; Weather weather)