Skip to content

Instantly share code, notes, and snippets.

@borisbat
Created June 19, 2013 01:43
Show Gist options
  • Save borisbat/5811081 to your computer and use it in GitHub Desktop.
Save borisbat/5811081 to your computer and use it in GitHub Desktop.
class name
template <typename ObjectType>
string TYPE_NAME()
{
// determine type name from typeid
// note - if this ever failes, we can always go constexpr route, i.e
// constexpr static const char * TYPE_NAME() { return "ClassNameHere"; };
// and maybe even try to parse __FUNCTION__ inside of it somehow
regex REG_class_name ( "N\\d*war\\d*(.+)E" );
smatch what;
if ( !regex_match( string(typeid(ObjectType).name()), what, REG_class_name) )
{
Log() << "ERROR: AtAppInitialize level class is " << typeid(ObjectType).name() << endl;
assert(0 && "revisit class parser");
}
return what[1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment