从protobuf-c对象转换为Protobuf C ++消息

时间:2019-07-12 06:16:40

标签: c++ protocol-buffers protoc protobuf-c

我编写了一个C ++类,用于比较两个Google Protocol Buffer消息。它接受两个GPB对象,并返回两个GPB消息是否完全相同。此类还具有另一个API,该API甚至返回在两条消息之间进行了修改的属性。 C ++ API(仅返回true / false的简单情况)如下所示。它将Google Protobuf基类“ Message”对象作为输入。因此,只要firstMsg和secondMsg是同一类型,就可以调用此API来比较任何类型的protobuf消息。即可以用来比较学生类型的消息或教师类型的消息。

bool get_diff(google::protobuf::Message* firstMsg,
                         google::protobuf::Message* secondMsg)

这对我来说可以在C ++代码中使用。但是,现在有一个新的用例,需要从C代码调用此API。我的C代码还具有由protoc-c编译器生成的protobuf消息。我很难从protobuf-c消息生成google :: protobuf :: Message来调用此API。

关于前进的任何建议?

0 个答案:

没有答案
相关问题