weh
This commit is contained in:
parent
afbba70f92
commit
81cb6b5d4a
|
@ -10,10 +10,12 @@ AllowShortLoopsOnASingleLine: true
|
||||||
BasedOnStyle: Chromium
|
BasedOnStyle: Chromium
|
||||||
BinPackArguments: false
|
BinPackArguments: false
|
||||||
BinPackParameters: false
|
BinPackParameters: false
|
||||||
|
ColumnLimit: 100
|
||||||
FixNamespaceComments: false
|
FixNamespaceComments: false
|
||||||
IndentAccessModifiers: false
|
IndentAccessModifiers: false
|
||||||
IndentExternBlock: Indent
|
IndentExternBlock: Indent
|
||||||
NamespaceIndentation: All
|
NamespaceIndentation: All
|
||||||
|
SkipMacroDefinitionBody: true
|
||||||
SpaceBeforeCpp11BracedList: true
|
SpaceBeforeCpp11BracedList: true
|
||||||
SpacesBeforeTrailingComments: 1
|
SpacesBeforeTrailingComments: 1
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#define fn auto
|
#define fn auto
|
||||||
|
|
||||||
#define DEFINE_GETTER(class_name, type, name) \
|
#define DEFINE_GETTER(class_name, type, name) \
|
||||||
fn class_name::get##name() const->type { return m_##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; \
|
||||||
|
};
|
||||||
|
|
|
@ -98,7 +98,7 @@ if host_machine.system() == 'linux'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
incdir = include_directories(
|
incdir = include_directories(
|
||||||
'include',
|
['include', '/nix/store/pp85qmfpf239b75sm23hhx6cvxfrr4p9-fmt-10.2.1-dev/include'],
|
||||||
is_system: true # Ignores warnings from include dir
|
is_system: true # Ignores warnings from include dir
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ DEFINE_GETTER(General, const std::string, Name)
|
||||||
|
|
||||||
General::General(std::string name) : m_Name(std::move(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()};
|
return {general.getName()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,8 +46,7 @@ DEFINE_GETTER(NowPlaying, bool, Enabled)
|
||||||
|
|
||||||
NowPlaying::NowPlaying(bool enabled) : m_Enabled(enabled) {}
|
NowPlaying::NowPlaying(bool enabled) : m_Enabled(enabled) {}
|
||||||
|
|
||||||
fn NowPlayingImpl::from_class(const NowPlaying& now_playing
|
fn NowPlayingImpl::from_class(const NowPlaying& now_playing) -> NowPlayingImpl {
|
||||||
) noexcept -> NowPlayingImpl {
|
|
||||||
return {.enabled = now_playing.getEnabled()};
|
return {.enabled = now_playing.getEnabled()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +73,7 @@ fn Config::getInstance() -> const Config& {
|
||||||
return *INSTANCE;
|
return *INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ConfigImpl::from_class(const Config& config) noexcept -> ConfigImpl {
|
fn ConfigImpl::from_class(const Config& config) -> ConfigImpl {
|
||||||
return {
|
return {
|
||||||
.general = config.getGeneral(),
|
.general = config.getGeneral(),
|
||||||
.now_playing = config.getNowPlaying(),
|
.now_playing = config.getNowPlaying(),
|
||||||
|
|
|
@ -20,14 +20,6 @@ class General {
|
||||||
[[nodiscard]] fn getName() const -> const std::string;
|
[[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 {
|
class NowPlaying {
|
||||||
private:
|
private:
|
||||||
bool m_Enabled;
|
bool m_Enabled;
|
||||||
|
@ -38,15 +30,6 @@ class NowPlaying {
|
||||||
[[nodiscard]] fn getEnabled() const -> bool;
|
[[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 {
|
class Config {
|
||||||
private:
|
private:
|
||||||
General m_General;
|
General m_General;
|
||||||
|
@ -63,42 +46,21 @@ class Config {
|
||||||
[[nodiscard]] fn getNowPlaying() const -> const NowPlaying;
|
[[nodiscard]] fn getNowPlaying() const -> const NowPlaying;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ConfigImpl {
|
// Reflect-CPP Stuff
|
||||||
General general;
|
DEF_IMPL(General, general, std::string name)
|
||||||
NowPlaying now_playing;
|
DEF_IMPL(NowPlaying, now_playing, std::optional<bool> enabled)
|
||||||
Weather weather;
|
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 {
|
namespace rfl::parsing {
|
||||||
template <class ReaderType, class WriterType, class ProcessorsType>
|
template <class ReaderType, class WriterType, class ProcessorsType>
|
||||||
struct Parser<ReaderType, WriterType, General, ProcessorsType>
|
struct Parser<ReaderType, WriterType, General, ProcessorsType>
|
||||||
: public CustomParser<
|
: public CustomParser<ReaderType, WriterType, ProcessorsType, General, GeneralImpl> {};
|
||||||
ReaderType,
|
|
||||||
WriterType,
|
|
||||||
ProcessorsType,
|
|
||||||
General,
|
|
||||||
GeneralImpl> {};
|
|
||||||
|
|
||||||
template <class ReaderType, class WriterType, class ProcessorsType>
|
template <class ReaderType, class WriterType, class ProcessorsType>
|
||||||
struct Parser<ReaderType, WriterType, NowPlaying, ProcessorsType>
|
struct Parser<ReaderType, WriterType, NowPlaying, ProcessorsType>
|
||||||
: public CustomParser<
|
: public CustomParser<ReaderType, WriterType, ProcessorsType, NowPlaying, NowPlayingImpl> {};
|
||||||
ReaderType,
|
|
||||||
WriterType,
|
|
||||||
ProcessorsType,
|
|
||||||
NowPlaying,
|
|
||||||
NowPlayingImpl> {};
|
|
||||||
|
|
||||||
template <class ReaderType, class WriterType, class ProcessorsType>
|
template <class ReaderType, class WriterType, class ProcessorsType>
|
||||||
struct Parser<ReaderType, WriterType, Config, ProcessorsType>
|
struct Parser<ReaderType, WriterType, Config, ProcessorsType>
|
||||||
: public CustomParser<
|
: public CustomParser<ReaderType, WriterType, ProcessorsType, Config, ConfigImpl> {};
|
||||||
ReaderType,
|
|
||||||
WriterType,
|
|
||||||
ProcessorsType,
|
|
||||||
Config,
|
|
||||||
ConfigImpl> {};
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue