#pragma once #include #include #include #include #include #include "util/numtypes.h" class Weather { public: using percentage = rfl::Validator, rfl::Maximum<100>>; using degrees = rfl::Validator, rfl::Maximum<360>>; struct Condition { usize id; rfl::Rename<"main", std::string> group; std::string description; rfl::Rename<"icon", std::string> icon_id; }; struct Main { f64 temp; f64 temp_max; f64 temp_min; f64 feels_like; isize pressure; std::optional sea_level; std::optional grnd_level; percentage humidity; }; struct Wind { f64 speed; degrees deg; std::optional gust; }; struct Precipitation { rfl::Rename<"1h", f64> one_hour; rfl::Rename<"3h", f64> three_hours; }; struct Sys { std::string country; usize id; usize sunrise; usize sunset; usize type; }; struct Clouds { percentage all; }; struct Coords { double lat; double lon; }; struct WeatherOutput { isize timezone; isize visibility; Main main; Clouds clouds; rfl::Rename<"coord", Coords> coords; std::optional rain; std::optional snow; std::vector weather; std::string base; std::string name; Sys sys; usize cod; usize dt; usize id; Wind wind; }; using Location = std::variant; private: Location m_Location; std::string m_ApiKey; std::string m_Units; public: Weather(Location location, std::string api_key, std::string units); [[nodiscard]] WeatherOutput getWeatherInfo() const; [[nodiscard]] const Location getLocation() const; [[nodiscard]] const std::string getApiKey() const; [[nodiscard]] const std::string getUnits() const; }; struct WeatherImpl { Weather::Location location; std::string api_key; std::string units; static WeatherImpl from_class(const Weather& weather) noexcept; [[nodiscard]] Weather to_class() const; }; class General { private: std::string m_Name; public: General(std::string name); [[nodiscard]] const std::string getName() const; }; struct GeneralImpl { std::string name; static GeneralImpl from_class(const General& general) noexcept; [[nodiscard]] General to_class() const; }; class NowPlaying { private: bool m_Enabled; public: NowPlaying(bool enabled); [[nodiscard]] bool getEnabled() const; }; struct NowPlayingImpl { bool enabled; static NowPlayingImpl from_class(const NowPlaying& now_playing) noexcept; [[nodiscard]] NowPlaying to_class() const; }; class Config { private: General m_General; NowPlaying m_NowPlaying; Weather m_Weather; public: Config(General general, NowPlaying now_playing, Weather weather); static const Config& getInstance(); [[nodiscard]] const Weather getWeather() const; [[nodiscard]] const General getGeneral() const; [[nodiscard]] const NowPlaying getNowPlaying() const; }; struct ConfigImpl { General general; NowPlaying now_playing; Weather weather; static ConfigImpl from_class(const Config& config) noexcept; [[nodiscard]] Config to_class() const; }; // Parsers for Config classes namespace rfl::parsing { template struct Parser : public CustomParser {}; template struct Parser : public CustomParser {}; template struct Parser : public CustomParser {}; template struct Parser : public CustomParser {}; } // namespace rfl::parsing