The framework introduces a custom enum
managing the associated static name (std::string
) for each enumerator.
#include "SlvEnum.h"
glvm_SlvEnum_named(Color, red, "red", green, "green", blue, "blue")
Alternatively, the enum
declaration is possible without specifying the name of the enumerators. In this case, the name will be the same as the declared name.
glvm_SlvEnum(Color, red, green, blue)
Each name of the enum
is accessible through the method SlvEnum<Color>::get_name(Color)
.
The preprocessor macro defines the std::ostream
, std::istream
, slv::rw::write
and slv::rw::read
functions to make the enum
compliant with the whole Glove framework. For read/write functions, the enumerators are casted to int
.
For an enum
encapsulated into a struct
, class
, or namespace
, the macros above do not apply. It is necessary to implement the specializations in a global context.
namespace Foo {
enum class Color {red, green, blue};
}
#include "SlvEnum.h"
glvm_SlvEnum_implementation(Color, red, green, blue)//inline implementation
//Or: glvm_SlvEnum_named_implementation(Color, red, "red", green, "green", blue, "blue")
The maximum number of elements of enum is 99 when using the macros. The maximum is 62 for MSVC compiler. To enable a maximum of 99 for MSVC, /Zc:preprocessor
compile option must be set.