Add name override for enum to string
This commit is contained in:
parent
e8f7dd0911
commit
0f9b90a32b
1 changed files with 8 additions and 1 deletions
|
|
@ -39,7 +39,14 @@ void generate_to_string(const cppast::cpp_file& file)
|
|||
{
|
||||
std::cout << " case " << enum_.name() << "::" << enumerator.name()
|
||||
<< ":\n";
|
||||
std::cout << " return \"" << enumerator.name() << "\";\n";
|
||||
|
||||
if (auto attr =
|
||||
cppast::has_attribute(enumerator, "generate::to_string"))
|
||||
std::cout << " return "
|
||||
<< attr.value().arguments().value().as_string()
|
||||
<< ";\n";
|
||||
else
|
||||
std::cout << " return \"" << enumerator.name() << "\";\n";
|
||||
}
|
||||
std::cout << " }\n";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue