通常,我可以调用google::protobuf::TextFormat::Parse
来将原型文件解析为Message
。但是由于某种原因,现在我不得不使用MessageLite
。由于TextFormat仅采用Message *,因此转换失败。有什么办法吗?
答案 0 :(得分:0)
MessageLite
类具有一个带有以下签名的ParseFromString
成员。
bool MessageLite::ParseFromString(const string & data)
这将解析字符串中包含的协议缓冲区。
有关更多详细信息,您可以参考
到documentation上。