0

I need to create an Enum in a proto3 file, and it needs to has the following strings as options:

"0,01_200", "200,01_500", "500,01_1.000", "1.000,01_3.000", "3.000,01_10.000", 10.000,01_30.000, "30.000,01_100.000"

I tried something like this:

enum enumRangeTransactionCategory {
    0,01_200 = 0;
    200,01_500 = 1;
    500,01_1.000 = 2;
    1.000,01_3.000 = 3;
    3.000,01_10.000 = 4;
    10.000,01_30.000 = 5;
    30.000,01_100.000 = 6;
}

But did not work.

Could anyone help me?

lucas
  • 79
  • 6

1 Answers1

0

Protobuf Enums map constants to (recommended) unsigned ints.

If I understand correctly, you want to be able to receive a float (?) value and map this onto an integer.

Your Protobuf Message should include a field of type float for the incoming value and your code (!) will need to map the ranges onto the integer values (buckets) that you want. Alternatively, your code will need to perform this mapping and use (perhaps) uint32 as the Protobuf Message field value.

DazWilkin
  • 32,823
  • 5
  • 47
  • 88
  • I want to be able to receive a string, one of these options: "0,01_200", "200,01_500", "500,01_1.000", "1.000,01_3.000", "3.000,01_10.000", 10.000,01_30.000, "30.000,01_100.000". – lucas Dec 16 '21 at 16:38