Hi,

This code works for me, it prints the same message twice :

[..]
   Protos::Core::Find findProto;
   findProto.set_tag(12345);
   findProto.mutable_peerid()->set_hash("plop");
   findProto.set_pattern("plop");

  logger->log(findProto.DebugString().data(), LogManager::Debug);

   std::string out;
   findProto.SerializeToString(&out);

   Protos::Core::Find findProto2;
   findProto2.ParseFromString(out);

  logger->log(findProto2.DebugString().data(), LogManager::Debug);
[..]

/Greg

On Oct 15, 5:40 pm, The_Glu <[email protected]> wrote:
> Hello,
>
> I use the following prototype :
>
> message Find {
>    required uint64 tag = 1;
>    required Common.Hash peerID = 2;
>    required string pattern = 3;
>
> }
>
> Now:
>
>    Protos::Core::Find findProto;
>    findProto.set_tag(9999);
>
> (findProto.tag() == 9999) is true.
>
> findProto.DebugString() return
>
>   tag: 9999
>   peerID {
>     hash: "323655354"
>   }
>   pattern: "coucou"
>   )
>
> Great isn't it ?
>
> But now, if I serialize and unserialize the prototype
>
>       std::string output;
>       findProto.SerializeToString(&output);
>
>       Protos::Core::Find findMessage;
>       findMessage.ParseFromString(output);
>
> What do I get ?
>
>   tag: 30064781071
>   peerID {
>     hash: "323655354"
>   }
>   pattern: "coucou"
>   )
>
> Why my tag changed oO ? It's not a random value, and it's works for
> small numbers.
>
> I tried to change the type of tag to uint32, int32, etc. always the
> same problem.
>
> Thanks for your help,
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to