c++ - 在 C++ 协议缓冲区中具有相同类型的一个
问题描述
我有这样的消息:
message Foo {
oneof Value {
string a;
string b;
string c;
string d;
string e;
}
}
如何oneof
通过避免编写如下内容来写入然后读取字段:
if (choose_a)
write a
else if (choose_b)
write b
...
if (a is set)
read from a
else if (b is set)
read from b
...
解决方案
推荐阅读
- python - jupyter notebook 上的 Turicreate 无法识别
- flutter - 在颤振中检查连接并根据连接状态更改状态
- google-directions-api - 将请求路线航点与响应匹配
- javascript - 如何将变量放在内联 javascript [[]] api 路径中
- c# - WPF WebBrowser 控件不再显示 PDF (.NET5 Acrobat Reader ActiveX)
- r - 在 Rd 文件中保留空格
- arrays - 在 Julia 中按元组索引数组?
- java - 任务“:app:dataBindingMergeDependencyArtifactsDebug”执行失败
- mongodb - spring-data-mongodb 中的季度查询
- java - Spring 在 application.yml 中启用 SQL 日志