<div>Hi,</div>
<div> </div>
<div>Given a QualType that has a class, struct, or enum name in there somewhere, I'd like to get a string that just contains the leaf type name, and a string that contains just the qualified type name.</div>
<div> </div>
<div>For example, given a QualType whose getAsString() call returns "class namespace::classname *&", I'd like to get a string like "classname" and a string like "namespace::classname".</div>

<div> </div>
<div>At present I'm doing it very naively like this:</div>
<div> </div>
<div><font face="courier new,monospace">//...<br>std::string baseName = LuaBindingsConsumer::StripToBaseName(type.GetAsString());<br>std::string qualifiedBaseName = LuaBindingsConsumer::StripToQualifiedName(type.GetAsString());<br>
//...</font></div>
<div><br><font face="courier new,monospace">  // Strip a type string of everything but the base type name.<br>std::string LuaBindingsConsumer::StripToBaseName(std::string typeName) {<br>  typeName = StripToQualifiedName(typeName);<br>
  size_t index;<br>  while ((index = typeName.find_first_of("::")) < typeName.length())<br>    typeName = typeName.substr(index + 2);<br>  return typeName;<br>}</font></div>
<div><font face="courier new,monospace">  // Strip a type string of everything but the qualified base type name.<br>std::string LuaBindingsConsumer::StripToQualifiedName(std::string typeName) {<br>  size_t index;<br>  if (typeName.compare(0, 6, "class ") == 0)<br>
    typeName = typeName.substr(6);<br>  else if (typeName.compare(0, 7, "struct ") == 0)<br>    typeName = typeName.substr(7);<br>  else if (typeName.compare(0, 5, "enum ") == 0)<br>    typeName = typeName.substr(5);<br>
  while ((index = typeName.find_first_of('*')) < typeName.length())<br>    typeName = typeName.substr(0, index);<br>  while ((index = typeName.find_first_of('&')) < typeName.length())<br>    typeName = typeName.substr(0, index);<br>
  while ((index = typeName.find_first_of('[')) < typeName.length())<br>    typeName = typeName.substr(0, index);<br>  while ((index = typeName.find_first_of('{')) < typeName.length())<br>    typeName = typeName.substr(0, index);<br>
  while ((index = typeName.find_first_of(' ')) < typeName.length())<br>    typeName = typeName.substr(0, index);<br>  while ((index = typeName.find_first_of('\t')) < typeName.length())<br>    typeName = typeName.substr(0, index);<br>
  return typeName;<br>}<br><br clear="all"></font>but there must be a better way.</div>
<div> </div>
<div>Thanks.</div>
<div> </div>
<div>-John</div>
<div><br>-- <br>John Thompson<br><a href="mailto:John.Thompson.JTSoftware@gmail.com">John.Thompson.JTSoftware@gmail.com</a><br><br></div>