This commit is contained in:
Mars 2024-06-15 16:38:37 -04:00
parent afbba70f92
commit 81cb6b5d4a
Signed by: pupbrained
GPG key ID: 874E22DF2F9DFCB5
5 changed files with 24 additions and 51 deletions

View file

@ -10,10 +10,12 @@ AllowShortLoopsOnASingleLine: true
BasedOnStyle: Chromium
BinPackArguments: false
BinPackParameters: false
ColumnLimit: 100
FixNamespaceComments: false
IndentAccessModifiers: false
IndentExternBlock: Indent
NamespaceIndentation: All
SkipMacroDefinitionBody: true
SpaceBeforeCpp11BracedList: true
SpacesBeforeTrailingComments: 1

View file

@ -1,3 +1,13 @@
#pragma once
#define fn auto
#define DEFINE_GETTER(class_name, type, name) \
fn class_name::get##name() const -> type { return m_##name; }
#define DEF_IMPL(struct_name, lower_name, ...) \
struct struct_name##Impl { \
__VA_ARGS__; \
static fn from_class(const struct_name& lower_name) -> struct_name##Impl; \
[[nodiscard]] fn to_class() const -> struct_name; \
};

View file

@ -98,7 +98,7 @@ if host_machine.system() == 'linux'
endif
incdir = include_directories(
'include',
['include', '/nix/store/pp85qmfpf239b75sm23hhx6cvxfrr4p9-fmt-10.2.1-dev/include'],
is_system: true # Ignores warnings from include dir
)

View file

@ -32,7 +32,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) noexcept -> GeneralImpl {
fn GeneralImpl::from_class(const General& general) -> GeneralImpl {
return {general.getName()};
}
@ -46,8 +46,7 @@ DEFINE_GETTER(NowPlaying, bool, Enabled)
NowPlaying::NowPlaying(bool enabled) : m_Enabled(enabled) {}
fn NowPlayingImpl::from_class(const NowPlaying& now_playing
) noexcept -> NowPlayingImpl {
fn NowPlayingImpl::from_class(const NowPlaying& now_playing) -> NowPlayingImpl {
return {.enabled = now_playing.getEnabled()};
}
@ -74,7 +73,7 @@ fn Config::getInstance() -> const Config& {
return *INSTANCE;
}
fn ConfigImpl::from_class(const Config& config) noexcept -> ConfigImpl {
fn ConfigImpl::from_class(const Config& config) -> ConfigImpl {
return {
.general = config.getGeneral(),
.now_playing = config.getNowPlaying(),

View file

@ -20,14 +20,6 @@ class General {
[[nodiscard]] fn getName() const -> const std::string;
};
struct GeneralImpl {
std::string name;
static fn from_class(const General& general) noexcept -> GeneralImpl;
[[nodiscard]] fn to_class() const -> General;
};
class NowPlaying {
private:
bool m_Enabled;
@ -38,15 +30,6 @@ class NowPlaying {
[[nodiscard]] fn getEnabled() const -> bool;
};
struct NowPlayingImpl {
std::optional<bool> enabled;
static fn from_class(const NowPlaying& now_playing
) noexcept -> NowPlayingImpl;
[[nodiscard]] fn to_class() const -> NowPlaying;
};
class Config {
private:
General m_General;
@ -63,42 +46,21 @@ class Config {
[[nodiscard]] fn getNowPlaying() const -> const NowPlaying;
};
struct ConfigImpl {
General general;
NowPlaying now_playing;
Weather weather;
// Reflect-CPP Stuff
DEF_IMPL(General, general, std::string name)
DEF_IMPL(NowPlaying, now_playing, std::optional<bool> enabled)
DEF_IMPL(Config, config, General general; NowPlaying now_playing; Weather weather)
static fn from_class(const Config& config) noexcept -> ConfigImpl;
[[nodiscard]] fn to_class() const -> Config;
};
// Parsers for Config classes
namespace rfl::parsing {
template <class ReaderType, class WriterType, class ProcessorsType>
struct Parser<ReaderType, WriterType, General, ProcessorsType>
: public CustomParser<
ReaderType,
WriterType,
ProcessorsType,
General,
GeneralImpl> {};
: public CustomParser<ReaderType, WriterType, ProcessorsType, General, GeneralImpl> {};
template <class ReaderType, class WriterType, class ProcessorsType>
struct Parser<ReaderType, WriterType, NowPlaying, ProcessorsType>
: public CustomParser<
ReaderType,
WriterType,
ProcessorsType,
NowPlaying,
NowPlayingImpl> {};
: public CustomParser<ReaderType, WriterType, ProcessorsType, NowPlaying, NowPlayingImpl> {};
template <class ReaderType, class WriterType, class ProcessorsType>
struct Parser<ReaderType, WriterType, Config, ProcessorsType>
: public CustomParser<
ReaderType,
WriterType,
ProcessorsType,
Config,
ConfigImpl> {};
: public CustomParser<ReaderType, WriterType, ProcessorsType, Config, ConfigImpl> {};
}