简体   繁体   English

创建带有特殊字符的 protobuf 枚举

[英]Creating a protobuf Enum with Especial characters

I need to create an Enum in a proto3 file, and it needs to has the following strings as options:我需要在 proto3 文件中创建一个 Enum,它需要具有以下字符串作为选项:

"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" “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?有人可以帮我吗?

ProtobufEnums map constants to (recommended) unsigned ints. Protobuf枚举map 常量为(推荐的)无符号整数。

If I understand correctly, you want to be able to receive a float (?) value and map this onto an integer.如果我理解正确,您希望能够接收一个浮点(?)值和 map 这个到 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.您的 Protobuf 消息应包含一个float类型的字段,用于传入值,并且您的代码 (.) 将需要 map 将范围转换为您想要的 integer 值(桶),或者,您的代码将需要执行此映射并使用(也许) uint32作为 Protobuf 消息字段值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM