I have a program that serializes data with Protobuf in Java, by writing binary data in a byte[] Array and then saving it in ".txt" file. I am receiving that data on the C++ side in a stringstream. Now I want to parse that binary data with C++, but the Protobuf-Parsing-Method "parseFromString()" doesn't work! The fields from my Test Message are not set. I wrote a little test for that and I can show you some code:
Java Serialization
byte[] s = test.build().toByteArray(); //This is serialized to "C:\test.txt" as binary
C++ Parsing:
Test t1; // My Protobuf Message
std::ifstream myFile("C:\\test.txt");
std::string s;
myFile >> s;
t1.ParseFromString(s);
std::cout << "Decoded: " << t2.s() << std::endl; // Check if parsing was correct
But it just returns: " Decoded: ", as if t2 was empty, but it shouldn't be! How can you parse binary data in C++?