Is it possible with Google Protocol Buffers to retrieve the field name (not the field type) of the parent message by using descriptors in C++?
Consider the following minimal example:
message MessageHeader {
string addressee = 1;
}
message Message {
MessageHeader header = 1;
}
I want to retrieve the string "header.addresse"
with the following function:
std::string createFieldQueryFrom(
const google::protobuf::FieldDescriptor* const descriptor)
{
// TODO(wolters): The descriptor for the containing FIELD is required. Is
// there a way to retrieve it?
//
// containing_descriptor->name() returns "Message", what I want is
// "header"!
const google::protobuf::Descriptor* containing_descriptor{
descriptor->containing_type()};
// TODO(wolters): Add recursion if able to get the actual attribute name of
// the containing FIELD.
return "";
}
- Is this possible, or doesn't a
google::protobuf::FieldDescriptor
instance provide the information required to fulfil that task? - If the answer to 1. is no: Is this possible at all (if so, can you provide me an example)?
Aucun commentaire:
Enregistrer un commentaire