C++ 如何将文本文件解析为C++;?

C++ 如何将文本文件解析为C++;?,c++,protocol-buffers,C++,Protocol Buffers,通常,我可以调用google::protobuf::TextFormat::Parse将prototxt文件解析为消息。但由于某种原因,我现在不得不使用MessageLite。由于TextFormat只接受Message*,因此转换失败。有什么方法可以做到这一点吗?这个MessageLite类有一个带有以下签名的ParseFromString成员 bool MessageLite::ParseFromString(const string & data) 这将解析字符串中包含的协议缓冲

通常,我可以调用
google::protobuf::TextFormat::Parse
将prototxt文件解析为
消息。但由于某种原因,我现在不得不使用
MessageLite
。由于TextFormat只接受Message*,因此转换失败。有什么方法可以做到这一点吗?

这个
MessageLite
类有一个带有以下签名的
ParseFromString
成员

bool MessageLite::ParseFromString(const string & data)
这将解析字符串中包含的协议缓冲区。
有关更多详细信息,请参阅
我猜你被否决了,因为
TextFormat::Parse
的文档说,当你没有
Message
而是
MessageLite
时,要使用
MessageLite::ParseFromString
。不过,将@P.W答案标记为答案是礼貌的。