3 ms·
Sure, if you have a few enums with each a few possible values, by all means do this. However, as soon as you get to have, let us say, some more enums that each
by cjfd 3y ago
Sure, if you have a few enums with each a few possible values, by all means do this. However, as soon as you get to have, let us say, some more enums that each have a hundred values or so, not only need to serialize them but also need to deserialize, them, also want to loop over all possible enum values and some such requirements one should start thinking about a smarter solution.
- jackieooh 3y agoI'd probably write a quick python script to generate a function/string table in that case (or I could even do it with a vim macro).
- signa11 3y agoand then check that vim-macro in your code-base somewhere ? sure ^^ ... that will work.
- signa11 3y agolanguage does not really offer a 'loop over all enums' construct. you can push values into a vector/initializer_list/... serialization || deserialization of enum values is a different concern. it all depends on your need though, and you can spend as little or as much time as you deem necessary.