[protobuf] Re: question about creating message classes dynamically (known at runtime)

2009-11-16 Thread JC-MAD-SP
(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,

[protobuf] Re: question about creating message classes dynamically (known at runtime)

2009-11-16 Thread Kenton Varda
BTW, you could catch this problem more easily if you defined a down_cast function like: template To down_cast(From from) { #ifdef NDEBUG return static_cast(from); #else To result = dynamic_cast(from); assert(result != NULL); return result; #endif } This way, in debug mode you use RTTI to

[protobuf] Re: question about creating message classes dynamically (known at runtime)

2009-11-16 Thread Kenton Varda
On Mon, Nov 16, 2009 at 11:35 AM, JC-MAD-SP wrote: > ConcreteMessage* concreteMessage = reinterpret_cast > (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