← Back

ofxMagicEnum

github.com/ofxyz/ofxMagicEnum · @ofxyz
OF 0.12 Utilities

Header-only C++17 library providing compile-time enum reflection

1 0 Last commit 5mo ago Created 5mo ago

README

ofxMagicEnum



//                 _        __                          _
// |  \/  |           (_)      |  __|                        / __|_     _
// | \  / |  _   _ _  _  | |   _   _   _ _  ___   | |   _| |_ _| |_
// | |\/| |/ _ |/ _ | |/ | |  | | '_ \| | | | '_  _ \  | |  |_   _|_   _|
// | |  | | (_| | (_| | | (  | || | | | |_| | | | | | | | |__|_|   |_|
// |_|  |_|\,_|\, |_|\_| |__|_| |_|\,_|_| |_| |_|  \_|
//                __/ | https://github.com/Neargye/magic_enum
//               |___/  version 0.9.7


A thin wrapper addon for magic_enum v0.9.7 — a header-only C++17 library providing compile-time enum reflection.

Features



Usage



Add
ofxMagicEnum to your addons.make, then include what you need:

// Core reflection only

include <magic_enum/magic_enum.hpp>

// Everything (flags, containers, switch, iostream helpers)

include <magic_enum/magic_enum_all.hpp>



Example



enum class Direction { North, South, East, West };

auto name = magic_enum::enum_name(Direction::North); // "North"
auto val  = magic_enum::enum_cast<Direction>("East"); // std::optional<Direction>

for (auto v : magic_enum::enum_values<Direction>()) {
    ofLog() << magic_enum::enum_name(v);
}


MIT — see
include/magic_enum/magic_enum.hpp` header.

Get this addon

HTTPS
SSH