c++ - 配置文件的protobuf

标签 c++ protocol-buffers configuration-files

using protobuf as a textual configuraton file相关我想使用 protobuf 作为配置文件。

我希望 protobuf 允许我使用具有精确结构的简单解析器。

我的配置结构是这样的

//my.proto    
package my_config; 

message MyConfigItem {
  required string type = 1;
  required string name = 2;
  repeated string inputNames = 3 [packed=true];
  repeated string outputNames = 4 [packed=true];
}

还有配置文件中的一堆不同的项目,比如

MyConfigItem {
  type = "type1";
  name = "name1";
  inputNames = {"input1", "input2"};
}

什么是最好的组织方式?

最佳答案

你可以这样写配置文件:

  type : "type1"
  name : "name1"
  inputNames : {"input1", "input2"}

所以我认为你必须使用':'而不是'=',并且“不要”写括号中的项目。

关于c++ - 配置文件的protobuf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42652009/

相关文章:

c++ - 将数字与 NaN 进行比较的结果是什么?

c++ - 如何更改 QTimeEdit 的步长?

c++ - 无法在 gRPC 中使用 proto 3.0 缓冲区生成客户端代码

python - 使用配置文件打包 Python 应用程序

asp.net - 配置部分 'system.web/httpModules' 已定义。每个配置文件中的部分只能出现一次。请参阅帮助主题 <位置> 了解异常(exception)情况

c++ - 调用信号的函数堆栈内存和函数控制会发生什么

c++ - 在函数外访问堆栈对象

c# - 对 C# 和 C++ 项目使用相同的 .proto 文件

java - protobuf RPC结构(嵌入式ARM)

asp.net - 使用 NInject 连接依赖项的选项