Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int ScoreWrite(string output_pbuf, OverallScores overall, MetaInfo minfo)
- {
- DLOG("SCOR: start ScoreWrite()");
- hlcam::communication::scores::ScoreBook score_book;
- /*{ fstream input(output_pbuf.c_str(), ios::in | ios::binary);
- if(!input)
- { cout << " File not found, creating new one." << endl;
- }
- else if(!score_book.ParseFromIstream(&input))
- { cerr << "Failed to parse score book." << endl;
- return -1;
- }
- }*/
- DLOG("pushing data into protobuf");
- GetDataToPbuf(&score_book, overall, minfo);
- fstream output(output_pbuf.c_str(), ios::out | ios::trunc | ios::binary);
- if(!output)
- {
- DLOG("SCOR: Failed to open output file: %s.", output_pbuf.c_str());
- cerr << "SCOR: Failed to open output file: "<<output_pbuf.c_str() <<" ."<<endl;
- return -1;
- }
- DLOG("File opened for writing");
- if(!score_book.SerializeToOstream(&output))
- {
- DLOG("Failed to serialize data to stream");
- cerr << "Failed to write score book." << endl;
- return -1;
- }
- DLOG("shutting down protobuf");
- google::protobuf::ShutdownProtobufLibrary();
- DLOG("shutdown of protobuf successul");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement