This commit is contained in:
Mars 2024-06-16 00:13:15 -04:00
parent f668a2eb4c
commit 50083503cf
Signed by: pupbrained
GPG key ID: 0FF5B8826803F895
224 changed files with 16150 additions and 19488 deletions

View file

@ -1,26 +1,5 @@
#include "config.h"
// -------------
// -- Weather --
// -------------
DEFINE_GETTER(Weather, const Weather::Location, Location)
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)) {}
fn WeatherImpl::from_class(const Weather& weather) noexcept -> WeatherImpl {
return {
.location = weather.getLocation(),
.api_key = weather.getApiKey(),
.units = weather.getUnits(),
};
}
fn WeatherImpl::to_class() const -> Weather { return {location, api_key, units}; }
// ------------
// -------------
// -- General --
// -------------
@ -28,9 +7,11 @@ 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& instance) noexcept -> GeneralImpl {
return { instance.getName() };
}
fn GeneralImpl::to_class() const -> General { return {name}; }
fn GeneralImpl::to_class() const -> General { return General { name }; }
// -------------
// ----------------
@ -40,11 +21,11 @@ DEFINE_GETTER(NowPlaying, bool, Enabled)
NowPlaying::NowPlaying(bool enabled) : m_Enabled(enabled) {}
fn NowPlayingImpl::from_class(const NowPlaying& now_playing) -> NowPlayingImpl {
return {.enabled = now_playing.getEnabled()};
fn NowPlayingImpl::from_class(const NowPlaying& instance) noexcept -> NowPlayingImpl {
return { .enabled = instance.getEnabled() };
}
fn NowPlayingImpl::to_class() const -> NowPlaying { return {enabled.value_or(false)}; }
fn NowPlayingImpl::to_class() const -> NowPlaying { return NowPlaying { enabled.value_or(false) }; }
// ----------------
// ------------
@ -55,20 +36,20 @@ 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>("./config.toml").value());
return *INSTANCE;
}
fn ConfigImpl::from_class(const Config& config) -> ConfigImpl {
fn ConfigImpl::from_class(const Config& instance) noexcept -> ConfigImpl {
return {
.general = config.getGeneral(),
.now_playing = config.getNowPlaying(),
.weather = config.getWeather(),
instance.getGeneral(),
instance.getNowPlaying(),
instance.getWeather(),
};
}
fn ConfigImpl::to_class() const -> Config { return {general, now_playing, weather}; }
fn ConfigImpl::to_class() const -> Config { return { general, now_playing, weather }; }
// ------------