谷歌协议缓冲区,如何设置自定义类型的字段?

时间:2012-09-02 10:40:14

标签: c++ protocol-buffers

我有这样的原型文件:

message Control {

    message KeyStatus {
        required bool keyUp = 1;
        required bool keyDown = 2;
        required bool keyLeft = 3;
        required bool keyRight = 4;
    }

    message MouseClick {
        required double x = 1;
        required double y = 2;
        optional bool buttonRight = 3;
    }

    required KeyStatus keyStatus = 1;
    required double angle = 2;
    optional MouseClick mouseClick = 3;
}

在生成的代码中,没有方法set_keystatusset_mouseclick,只有set_angle。我怎样才能设置keystatus?

1 个答案:

答案 0 :(得分:2)

您是否阅读过the documentation?例如,尝试使用mutable_keystatus()方法。