diff options
Diffstat (limited to 'lib/include/turnsmm/enum_helpers.hpp')
| -rw-r--r-- | lib/include/turnsmm/enum_helpers.hpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/include/turnsmm/enum_helpers.hpp b/lib/include/turnsmm/enum_helpers.hpp new file mode 100644 index 0000000..60b8cd7 --- /dev/null +++ b/lib/include/turnsmm/enum_helpers.hpp @@ -0,0 +1,39 @@ +/* + * SPDX-FileCopyrightText: 2025 Felix Morgner <felix.morgner@gmail.com> + * SPDX-License-Identifier: LGPL-2.1-only + */ + +#ifndef TURNSMM_ENUM_HELPERS_HPP +#define TURNSMM_ENUM_HELPERS_HPP + +#include <glibmm/value.h> + +#include <glib-object.h> +#include <glib.h> + +#include <type_traits> + +#define TURNS_DECLARE_ENUM_VALUE_SPECIALIZATION(Enum) \ + template<> \ + class Value<::Turns::Enum> : public Glib::Value_Enum<::Turns::Enum> \ + { \ + public: \ + auto static value_type() -> GType; \ + } + +#define TURNS_DEFINE_VALUE_SPECIALIZATION(Enum, TurnsEnumName) \ + auto Value<::Turns::Enum>::value_type() -> GType \ + { \ + return ::turns_##TurnsEnumName##_get_type(); \ + } + +namespace Turns +{ + + template<auto Wrapped, auto Unwrapped> + auto constexpr enum_matches = + static_cast<std::underlying_type_t<decltype(Wrapped)>>(Wrapped) == static_cast<std::underlying_type_t<decltype(Unwrapped)>>(Unwrapped); + +} // namespace Turns + +#endif
\ No newline at end of file |
