libcluon icon indicating copy to clipboard operation
libcluon copied to clipboard

Feature request/clarification - C++ generated enum of message types

Open Expan75 opened this issue 10 months ago • 1 comments

Hi!

Thank you for open sourcing! Looking over unpacking, I was wondering if there's a way of outputting an enum alongside the generated C++ header for the message?

cluon::OD4Session od4(111,
    [](cluon::data::Envelope &&envelope) noexcept {
      if (envelope.dataType() == 2001) {
        MyTestMessage1 receivedMsg = cluon::extractMessage<MyTestMessage1>(std::move(envelope));

        PrimeChecker pc;
        std::cout << receivedMsg.myValue() << " is" 
          << (pc.isPrime(receivedMsg.myValue()) ? " " : " not ")
          << "a prime." << std::endl;
      }
    });

^Use case would be to swap out 2001 with an enum that's generated. Ideally this enum would also be present as generated proto enum (which I think is represented in the protobuf spec? If not, forgive my ignorance!). When I follow the docs the message id gets added as comments in the .proto file.

Cheers!

// Erik

Expan75 avatar Mar 26 '24 16:03 Expan75