I'm using google protobuf library version 2.61 and want to use extensions,
I have the following proto files:
package communication;
message BaseMessage {
required uint64 server_id = 1;
required string uuid = 2;
required uint64 message_id = 3;
extensions 100 to max;
}
message GetIdentify {
extend BaseMessage {
optional GetIdentify message = 100;
}
required string hostname = 1;
}
I am able to build the message using the following code:
communication::BaseMessage base_message;
base_message.set_message_id(123456);
base_message.set_server_id(112313123);
base_message.set_uuid("asdaskdjasd213123123asd");
base_message.MutableExtension(communication::GetIdentify::message)->set_hostname("http://test123123123ing");
However I would like to do the opposite action and get message with unknown extension and parse it and find which extension it is and parse according to it.
I've used nanopb for my c project and python version. but I find it really hard to write protobuf code in c++ because I can't find good enough documentation and code examples.
Is there a way to do this without adding additional variable of type of extension?
Also what is the most elegant way to do so in c++