Skip to main content

cpp enum class string idl.

Project description

cpp-enum-class-string-idl

python3 -m cpp_enum_class_string_idl MyEnums.yaml

MyEnums.yaml

interfaces:
  - MyEnum.yaml
  - MyOtherEnum.yaml

MyEnum.yaml

name: MyEnum
type: int
values:
  - Value0
  - Value1

MyEnum.h

#pragma once

/*
 * generated code from cpp-enum-class-string-idl
 */

enum class MyEnum : int {
    Value0,
    Value1,
    Count
};

const char* enum_to_string(const MyEnum value);

MyEnum.cpp

#include "MyEnum.h"

/*
 * generated code from cpp-enum-class-string-idl
 */

const char* _MyEnum[] = {
    "Value0",
    "Value1"
};

const char* enum_to_string(const MyEnum value) {
    if (MyEnum::Count == value) {
        return "";
    }

    return _MyEnum[static_cast<int>(value)];
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cpp-enum-class-string-idl-0.0.4.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page