ECSTASY
All in the name
Loading...
Searching...
No Matches
SerializableEnum.hpp File Reference

Create a serializable enumeration type. More...

#include "foreach.hpp"
Include dependency graph for SerializableEnum.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _ENUM_TO_STRING_ENTRY(name)   {Enum::name, #name},
 
#define _STRING_TO_ENUM_ENTRY(name)   {#name, Enum::name},
 
#define _GET_FIRST_ARG(arg1, ...)   arg1
 
#define _REMOVE_FIRST_ARG(arg1, ...)   __VA_ARGS__
 
#define SERIALIZABLE_ENUM(NAME, STARTING_AT, ...)
 Create a serializable enumeration type.
 

Detailed Description

Create a serializable enumeration type.

Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Version
1.0.0
Date
2022-11-30

Definition in file SerializableEnum.hpp.

Macro Definition Documentation

◆ _ENUM_TO_STRING_ENTRY

#define _ENUM_TO_STRING_ENTRY (   name)    {Enum::name, #name},

Definition at line 17 of file SerializableEnum.hpp.

◆ _GET_FIRST_ARG

#define _GET_FIRST_ARG (   arg1,
  ... 
)    arg1

Definition at line 19 of file SerializableEnum.hpp.

◆ _REMOVE_FIRST_ARG

#define _REMOVE_FIRST_ARG (   arg1,
  ... 
)    __VA_ARGS__

Definition at line 20 of file SerializableEnum.hpp.

◆ _STRING_TO_ENUM_ENTRY

#define _STRING_TO_ENUM_ENTRY (   name)    {#name, Enum::name},

Definition at line 18 of file SerializableEnum.hpp.

◆ SERIALIZABLE_ENUM

#define SERIALIZABLE_ENUM (   NAME,
  STARTING_AT,
  ... 
)
Value:
struct __##NAME { \
public: \
enum class Enum { _GET_FIRST_ARG(__VA_ARGS__) = STARTING_AT, _REMOVE_FIRST_ARG(__VA_ARGS__) }; \
\
friend inline std::ostream &operator<<(std::ostream &stream, const Enum &e) \
{ \
return stream << map.at(e); \
} \
friend inline std::istream &operator>>(std::istream &stream, Enum &e) \
{ \
std::string buffer; \
\
stream >> buffer; \
e = map.at(buffer); \
return stream; \
} \
}; \
using NAME = __##NAME::Enum;
#define _ENUM_TO_STRING_ENTRY(name)
#define _GET_FIRST_ARG(arg1,...)
#define _REMOVE_FIRST_ARG(arg1,...)
#define _STRING_TO_ENUM_ENTRY(name)
T at(T... args)
#define FOR_EACH(macro,...)
Definition foreach.hpp:25

Create a serializable enumeration type.

Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2024-10-18)

Definition at line 28 of file SerializableEnum.hpp.