Reading FileOptions extension in C++?

27 views
Skip to first unread message

Colin McInnes

unread,
Sep 14, 2022, 5:09:16 PM9/14/22
to Protocol Buffers
I know how to read an option within Message by using GetExtension on the Message, but can I do that for a global option that is not encapsulated within a message?

So in C++, how would I read the "my_file_name" option from the proto below?

extend google.protobuf.FileOptions {
  string my_file_name = 1001;
}

extend google.protobuf.MessageOptions {
  optional string my_option = 51234;
}

option (my_file_name) = "filename.txt";

message MyMessage {
  option (my_option) = "Hello world!";
}


sh...@google.com

unread,
Sep 20, 2022, 6:40:03 PM9/20/22
to Protocol Buffers
I believe there's `msg->file()->options()->getExtensions(...)`
Reply all
Reply to author
Forward
0 new messages