On Thu, Jan 14, 2016 at 1:19 PM, Alfred Kwan <[email protected]> wrote:

> I would like to check (via reflection) whether a particular field within a
> oneof. This is the example message:
>
> message Foo {
>    oneof Bar {
>       int32 A = 1;
>       string B = 2;
>    }
> }
>
>
>
> I browse through the .h and it seems like the only plausible check is to
> examine it via Foo.GetReflection->HasOneof(), but I found it hardcoded as
> false in message.h:
>
> class LIBPROTOBUF_EXPORT Reflection {
>  public:
>  ...
>   // Check if the oneof is set. Returns true if any field in oneof
>   // is set, false otherwise.
>   // TODO(jieluo) - make it pure virtual after updating all
>   // the subclasses.
>   virtual bool HasOneof(const Message& /*message*/,
>                         const OneofDescriptor* /*oneof_descriptor*/) const
> {
>     return false;
>   }
>  ...
> }
>
> Am I missing something?
>
This is a virtual function. It's overridden by its subclasses.


> --
> 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.
> 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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to