What language are you working in? I don't think any copying is necessary, you can just build Msg like you would any other message and set the value of type to m1 or m2.
On Friday, December 9, 2022 at 8:40:16 AM UTC-8 [email protected] wrote: > I have protobuf: > message Msg > { > oneof type { > Msg1 msg1 = 1; > Msg2 msg2 = 2; > Msg3 msg3 = 3; > .... > } > }; > > Is it possible to fill Msg with protobuf::Message from one of msgs? > Like: > > msg1 m1; > //fill m1; > f(&m1); > > msg2 m2; > //fill m2; > f(&m2); > ... > > void f(google::protobuf::Message *m) > { > Msg mainMessage; > // fill mainMessage with data from m correctly? <--- > } > > I tried CopyFrom but it doesn't work in this case. > > Thank you. > > > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/1bcbeb65-6b29-457d-8303-27014c63585cn%40googlegroups.com.
