shiva
last version
last version
  • Shiva Documentation
  • Shiva
    • Changelog
    • FAQ
    • Gallery
    • Installation
    • Modules
      • shiva::box2d
      • shiva::dll
      • shiva::ecs
      • shiva::entt
      • shiva::enums
      • shiva::error
      • shiva::event
      • shiva::filesystem
      • shiva::input
      • shiva::json
      • shiva::lua
      • shiva::meta
      • shiva::pp
      • shiva::pyscripting
      • shiva::range
      • shiva::reflection
      • shiva::scenes
      • shiva::sfml
        • shiva::system-sfml-animation
        • shiva::system-sfml-graphics
        • shiva::system-sfml-inputs
        • shiva::system-sfml-resources
      • shiva::spdlog
      • shiva::stacktrace
      • shiva::timer
      • shiva::world
    • Roadmap
    • Scripting
      • Lua
      • Python
    • Tutorial
      • Quick'start
      • How to create/build/install a system plugin
      • How to create a scripted system
      • How to create a project through the CLI tools and build it
Powered by GitBook
On this page
  1. Shiva
  2. Modules

shiva::enums

ENUM

The ENUM macro allows preprocessor-based generation of reflective enumerations. These enumerations can be easily converted back and forth to strings. It is also possible to iterate through the available values of such an enumeration type.

#include <shiva/enums/enums.hpp>

ENUM(AnEnum, VALUE_A, VALUE_B);

AnEnum v(AnEnum::VALUE_A);
//v is now AnEnum::VALUE_A

v = AnEnum::VALUE_B;
//v is now AnEnum::VALUE_B

std::string str = v.toString();
//str is now "VALUE_B"

AnEnum s("VALUE_A");
//s is now AnEnum::VALUE_A

for (const auto &cur : AnEnum::values()) {
    //Do stuff
}
Previousshiva::enttNextshiva::error

Last updated 6 years ago