-
-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does this support converting strings to the appropriate enum? #42
Comments
As I understand you, Better Enums doesn't try to replaces spaces by underscores, convert camel case to underscores, or do anything else "fancy" like that – mostly because any choice it could make for one user would be wrong for another user. You may be able to write some kind of function that transforms your input strings before passing them to |
If converting input strings to match your enum constants is not an option for you, you can go in the other direction. At startup, or perhaps using some kind of crazy metaprogramming, you could iterate over all the constants and convert the outputs of |
Yeah, I just need to convert |
There isn't at the moment, but you can get the bytes making up the string. You could then write a custom comparison function against them without having to allocate a temporary intermediate string. The interface could also be adjusted, but so far, I think it is possible to get what you want without an excessive amount of trouble, given that this is a sort of "custom" need. |
Currently, I'm using better enums for the enums I need to be able to iterate over. It works excellent for that. The only issue is I'm using a separate enum for converting cstrings to enums with rt_crc32.
I noticed there is
_from_string_nocase()
, which works except I used underscores between words in my enum. It doesn't look likemake_map
is able to go from a string to the enum representation. The string I'm passing in doesn't have the underscore between the two words. Is there anyway to map string to enum, like enum to string has?The text was updated successfully, but these errors were encountered: