It looks like whenever I call ParseFromArray it returns false, even if
the message seems to properly be set...
Here is a code example to illustrate the issue:
#include <iostream>
#include "iceDetection.pb.h"
using namespace std;
int main(int argc, char *argv[])
{
char buffer[4*1024];
cout << "ProtoBuf Eval";
iceData my_IceDataSent;
iceData my_IceDataReceived;
my_IceDataSent.set_avgthickness(1.23);
my_IceDataSent.set_maxthickness(2.23);
my_IceDataSent.set_minthickness(0.23);
cout << "This is what I sent: avgthickness=" <<
my_IceDataSent.avgthickness() << " maxthickness=" <<
my_IceDataSent.maxthickness() << " minthickness=" <<
my_IceDataSent.minthickness();
memset(buffer, 0, sizeof(buffer));
if(true == my_IceDataSent.SerializeToArray(buffer, sizeof(buffer)))
{
cout << "\nSerialization succeeded";
if(true == my_IceDataReceived.ParseFromArray(buffer, sizeof(buffer)))
{
cout << "\nParsing succeeded";
cout << "This is what I received: avgthickness=" <<
my_IceDataReceived.avgthickness() << " maxthickness=" <<
my_IceDataReceived.maxthickness() << " minthickness=" <<
my_IceDataReceived.minthickness();
}
else
{
cout << "\nParsing failed";
}
}
else
{
cout << "\nSerialization failed";
}
return 0;
} // main
ParseFromArray always returns false, however my_IceDataReceived seems
to contain the values encoded in my_IceDataSent.
Any ideas?
Thanks!
On 7/23/08, Jean-Sebastien Stoezel <js.st...@gmail.com> wrote:
> Hi,
>
> when calling ParseFromArray, why pass the size of the object as an
> argument then, since it looks like this will always be whatever
> ByteSize() returns (please correct me if I'm wrong). Can't ByteSize()
> be access from within ParseFromArray()?