string to enum

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Hellcat

string to enum

Post by Hellcat »

hey all,
does anyone know how to convert from a string to enum? im pretty sure there's a way just cant find it right now...

thx
The Hellcat
Posts: 33
Joined: Sat Oct 16, 2004 11:52 pm
Location: Earth

Post by The Hellcat »

Problem Solved...
HTML/CSS/Javascript/ASP/PHP/SQL/XML/QBasic
Next Up: C++
Guest

Post by Guest »

And how?
The Hellcat
Posts: 33
Joined: Sat Oct 16, 2004 11:52 pm
Location: Earth

Post by The Hellcat »

ok, here's how i originally wanted to go about it:
string whichdriver= "OpenGL"
driverType = convertfromstringtoenum(whichdriver) pseudocode

and heres how i will instead do it
if whichdriver = "OPENGL"
driverType = EDT_OPENGL

for some reason though, my if statements are never true, so i still have to mess with it...
HTML/CSS/Javascript/ASP/PHP/SQL/XML/QBasic
Next Up: C++
Guest

Post by Guest »

I realise you posted pseudocode, so this may not be what you're doing, but:
C++ uses == to compare values, and = to assign a value.

Other than that, it may be a good idea to consider that irr's string == operator is case-sensitive.
The Hellcat
Posts: 33
Joined: Sat Oct 16, 2004 11:52 pm
Location: Earth

Post by The Hellcat »

yes, that post was pseudocode. I know how to use the == operator! lol

ive messed with the capitalization a few times, but im going to try something else...i have a series of if statements...but i was thinking of doing

if whatever
else if whatever
else if whatever

instead of if whatever
if whatever
if whatever


the former was done in another reply to one of my topics so i think i might try that out and look for a difference.
HTML/CSS/Javascript/ASP/PHP/SQL/XML/QBasic
Next Up: C++
Post Reply