title: How to find Message Type from attribute name in google proto buf message?
body: <p>I have protobuf messages defined as below. I need to find the message type from the attribute name. For example, when the input is "cfgMsg" the output should be ConfigMsg or CfgServerMsg.ConfigMsg (full name). </p>
  
  <pre><code>message CfgServerMsg {
    string name = 1;
    ConfigMsg cfgMsg = 2;
  }
  
  message ConfigMsg {
    string cfgName = 1;
    uint32 msgId = 2;
  }
  </code></pre>
  
  <p>I have the below code. However, this is working for well defined types like string, int, float etc. and for messages it just prints "message" as the output. </p>
  
  <p>I removed some code and presented only that is relevant to this question. So this is obviously not the complete code.</p>
  
  <pre><code>google::protobuf::Message *modObj = new ModObj();
  
  const google::protobuf::Descriptor *outModDesc 
              =  modObj-&gt;GetDescriptor();
  const Reflection *outModRefl = modObj-&gt;GetReflection();
  const FieldDescriptor *field;
  
  // Loop to iterate over all the fields
  {
    field = outModDesc-&gt;FindFieldByName(tmp_name);
    std::string type = field-&gt;type_name();
    std::cout &lt;&lt; "Type:" &lt;&lt; type &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>Output:
  Type:string
  Type:message</p>
  
  <p>However, I want to get the actual message type which is "ConfigMsg" instead of just "message". Is there any such API available from protobuf ? </p>
  
  <p>I did check this page <a href="https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.descriptor#FileDescriptor.name.details" rel="nofollow noreferrer">https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.descriptor#FileDescriptor.name.details</a> thoroughly, but couldn't find any thing useful for this.  </p>
  
  <p>If anyone has done similar thing or know some thing around this, it would be useful.</p>
  
  <p>Thanks,</p>