azwaan
Programmer
- Jan 11, 2002
- 42
I have a enum declared as follows
enum StatusLevels
{ eConversionStatusNone= 0,
eStatusInProgress = 1,
eStatusSuccess = 2,
eFailed = 3
} StatusLevels;
im using this within code to cast a variable of type short to the enum type as follows
StatusLevels eStatus;
eStatus=static_cast<StatusLevels> (pCommand->GetParamValue(5).iVal);
the stored proc executed returns a smallint type from sql server , but i need to check whether its a invalid value (ie.. not within 0-3)
however i cannot determine whether the cast was successful by using the above method.. is there any other way of doing this so i can determine if the operation was a success so that i can throw an exception if it failed.
enum StatusLevels
{ eConversionStatusNone= 0,
eStatusInProgress = 1,
eStatusSuccess = 2,
eFailed = 3
} StatusLevels;
im using this within code to cast a variable of type short to the enum type as follows
StatusLevels eStatus;
eStatus=static_cast<StatusLevels> (pCommand->GetParamValue(5).iVal);
the stored proc executed returns a smallint type from sql server , but i need to check whether its a invalid value (ie.. not within 0-3)
however i cannot determine whether the cast was successful by using the above method.. is there any other way of doing this so i can determine if the operation was a success so that i can throw an exception if it failed.