If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
I would like to convert a wxString such as "Stretched" to the corresponding enum value. Is there an easy way to do this without using if/else statements?
Java does this, but I don't know any similar facility in C++. It should be quite straightforward to implement it in a generic way if that's what you want though
"Keyboard not detected. Press F1 to continue"
-- Windows
switch(yourstring[0]){
case 'S':
assert(yourstring == "Stretched");
return Stretched;
case 'C':
assert(yourstring == "Centred");
return Centred;
case 'T':
assert(yourstring == "Tiled");
return Tiled;
};
Just make sure that wxStrings guarantees that you have at least one character ('\0') in it. std::string does, but I'm not sure about wxString. Seems like it would though.
switch(yourstring[0]){
case 'S':
assert(yourstring == "Stretched");
return Stretched;
case 'C':
assert(yourstring == "Centred");
return Centred;
case 'T':
assert(yourstring == "Tiled");
return Tiled;
};
Just make sure that wxStrings guarantees that you have at least one character ('\0') in it. std::string does, but I'm not sure about wxString. Seems like it would though.
This would be the easiest, but the EnumBinder might have some use later on.