waffle-gl / waffle

A C library for selecting an OpenGL API and window system at runtime
https://waffle.freedesktop.org
BSD 2-Clause "Simplified" License
35 stars 16 forks source link

string to enum #22

Open fjhenigman opened 9 years ago

fjhenigman commented 9 years ago

A "string to enum" function (inverse of waffle_enum_to_string) would help with writing command line parsing code. For example: if (argv[1] starts with "WAFFLEPLATFORM") platform = waffle_string_to_enum(argv[1]) else print usage This way when waffle grows new platforms, they can be used without having to update any code. If there are no objections I can write this.

linyaa-kiwi commented 9 years ago

No objections. Please go ahead.

jljusten commented 9 years ago

The function seems fine, but a tool that has a command line parameter of WAFFLE_PLATFORM_FOO seems a bit silly. I prefer -p foo / --platform=foo like wflinfo has.

In https://github.com/jljusten/waffle/tree/wflgears, I was trying to separate out the wflinfo command line parsing to use it in a new wflgears tool. (But, the branch has stalled for some months now...)