On Mon, May 4, 2015 at 11:36 PM, Jan Kyjovský <jan.kyjov...@tieto.com>
> so we are somehow back in game. And now I am getting familiar what I have
> done more then half a year ago.
> So for now I got some basic structure of code that will later be as a
> starting point for real implementation. I am trying to do some simple
> experiments to see how it works. Though I got problem that even if I get
> descriptor I am not getting any data. I have used example from encoding
> specification since I needed something really simple.
> const Descriptor* descriptor =
> if (descriptor == NULL)
> DynamicMessageFactory factory;
> Message *message = factory.GetPrototype(descriptor)->New();
> // Use the message object for parsing/etc.
> std::string input_data = "089601";
ParseFromString() expects protobuf binary format data (stored in a C++
string), which I believe 089601 is not.
You could check the return value of ParseFromString() to see whether the
parsing is a success.
> // Access a specific field in the message
> for (int i = 0; i < descriptor->field_count(); i++)
> const FieldDescriptor* field = descriptor->field(i);
> switch (field->type())
> case FieldDescriptor::TYPE_INT32:
> int nVal =
> message->GetReflection()->GetInt32(*message, field);
> printf("%d\n", nVal);
> But from reflection I am getting that value is 0. So either I have wrongly
> set input data considering that I misunderstand format or there is
> something else. Do you have any idea what may be cause?
> Thank you in advance for your reply.
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To post to this group, send email to email@example.com.
> Visit this group at http://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
To post to this group, send email to firstname.lastname@example.org.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.