So after parsing, the message is just empty? The first thing I would do is double-check that SerializeToString() and ParseFromString() are returning true and also verify that the length of the serialized string is reasonable.
On Wed, May 29, 2019 at 9:48 AM Boris Pitel <[email protected]> wrote: > Ok, let me explain. I have a class let's call it PriceTicObjectSet. This > class is a wrapper around protobuf class. This PriceTicObjectSet has member > variables which are directly point to protobuf class variables - just > setters and getters. Function toString is for convenience only, all it does > it is dumps the content of the instance of PriceTicObjectSet. Its > implementation is like : > ..... > if ( name_internal != NULL ) toReturn += ("name=" + name_internal->value() > ); > .... > > in other words toString() is just not essential here. We could just use > debugger and see that after ParseFromString the object doesn't change at > all. > > Sorry for not being clear. > > Thanks, > > -Boris > > > On Wednesday, May 29, 2019 at 12:15:02 PM UTC-4, Adam Cozzette wrote: >> >> Could you provide some more details on what that function does and what >> its outputting? Without that it is hard to know what the problem is. >> >> On Wed, May 29, 2019 at 8:04 AM Boris Pitel <[email protected]> wrote: >> >>> toString is just a function which dumps the object ( PriceTicObjectSet ) >>> - PriceTicObjectSet is just a very thin wrapper around protobuf class. I >>> use toString to see the content of the message. >>> >>> -Boris >>> >>> On Wednesday, May 29, 2019 at 10:40:02 AM UTC-4, Adam Cozzette wrote: >>>> >>>> What does your toString() function do? >>>> >>>> On Wed, May 29, 2019 at 7:32 AM Boris Pitel <[email protected]> wrote: >>>> >>>>> Hello team, >>>>> I am new to C++ protobuf. library. >>>>> I experience following difficulty. >>>>> I have an pObj, i serialize it using SerializeToString, then as a test >>>>> i try to deserialize the string using ParseFromString. I expect that after >>>>> deserialization the object will contain the same data as original pObj. It >>>>> doesn't happen. The new object contains nulls. The ParseFromString return >>>>> true. Here is the pseudo-code: >>>>> >>>>> string body; >>>>> int n1 = pObj->_objectSetType.ByteSizeLong(); >>>>> result = pObj->_objectSetType.SerializeToString(&body); >>>>> PriceTicObjectSet* pnewObj = new PriceTicObjectSet; >>>>> result = pnewObj->_objectSetType.ParseFromString(body); >>>>> >>>>> string dump1 = toString(pObj); >>>>> printf("Dump1:\n%s\n", dump1.c_str()); >>>>> string dump2 = toString(pnewObj); >>>>> printf("Dump2:\n%s\n", dump2.c_str()); >>>>> >>>>> >>>>> Again, I expect that after deserialization objects pObj and pnewObj >>>>> contain same data. >>>>> This issue puzzles me and it is really important to solve it. >>>>> >>>>> Please can somebody help me - probably I am doing something wrong. >>>>> >>>>> Thank you >>>>> >>>>> Boris Pitel >>>>> >>>>> -- >>>>> 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 [email protected]. >>>>> To post to this group, send email to [email protected]. >>>>> Visit this group at https://groups.google.com/group/protobuf. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/protobuf/dfae067f-71ec-4550-b18e-aa8aabab0af2%40googlegroups.com >>>>> <https://groups.google.com/d/msgid/protobuf/dfae067f-71ec-4550-b18e-aa8aabab0af2%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>> On Wednesday, May 29, 2019 at 10:40:02 AM UTC-4, Adam Cozzette wrote: >>>> >>>> What does your toString() function do? >>>> >>>> On Wed, May 29, 2019 at 7:32 AM Boris Pitel <[email protected]> wrote: >>>> >>>>> Hello team, >>>>> I am new to C++ protobuf. library. >>>>> I experience following difficulty. >>>>> I have an pObj, i serialize it using SerializeToString, then as a test >>>>> i try to deserialize the string using ParseFromString. I expect that after >>>>> deserialization the object will contain the same data as original pObj. It >>>>> doesn't happen. The new object contains nulls. The ParseFromString return >>>>> true. Here is the pseudo-code: >>>>> >>>>> string body; >>>>> int n1 = pObj->_objectSetType.ByteSizeLong(); >>>>> result = pObj->_objectSetType.SerializeToString(&body); >>>>> PriceTicObjectSet* pnewObj = new PriceTicObjectSet; >>>>> result = pnewObj->_objectSetType.ParseFromString(body); >>>>> >>>>> string dump1 = toString(pObj); >>>>> printf("Dump1:\n%s\n", dump1.c_str()); >>>>> string dump2 = toString(pnewObj); >>>>> printf("Dump2:\n%s\n", dump2.c_str()); >>>>> >>>>> >>>>> Again, I expect that after deserialization objects pObj and pnewObj >>>>> contain same data. >>>>> This issue puzzles me and it is really important to solve it. >>>>> >>>>> Please can somebody help me - probably I am doing something wrong. >>>>> >>>>> Thank you >>>>> >>>>> Boris Pitel >>>>> >>>>> -- >>>>> 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 [email protected]. >>>>> To post to this group, send email to [email protected]. >>>>> Visit this group at https://groups.google.com/group/protobuf. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/protobuf/dfae067f-71ec-4550-b18e-aa8aabab0af2%40googlegroups.com >>>>> <https://groups.google.com/d/msgid/protobuf/dfae067f-71ec-4550-b18e-aa8aabab0af2%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> 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 [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at https://groups.google.com/group/protobuf. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/protobuf/d3e71b81-66db-48d9-8cc3-640aee92919a%40googlegroups.com >>> <https://groups.google.com/d/msgid/protobuf/d3e71b81-66db-48d9-8cc3-640aee92919a%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/protobuf. > To view this discussion on the web visit > https://groups.google.com/d/msgid/protobuf/bb594c06-2d62-46b6-9f53-b65f26af4dd8%40googlegroups.com > <https://groups.google.com/d/msgid/protobuf/bb594c06-2d62-46b6-9f53-b65f26af4dd8%40googlegroups.com?utm_medium=email&utm_source=footer> > . > 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/protobuf. To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/CADqAXr7P52B-gy0kBp5NEPB5Dq0USvytTOs8gm%2Bb8F1ccBAmjQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
