Nope, there's no easier way. Message objects do not contain pointers to their parents, so you have to remember what message objects you traversed through as you traverse them.
On Mon, Jun 1, 2009 at 9:09 PM, Ajoy Frank <ajo...@gmail.com> wrote: > The protos would be a chain ... e.g. lets say I have A.proto , B.proto, > C.proto, D.proto > > Message A{ > optional B b; > ..... > } > > Message B{ > optional C c; > ....... > } > > Message C{ > optional D d; > ........ > } > > Message D{ > optional int e; > } > > And i get a message of type A. Currently I have a recursive function > traverse(Message *) > when I get A, I switch on the CPP TYPE of each field it has and call > traverse recursively with A->getMessage or A->getRepeatedMessage depending > on the kind of field. > > For the solution I want, I can keep a stack of field names, and keep > pushing into it for every recursive call till I see 'e'. At that point I > can concatenate all field names in the stack and get A.B.C.D.e as the fully > qualified name of 'e'. > Is there an easier way? > thanks > -Ajoy > > > > On Mon, Jun 1, 2009 at 6:22 PM, Kenton Varda <ken...@google.com> wrote: > >> Sorry, I don't understand your question. Can you write out the >> hypothetical .proto file that defines these types, and example code showing >> what you imagine the solution looking like? >> >> On Mon, Jun 1, 2009 at 3:44 PM, ajoy <ajo...@gmail.com> wrote: >> >>> >>> Hi, >>> >>> If I have a chain of enclosed messages, e.g. A->B->C->D->e >>> where e is a scalar at the end of the chain, and I'm dynamically >>> parsing it, and looking at e, is there a way to get A.B.C.D.e as the >>> fully qualified name? >>> >>> thanks >>> >>> >>> >> > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---