Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 switch statement from enum
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

peterchen
Tomato Guru

126 Posts

Posted - Aug 06 2009 :  06:07:12 AM  Show Profile  Reply with Quote
Can the autotext (or anything else) be bent to create an appropriate switch statement over all enums in an definition?

i.e. going from

quote:
enum EFoo
{
fooA = 17
fooB = 20,
fooC
};

to

quote:
switch (foo)
{
case fooA: break;
case fooB: break;
case fooC: break;
default: break;
}


feline
Whole Tomato Software

United Kingdom
19021 Posts

Posted - Aug 06 2009 :  3:32:02 PM  Show Profile  Reply with Quote
I believe you can do this with IDE Snippets in C#, but I am not sure of the exact details off hand. The IDE does not offer this feature in C++.

We are considering adding this ability to VA:

case=19137

For now you might be able to do something with an IDE macro, or perhaps something with a regular expression search and replace to turn the enum items into a switch statement. I know this is not ideal, but it might be worth looking at if you do this a lot.

zen is the art of being at one with the two'ness
Go to Top of Page

sean
Whole Tomato Software

USA
2817 Posts

Posted - Aug 21 2015 :  12:26:50 AM  Show Profile  Reply with Quote
case=19137 is implemented in build 2073 as the command "Add Missing Case Statements"
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000