I suspect the only reliable way to convert between C++ generated messages
and protobuf-c messages is to serialize the message and then parse it back
into the other kind of message. You might also want to check out
MessageDifferencer
<https://github.com/protocolbuffers/protobuf/blob/f2cfe2c834a522ec553891451f7725c79bb57b09/src/google/protobuf/util/message_differencer.h#L120>
since that already does equality comparisons and diffing that sound similar
to what you are doing.

On Thu, Jul 11, 2019 at 11:18 PM Kiran Kumar <[email protected]>
wrote:

> I have written a C++ class for comparing two Google Protocol Buffer
> messages. It takes two GPB objects and returns whether the two GPB messages
> are exactly same or not. This class also has another API which returns even
> the attributes that got modified between the two messages. The C++ API
> (simple case of just return true/false) looks like below. It takes Google
> Protobuf base class "Message" objects as input. So this API can be called
> to compare any type of protobuf messages as long as firstMsg and secondMsg
> are of same type. i.e. can be used to compare message of type Student, or
> message of type Teacher.
>
>
> bool get_diff(google::protobuf::Message* firstMsg,
>                          google::protobuf::Message* secondMsg)
>
>
> This works fine for me to use from a C++ code. However, now I have a new
> use case where I need to call this API from a C code. My C code also has
> protobuf messages that are generated with protoc-c compiler. I am having
> difficulty in generating google::protobuf::Message from a protobuf-c
> message to call this API.
>
> Any suggestions on how to move forward ?
>
> --
> 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 post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/protobuf.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/ae2866da-ed59-4a23-a3fa-e68035e4359d%40googlegroups.com
> <https://groups.google.com/d/msgid/protobuf/ae2866da-ed59-4a23-a3fa-e68035e4359d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CADqAXr7g74jDD71ZXhEQ7aL9W85gwp%3DoY_V%3DoCju_4RQR_dgWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to