On Sun, Sep 6, 2009 at 9:46 AM, Jesper Eskilson <[email protected]> wrote:

> On Thu, Sep 3, 2009 at 6:56 PM, Kenton Varda<[email protected]> wrote:
> > You want:
> >   const UnknownFieldSet& set =
> cmd.GetReflection()->GetUnknownFields(cmd);
>
> Ok, so if I have function which receives a message which as an unknown
> field which I need to parse into a "real" message, how should I do?
> (The documentation is a little fuzzy on this...)
>
> I tried to call ParseFromString() on the string returned by
> length_delimited(), but that just crashed.
>
>  const UnknownFieldSet& set = cmd.unknown_fields();
>   const UnknownField f = set.field(0);
>

This also needs to be a const reference.  I guess I forgot to explicitly
declare UnknownField uncopyable, so the compiler is generating a default
copy constructor, which indeed would crash in this case.  Please do not
assume that protobuf classes are copyable unless they explicitly say that
they are.


>  const std::string &buf = f.length_delimited();
>
>  listwindow::ListWindowCommand lwc;
>  lwc.ParseFromString(buf);
>
> --
> /Jesper
>

--~--~---------~--~----~------------~-------~--~----~
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