I have the following protoc file:
message DataChunk{
required bool isHash=1;
required int64 hash=2;
required string data=3;
}
message responseBody{
repeated DataChunk dataChunk=1;
}
And I have the following C++ function:
void eamorr(string data){ //data is a protocol buffer stream converted to a string
responseBody rb;
rb=some_function_of(data); //what to do here?
}
The string “data” was created using:
...
std::ostringstream stream;
rb.SerializeToOstream(&stream);
string protobufStream = stream.str();
...
My question is: how do I convert a string to a protoc object so I can access the member elements? Please bear in mind that I’m very new to C++.
You can use