Skip to content

Commit

Permalink
~ json <=> proto binary
Browse files Browse the repository at this point in the history
  • Loading branch information
su committed Oct 10, 2017
1 parent 6ead5d1 commit a8d2f78
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ProtoBufTool/ProtobufThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void ProtobufThread::run()
const google::protobuf::Message *message = factory.GetPrototype(descriptor);
google::protobuf::Message *msg = message->New();

std::ifstream in;
google::protobuf::ifstream in;
in.open(binaryMessageName, std::ios::in | std::ios::binary);
if (in.is_open()) {
msg->ParseFromIstream(&in);
Expand Down Expand Up @@ -159,8 +159,9 @@ void ProtobufThread::run()
if (convertStatus.ok()) {
qDebug()<<"convertStatus.ok()";
_outBinaryFilePath = "./outStream.message";
std::ofstream ostram(_outBinaryFilePath.toStdString(),std::ios::binary);
if(!msg->SerializeToOstream(&ostram)){
google::protobuf::ofstream ofs(_outBinaryFilePath.toStdString(),ios::out |ios::binary);
//std::ofstream ostram(_outBinaryFilePath.toStdString(),std::ios::binary);
if(!msg->SerializeToOstream(&ofs)){
setLastError("导出地图错误: "+QString::fromStdString(msg->DebugString()));
}
// setMsgByteArray(QByteArray::fromStdString(msg->SerializeToOstream()));
Expand Down

0 comments on commit a8d2f78

Please sign in to comment.