Skip to content

Instantly share code, notes, and snippets.

@dmi3coder
Last active June 5, 2017 08:12
Show Gist options
  • Save dmi3coder/97c7ab1cd36513e5198fc1d4f873c1a1 to your computer and use it in GitHub Desktop.
Save dmi3coder/97c7ab1cd36513e5198fc1d4f873c1a1 to your computer and use it in GitHub Desktop.
c++ protbuf object to bytes
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(&note);
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