ffig
ffig copied to clipboard
Add template to generate protocol buffers
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>);
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".
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.
Would adding support for some sort of serialization achieve the same goal?