File: pybind_enums.cpp

package info (click to toggle)
taskflow 3.9.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 45,948 kB
  • sloc: cpp: 39,058; xml: 35,572; python: 12,935; javascript: 1,732; makefile: 59; sh: 16
file content (29 lines) | stat: -rw-r--r-- 736 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <pybind11/pybind11.h>

namespace py = pybind11;

enum MyEnum {
    First = 0,
    Second = 1,
    Third = 74,
    Consistent = -5
};

enum SixtyfourBitFlag: std::uint64_t {
    Yes = 1000000000000ull,
    No = 18446744073709551615ull
};

PYBIND11_MODULE(pybind_enums, m) {
    m.doc() = "pybind11 enum parsing";

    py::enum_<MyEnum>(m, "MyEnum", "An enum with external value docs, at least")
        .value("First", MyEnum::First)
        .value("Second", MyEnum::Second)
        .value("Third", MyEnum::Third)
        .value("CONSISTANTE", MyEnum::Consistent);

    py::enum_<SixtyfourBitFlag>(m, "SixtyfourBitFlag", "64-bit flags")
        .value("Yes", SixtyfourBitFlag::Yes)
        .value("No", SixtyfourBitFlag::No);
}