Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Protocol buffers 从文件中将protobuf消息作为字符串读取时出错_Protocol Buffers - Fatal编程技术网

Protocol buffers 从文件中将protobuf消息作为字符串读取时出错

Protocol buffers 从文件中将protobuf消息作为字符串读取时出错,protocol-buffers,Protocol Buffers,我打算从文件中读取protobuf数据,并在代码中使用它。我试着做一些逆向工程,把数据填入我的文件中,并在日志文件中将字符串哑化。我现在读取这个日志文件,更改字段的值,并使用文件处理以字符串形式读取它。然而,它似乎不起作用。我的代码有问题吗 std::ifstream myprotobuf("/root/testfile.txt", std::ios::in | std::ios::binary); if (myprotobuf) { std::string string_in_file

我打算从文件中读取protobuf数据,并在代码中使用它。我试着做一些逆向工程,把数据填入我的文件中,并在日志文件中将字符串哑化。我现在读取这个日志文件,更改字段的值,并使用文件处理以字符串形式读取它。然而,它似乎不起作用。我的代码有问题吗

std::ifstream myprotobuf("/root/testfile.txt", std::ios::in | std::ios::binary);
if (myprotobuf)
{
    std::string string_in_file;
    myprotobuf.seekg(0, std::ios::end);
    contents.resize(myprotobuf.tellg());
    myprotobuf.seekg(0, std::ios::beg);
    myprotobuf.read(&string_in_file[0], contents.size());
    myprotobuf.close();
    RealMsg -> ParseFromString (string_in_file);
}


您应该提供更多信息,例如:1)它是如何工作的,2)testfile中实际的.proto定义和数据是什么。