I want to serialize my protocol buffer to a char*. Is this possible? I know one can serialize to file as per:
fstream output("/home/eamorr/test.bin", ios::out | ios::trunc | ios::binary);
if (!address_book.SerializeToOstream(&output)) {
cerr << "Failed to write address book." << endl;
return -1;
}
But I’d like to serialize to a C-style char* for transmission across a network.
How to do this? Please bear in mind that I’m very new to C++.
That’s easy:
Check documentation of MessageLite class also, it’s parent class of Message and it contains useful methods.