title: Protobuf c++ extensions use
body: <p>I'm using google protobuf library version 2.61 and want to use extensions,</p>
  
  <p>I have the following proto files:</p>
  
  <pre><code>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;
  }
  </code></pre>
  
  <p>I am able to build the message using the following code:</p>
  
  <pre><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)-&gt;set_hostname("http://test123123123ing");
  </code></pre>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>Is there a way to do this without adding additional variable of type of extension?</p>
  
  <p>Also what is the most elegant way to do so in c++</p>