Search code examples
c++protocol-buffersconfiguration-files

protobuf for configuration files


Related to using protobuf as a textual configuraton file I'd like to use protobuf for configuration file.

I expect that protobuf allows me to use simple parser with exact structure.

My configuration structure looks like

//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];
}

And bunch of different items in config files like

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

What's the best way for organizing that?


Solution

  • You may write config file like:

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

    So I think that you must use ':' instead of '=', and "do not" write the items wrapped in the brackets.