CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::Enum Class Reference

Represents a reflected enum from C++. More...

#include <CeresEngine/Reflection/Enum.hpp>

Inheritance diagram for CeresEngine::Enum:
CeresEngine::MetaContainer CeresEngine::TEnum< T >

Public Types

using ValueGetter = UniqueFunction< Box() const >
 
using EnumerateElementFunction = FunctionView< bool(const EnumValue &) const >
 Defines a type that represents the function to be called when iterating over all MetaEnumValue.
 

Public Member Functions

 Enum (const StringView name)
 
const EnumValuegetEnumValueWithName (StringView name) const
 Gets the MetaEnumValue for the entry named name.
 
const EnumValuegetEnumValueWithValue (const Box &name) const
 Gets the MetaEnumValue for the entry with the given value.
 
Optional< const Box & > getValue (StringView name) const
 Gets the value of an enum by name.
 
Optional< StringViewgetName (const Box &value) const
 Gets the name of an enum by value.
 
void forEachValue (const EnumerateElementFunction &func) const
 Calls func for each value in the enum.
 
Generator< const EnumValueforEachValue () const
 Iterates over all enum values on the enum.
 
- Public Member Functions inherited from CeresEngine::MetaContainer
template<typename T , typename Func >
void forEach (Func &&func) const
 
template<typename Func >
void forEach (MetaCategory category, Func &&func) const
 
template<typename T >
Generator< const TforEach () const
 
Generator< const MetaItemforEach (MetaCategory category) const
 

Public Attributes

String name
 

Protected Member Functions

void addElement (StringView name, ValueGetter &&value)
 
- Protected Member Functions inherited from CeresEngine::MetaContainer
 MetaContainer ()=default
 
virtual ~MetaContainer ()=default
 
bool addItem (MetaItem *value)
 
std::size_t count (MetaCategory category) const
 

Detailed Description

Represents a reflected enum from C++.

Can be used to get a list of values and their names.

Member Typedef Documentation

◆ EnumerateElementFunction

Defines a type that represents the function to be called when iterating over all MetaEnumValue.

◆ ValueGetter

Constructor & Destructor Documentation

◆ Enum()

CeresEngine::Enum::Enum ( const StringView  name)
inlineexplicit

Member Function Documentation

◆ addElement()

void CeresEngine::Enum::addElement ( StringView  name,
ValueGetter &&  value 
)
protected

◆ forEachValue() [1/2]

Generator< const EnumValue > CeresEngine::Enum::forEachValue ( ) const

Iterates over all enum values on the enum.

Returns
A generator that iterates over all values of the enum.

◆ forEachValue() [2/2]

void CeresEngine::Enum::forEachValue ( const EnumerateElementFunction func) const

Calls func for each value in the enum.

Parameters
funcThe function to be called for each enum value.

◆ getEnumValueWithName()

const EnumValue * CeresEngine::Enum::getEnumValueWithName ( StringView  name) const

Gets the MetaEnumValue for the entry named name.

Parameters
nameThe name of the enum, as a string.
Returns
A pointer to the found MetaEnumValue, or nullptr if not found.

◆ getEnumValueWithValue()

const EnumValue * CeresEngine::Enum::getEnumValueWithValue ( const Box name) const

Gets the MetaEnumValue for the entry with the given value.

Parameters
valueThe value of the enum.
Returns
A pointer to the found MetaEnumValue, or nullptr if not found.

◆ getName()

Optional< StringView > CeresEngine::Enum::getName ( const Box value) const

Gets the name of an enum by value.

Parameters
valueThe value of the enum.
Returns
The name of the enum or an empty optional if no such value exists.

◆ getValue()

Optional< const Box & > CeresEngine::Enum::getValue ( StringView  name) const

Gets the value of an enum by name.

Parameters
nameThe name of the enum, as a string.
Returns
The value of the enum, or an empty value if no such value exists.

Member Data Documentation

◆ name

String CeresEngine::Enum::name

The documentation for this class was generated from the following file: