I currently have a *.cpp
file where I import the needed *.proto.h
file and instantiate an object based on one of the messages(Heartbeat) from my *.proto
file. My goal is to use the set_value()
, SerializeToString()
, and ParseFromString()
.I've had success accomplishing the first two tasks. When using ParseFromString()
not output is produced to the screen. I'm pretty new to protobufs
so there may be something I'm overlooking. This is my code.
#include <iostream>
#include <fstream>
#include <string>
#include "cpnt.pb.h"
using namespace std;
int main()
{
wombat::HeartBeat h;
string m;
string t;
string v;
h.set_value(1);
v = h.SerializeToString(&m);
t = h.ParseFromString(v);
cout << "\n The message received is:" << h.value();
cout << "\n The binary data stored in v is:" << v;
cout << "\n The parsed data stored in t is:" << t <<::endl;
return 0;
}
And this is a printout of the output: