以文本模式将消息写入给定文件
Write a message to a given file in text mode
请给我一个例子如何在谷歌协议缓冲区文本模式(不是二进制模式)写消息到给定的文件。
message S1
{
required string name=1;
required string family=2;
}
message S2
{
repeated S1;
}
如果使用此代码在文件中写入消息,如何从文件中读取文本格式?DebugString();
这很简单,使用Message::DebugString()
函数:
S2 s2;
std::ofstream out("S2.txt");
out << s2.DebugString();
相关文章:
- C++入门 5 版:类消息和文件夹
- 如何将消息时间戳写入日志文件?
- 避免使用 boost::进程间::消息队列创建文件
- 可以将Boost消息队列文件重定向到用户指定的位置
- 在 BMP 文件中查找隐藏的消息
- 有没有办法在不使用 set_buff() 的情况下从文件中读取并填充消息增益
- 将断言消息写入日志文件
- Visual Studio在发布模式下构建,但用户收到消息说他们需要调试文件
- 如何在消息文件中获取用户定义的字段
- 忽略来自 GDB(终端)中的包含/库文件的调试消息
- 如何从命令行运行可执行文件时启用系统错误消息
- C++ protobuf:如何通过"SerializeToOstream()"将多条消息写入文件
- 是否有 G++ 7.2 选项在使用预编译头文件时发出消息?
- 在.c文件接收函数中使用Linux中的MSGGET创建消息队列未实现错误
- 烦人的错误消息:无法合并以前的GCDA文件
- 包含类文件后的错误消息(多个定义的符号)
- 将PCAP文件解析至C 中的sip消息
- 如何加密用用户输入的文件写的消息
- 如何将多个协议缓冲区的消息写入可附加的压缩文件中?
- 从DLL文件调用消息框函数时出现奇怪的字符