VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
EnumNames.hpp File Reference

Enumerator names without a hand-written switch. More...

#include <cstddef>
#include <magic_enum/magic_enum.hpp>
#include <optional>
#include <string_view>

Go to the source code of this file.

Namespaces

namespace  VoltMod
 

Macros

#define MAGIC_ENUM_RANGE_MIN   0
 
#define MAGIC_ENUM_RANGE_MAX   255
 

Functions

template<class E >
constexpr std::string_view VoltMod::Name (E value) noexcept
 
template<class E >
constexpr std::optional< E > VoltMod::Parse (std::string_view name) noexcept
 
template<class E >
constexpr std::size_t VoltMod::EnumIndex (E value) noexcept
 
template<class E >
constexpr auto VoltMod::EnumValues () noexcept
 

Variables

template<class E >
constexpr std::size_t VoltMod::EnumCount = magic_enum::enum_count<E>()
 

Detailed Description

Enumerator names without a hand-written switch.

Every framework enum spells its enumerators the way the log and the JSON status want to read them, so the name is the compiler's copy of the identifier. A switch that maps them to strings is one more thing to forget when an enumerator is added.

Definition in file EnumNames.hpp.

Macro Definition Documentation

◆ MAGIC_ENUM_RANGE_MAX

#define MAGIC_ENUM_RANGE_MAX   255

Definition at line 11 of file EnumNames.hpp.

◆ MAGIC_ENUM_RANGE_MIN

#define MAGIC_ENUM_RANGE_MIN   0

Definition at line 8 of file EnumNames.hpp.