Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate Switch from Enum (Feature Request) #37

Open
naums opened this issue Feb 11, 2024 · 1 comment
Open

Generate Switch from Enum (Feature Request) #37

naums opened this issue Feb 11, 2024 · 1 comment
Labels
good first issue Good for newcomers

Comments

@naums
Copy link

naums commented Feb 11, 2024

Hello,

I've just found this plugin, which looks very interesting.

A thing I have to do sometimes is create switch statements for enum-types, mapping out every single element. So I'd propose a feature request, to generate switch statements from enum definitions.

For example from

enum Seasons {
    SPRING, SUMMER, FALL, WINTER
};

Generate:

Seasons s = // ...
switch ( s ) {
  case SPRING:
    break;
  case SUMMER:
    break;
  case FALL:
    break;
  case WINTER:
    break;
}

While we're at it, a separate function to generate a code to convert the enum from String and to String would be swell as well. E.g.

std::string txt = // ...
if ( txt == "WINTER" ) {
    return WINTER;
} else if ( ...

and

Seasons s = // ...
switch ( s ) {
  case SPRING:
    return "SPRING";
  case ...

This is just a feature request. Thank you for your work, even if you don't find this feature interesting enough the implement.

Kind Regards,
snaums

@Badhi
Copy link
Owner

Badhi commented Feb 20, 2024

Hi, that sounds like a useful feature to have. Thanks for the suggestion.

@Badhi Badhi added the good first issue Good for newcomers label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants