Does this library support reflecting Enum class member to string?
eesaber opened this issue · comments
Does this library support reflecting Enum class member to string?
For example, I have a enum class Foo
enum class Foo {
kBar,
kBaz,
};
And I want to convert to string
"kBar", "kBaz"
No, enum to string is not supported by RareCpp, at least in the short term I've decided I can't do this better than existing libraries (full-support for typical enum reflection activities is a very non-trivial problem) depending on your needs I recommend one of:
- magic_enum - https://github.com/Neargye/magic_enum (no boilerplate required if your enums aren't using the same values in the same enum more than once, and the values are between -128 and 128 or are only bit-flag values)
- wise_enum - https://github.com/quicknir/wise_enum (a macro-based approach to enum reflection with few restrictions)
- a manual approach, e.g. https://godbolt.org/z/T7aT9eKMT
I am currently working on a side project in ORM (Object-Relational Mapping). One of my requirements is to be able to map database enum types to C++ enum types, and vice versa.
Thanks a lot for the suggestion of using the magic_enum library. I will take a look at it and see if it fits my needs.