How to read partial message types generically from one proto to another proto.

89 views
Skip to first unread message

Manish Sharma

unread,
Aug 10, 2022, 6:52:08 PM8/10/22
to Protocol Buffers
I am trying to add a functionality to only save a small set of messages that are defined in a huge proto, where the definition of small set of messages will be defined by this another proto that the users will declare.

Example:

message LargeProto {
  optional int32 id = 1;     
  optional Type type = 2;
  optional Image img1 = 3;
  optional Image img2 = 4;
}

message SmallProto1 {
  optional int32 id = 1;     
  optional Type type = 2;
  optional Image img1 = 3;
}

message SmallProto2 {
  optional int32 id = 1;     
  optional Type type = 2;
  optional Image img2 = 4;
}

SmallProto1 = readFrom(LargeProto lp);
SmallProto2 = readFrom(LargeProto lp);


Do we have an already existing functionality that will allow us to only read specific messages from one proto to another proto without hardcoding all this in C++? Do we have some form of generic implementation available to do something as above?

Manish Sharma

unread,
Aug 10, 2022, 6:53:05 PM8/10/22
to Protocol Buffers
Correction

SmallProto1 pr1 = readFrom(LargeProto lp);
SmallProto2 pr2 = readFrom(LargeProto lp);
Reply all
Reply to author
Forward
0 new messages