Many times compilers generate the same code for switch statements as they do for if-then-else blocks. If the compile doesn't care, why should you.
If you really want to use a switch, you can add extra code that creates a Standard Template Library map (#include <map>). You can then map your list of strings to an integer value. Then you can switch on the integer value returned by map::find. Doesn't seem worth it.
Regards,
Thom Bentley
| "XML Man" <[EMAIL PROTECTED]>
06/18/2001 09:46 AM
|
To: [EMAIL PROTECTED] cc: Subject: getNodeValue().transcode() - Explanation |
Thank you everybody.
I only typed two possibilities ("John" and "Tom") only not
to write too much, but the fact is that I've got 9
possibilities, and I do not want to use if-then-else, but
switch-case.
I tested with:
value = attr.getNodeValue().transcode()
if (strcmp(value,"John")==0)...
if (strcmp(value,"Tom")==0)...
if (strcmp(value,"Mary")==0)...
It works but, in my opinion, it's more elegant switch-case,
isn't it?
_______________________________________________________________________
Tu correo gratuito en HispaVista - http://www.hispavista.com/altacorreo/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
