Hi Fred, you haven't mentioned a specific language you use, but in all the standard implementations I am familiar with (Java, Python, C++) an instance of a message doesn't hold a reference to its container. The opposite is true, you can find all the fields if you start working from the root. To construct the path, you can have the visitor build the partial path from the root as it goes down the graph.
-Nadav On Tue, Nov 22, 2022 at 5:46 AM Fred Eisele <[email protected]> wrote: > Given a message (b of type B), nested in another (a of type A); how does > one get ‘a’? > I was hoping for something like ‘b.getParent()’. > > message B { optional string name = 1; repeated B b = 2; } > message A { optional string name = 1; repeated B b = 1; } > > Here is an example instance of an ‘a’ with textual serialization. > > name: "a" > b { name: “foo” > b { name: “fred” > b { name: “flintstone” }}} > b { name: “bar” } > b { name: “baz” } > > The issue is that I am navigating the collection 'a' with a visitor and I > need to be able to reconstruct a full name composed of names of all the > ancestors. > > -- > 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 view this discussion on the web visit > https://groups.google.com/d/msgid/protobuf/9ba69d16-218b-4cde-b0c9-faa651a46167n%40googlegroups.com > <https://groups.google.com/d/msgid/protobuf/9ba69d16-218b-4cde-b0c9-faa651a46167n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- -Nadav -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/CANZcNEpP9O65xrZSNTKCSPrSNSyST8s6yHhuhBvtEn2hJFZvaw%40mail.gmail.com.
