Board index » cppbuilder » BDS2006: Live-template "switch"-statement

BDS2006: Live-template "switch"-statement


2006-09-30 02:36:16 AM
cppbuilder0
Hello,
does the live-template for the "switch"-statement work? When yes,
what must I do that "cases" are generated?
Thanks
Udo
 
 

Re:BDS2006: Live-template "switch"-statement

Udo,
typedef enum {
meOne,
meTwo,
meThree,
}myenum_t;
void my_func(myenum_t someparm) {
// type switch_SPACE_ here and then type someparm in the sync point so it
should look like:
// switch(someparm) {
// default: ;
// }
// then hit TAB or ENTER
}
it should generate:
void my_func(myenum_t someparm) {
switch (someparm) {
case meOne: break;
case meTwo: break;
case meThree: break;
default:
;
}
}
HTH,
-Adam
"Udo Weik" < XXXX@XXXXX.COM >wrote in message
Quote
Hello,

does the live-template for the "switch"-statement work? When yes,
what must I do that "cases" are generated?


Thanks
Udo
 

Re:BDS2006: Live-template "switch"-statement

Hallo Adam,
Quote
typedef enum {
meOne,
meTwo,
meThree,
}myenum_t;


void my_func(myenum_t someparm) {
// type switch_SPACE_ here and then type someparm in the sync point so it
should look like:
// switch(someparm) {
// default: ;
// }
// then hit TAB or ENTER
}

it should generate:

void my_func(myenum_t someparm) {
switch (someparm) {
case meOne: break;
case meTwo: break;
case meThree: break;
default:
;
}
}
...but usually you haven't defined an enum, just an int variable, or?
So it would be useful when n "cases" are generated...
Thanks and greetings
Udo
Quote
>Hello,
>
>does the live-template for the "switch"-statement work? When yes,
>what must I do that "cases" are generated?
 

{smallsort}

Re:BDS2006: Live-template "switch"-statement

Udo,
An enum type is required so that the compiler can determine what to switch
on. If it is merely an int then any int value can bind to it so that makes
the job of determining the cases nearly impossible. IMO, enums are integral
in nature, but make code much cleaner than using 'int' everywhere.
-Adam
"Udo Weik" < XXXX@XXXXX.COM >wrote in message
Quote
Hallo Adam,

>typedef enum {
>meOne,
>meTwo,
>meThree,
>}myenum_t;
>
>
>void my_func(myenum_t someparm) {
>// type switch_SPACE_ here and then type someparm in the sync point so
>it should look like:
>// switch(someparm) {
>// default: ;
>// }
>// then hit TAB or ENTER
>}
>
>it should generate:
>
>void my_func(myenum_t someparm) {
>switch (someparm) {
>case meOne: break;
>case meTwo: break;
>case meThree: break;
>default:
>;
>}
>}

...but usually you haven't defined an enum, just an int variable, or?
So it would be useful when n "cases" are generated...

Thanks and greetings
Udo