// Open the output file using std::ofstream
std::ofstream output_file(filename);
// Check if the file was successfully opened
if (!output_file.is_open()) {
std::cerr << "Failed to open the output file for writing." << std::endl;
return;
}
// Wrap the std::ofstream with OstreamOutputStream
google::protobuf::io::OstreamOutputStream ostream_output_stream(&output_file);
// Serialize the message in human-readable text format and write to the file
if (!google::protobuf::TextFormat::Print(model, &ostream_output_stream)) {
std::cerr << "Failed to serialize message to text format." << std::endl;
return;
}
std::cout << "Message successfully serialized to '" << filename << "' in human-readable format." << std::endl;
}
DumpPresolvedModelToPbtxt(model.Proto(), "presolved_model.pbtxt");