(I think my previous reply didn't arrive)

Thanks Kenton, this worked fine for me.

Probably, with DynamicMessageFactory I was trying to solve in a single
attempt, dynamic generation of both classes known in compile-time and
unknown. I forgot then to check back again with MessageFactory. I
guess, that I have learned the lesson about MessageFactory and
DynamicMessageFactory differences :)

Thanks again for your help. I appreciate it

regards




On Nov 16, 8:48 pm, Kenton Varda <ken...@google.com> wrote:
> BTW, you could catch this problem more easily if you defined a down_cast
> function like:
>
> template <typename To, typename From>
> To down_cast(From from) {
> #ifdef NDEBUG
>   return static_cast<To>(from);
> #else
>   To result = dynamic_cast<To>(from);
>   assert(result != NULL);
>   return result;
> #endif
>
> }
>
> This way, in debug mode you use RTTI to verifythat the down_cast is valid,
> but in release builds you get static cast performance.
>
> google/protobuf/stubs/common.h contains such an implementation of down_cast,
> although you should not use the protobuf version directly since we may
> decide to change it in the future.  Instead, copy it into your own code.
>
> On Mon, Nov 16, 2009 at 11:44 AM, Kenton Varda <ken...@google.com> wrote:
> > On Mon, Nov 16, 2009 at 11:35 AM, JC-MAD-SP 
> > <public.cebal...@gmail.com>wrote:
>
> >> ConcreteMessage* concreteMessage = reinterpret_cast<ConcreteMessage*>
> >> (mesage->New());
>
> > This line is invalid.  Here, *message is a DynamicMessage, and New() also
> > returns a DynamicMessage, not a ConcreteMessage.  DynamicMessage is a class
> > which implements the Message interface to look like any arbitrary
> > descriptor.  This allows you to represent types which are not compiled into
> > the binary at all.
>
> > If you want to construct instances of compiled-in types from their
> > descriptors, you want to use MessageFactory::generated_factory().
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to