ffig icon indicating copy to clipboard operation
ffig copied to clipboard

Add template to generate protocol buffers

Open compiletime opened this issue 7 years ago • 3 comments

Given the C++ type:

struct Data {
  std::string x;
  int y;
  std::vector<int> z;
};

Generate a .proto file including (assuming 64 bit):

message Data {
  required string x = 1;
  required int64 y = 2;
  repeated int64 z = 3;
}

Generate a .h file including:

std::vector<std::byte> serialize(Data);

std::optional<Data> deserialize(std::vector<std::byte>);

compiletime avatar Nov 07 '17 06:11 compiletime

I'm unconvinced that there's any point in this.

protobuffers allow one to specify an exchange format from a .proto file. C++, C#, Python etc can be generated from the .proto file by protoc. I'm not sure how FFIG would fit into this picture.

I'd favour closing this issue as "Will not fix".

jbcoe avatar Jan 25 '18 09:01 jbcoe

I've updated the description to give an example of what this might do. I opened this alongside https://github.com/FFIG/ffig/issues/306, with the intent of using FFIG to automate writing serialization and deserialization.

I hadn't given any thought to how protobuf interacts with other languages. Mostly I meant to use it for its binary serialization.

compiletime avatar Jan 25 '18 21:01 compiletime

Would adding support for some sort of serialization achieve the same goal?

jbcoe avatar Jan 25 '18 22:01 jbcoe