Add example documentation

Fixes #13.
This commit is contained in:
Jonathan Müller 2017-11-14 18:28:24 +01:00
commit c886ef31e4
7 changed files with 70 additions and 1 deletions

View file

@ -4,6 +4,8 @@
/// \file
/// Generates enum `to_string()` code.
///
/// Given an input file, it will generate a to_string() function for all enums marked with [[generate::to_string]].
#include <iostream>
@ -40,6 +42,7 @@ void generate_to_string(const cppast::cpp_file& file)
std::cout << " case " << enum_.name() << "::" << enumerator.name()
<< ":\n";
// attribute can be used to override the string
if (auto attr =
cppast::has_attribute(enumerator, "generate::to_string"))
std::cout << " return "