I'm writing a C++ library function which reads protocol buffer objects
from an input stream and returns an abstract Message object to caller.
When descriptors are not known at compile-time, I use a
DescriptorPool::BuildFile() call to load them dynamically. I inspect
each loaded file to find messages which are valid top-level objects to
be parsed from my input stream (they are tagged with a custom option).
However, library client may want to use objects he knows at compile-
time (typically dynamic_cast'ing them, rather than getting
DynamicMessage instances), so I would like to inspect the
generated_pool itself to index valid descriptors it might contain.
This way, I could build objects based on descriptions from
I can't figure out how to browse a DesciptorPool (I would need a way
to iterate over the whole list of FileDescriptor objects). Looking at
sources, it seems it would not be so difficult to implement that, but
I probably miss something...
I wrote a small protoc plugin which inserts self-registration code in
each generated *.pb.cc file. This way, I can use the resulting file
list to get the descriptor using DescriptorPool::generated_pool()-
>FindFileByName() but it is totally redundant with generated pool's
built-in registration system.
What do you think would be the good solution to do that?
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to
For more options, visit this group at