Last active
June 5, 2017 08:12
-
-
Save dmi3coder/97c7ab1cd36513e5198fc1d4f873c1a1 to your computer and use it in GitHub Desktop.
c++ protbuf object to bytes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol::Note note = protocol::Note(); | |
string name = "Buy vegetable"; | |
string cafel = "-Apple\n-Pomodoro\n-Avocado"; | |
note.set_name(name); | |
note.set_content(cafel); | |
note.set_id(1); | |
note.set_type(protocol::NoteType::BASIC); | |
Envelope envelope = createEnvelope(¬e); | |
int size = envelope.ByteSize(); | |
char* array = new char[size]; | |
envelope.SerializeToArray(array, size); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment