[protobuf] Re: Dynamically determine the type of a message

2013-02-25 Thread Jeremy Swigart
What about something like this message UnknownMessage { enum MessageType { MESSAGE_TYPE_A = 1; MESSAGE_TYPE_B = 2; MESSAGE_TYPE_C = 3; } required MessageTypemsgType = 1; required bytesmsgPayload = 2; } On Wednesday, February 10, 2

[protobuf] Re: Dynamically determine the type of a message

2010-03-04 Thread Gonzo
On Feb 11, 5:44 pm, alexrichard...@gmail.com wrote: > > Union types in combination with 'extensions' seems like the right solution   > for this problem in almost all cases, whether the number of message types   > is large or small. I am trying to solve a similar problem. Can anybody point me to a

Re: [protobuf] Re: Dynamically determine the type of a message

2010-02-11 Thread Evan Jones
On Feb 11, 2010, at 15:44 , alexrichard...@gmail.com wrote: Are there known issues which arise from a union type with a large number of extensions? The problem that concerns me is that I need to have unique extension ids. This seems difficult when using Protocol Buffers as an RPC system, u

Re: Re: [protobuf] Re: Dynamically determine the type of a message

2010-02-11 Thread alexrichardson
... I think union types are the best choice for a "small" number of possible messages. However, if you really need to support *any* type of message, you could consider adding a "header" message of a known type that includes the fully-qualified message name as returned by message->GetDescr

Re: [protobuf] Re: Dynamically determine the type of a message

2010-02-11 Thread Evan Jones
fokenrute wrote: Ok, so, I will likely opt for Enum Types. Thanks for answering. I think union types are the best choice for a "small" number of possible messages. However, if you really need to support *any* type of message, you could consider adding a "header" message of a known type that

[protobuf] Re: Dynamically determine the type of a message

2010-02-11 Thread Alessandro Bellina
Every message has a descriptor object associated. Look in the c++ API reference (http://code.google.com/apis/protocolbuffers/docs/reference/ cpp/index.html) for it. Once you get the descriptor, you can get a string type by calling name(). On Feb 10, 5:02 pm, fokenrute wrote: > Hi, I'm developing

[protobuf] Re: Dynamically determine the type of a message

2010-02-10 Thread fokenrute
> That's not possible.  Serialized messages do not identify their own type. Ok, so, I will likely opt for Enum Types. Thanks for answering. -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to proto...@google

Re: [protobuf] Re: Dynamically determine the type of a message

2010-02-10 Thread Kenton Varda
On Wed, Feb 10, 2010 at 3:57 PM, fokenrute wrote: > I just > need something that takes a buffer (char[] which contains bytes of the > message) as an input and return the message type. That's not possible. Serialized messages do not identify their own type. -- You received this message becaus

[protobuf] Re: Dynamically determine the type of a message

2010-02-10 Thread fokenrute
> See the techniques section on Union Types: > > http://code.google.com/apis/protocolbuffers/docs/techniques.html#union I read the link you pointed to me, and it appears that Union Types are not generic enough to suit my needs. Self Describing Messages seems more like what I need, but they appears