Skip to content

Generate Switch from Enum (Feature Request) #37

@naums

Description

@naums

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions