217 |
217 |
218 std::sort (filesToInclude.begin(), filesToInclude.end()); |
218 std::sort (filesToInclude.begin(), filesToInclude.end()); |
219 auto pos = std::unique (filesToInclude.begin(), filesToInclude.end()); |
219 auto pos = std::unique (filesToInclude.begin(), filesToInclude.end()); |
220 filesToInclude.resize (std::distance (filesToInclude.begin(), pos)); |
220 filesToInclude.resize (std::distance (filesToInclude.begin(), pos)); |
221 |
221 |
222 for (const string & a : filesToInclude) |
222 for (const string& a : filesToInclude) |
223 fprintf (fp, "#include \"%s\"\n", basename (a.c_str())); |
223 fprintf (fp, "#include \"%s\"\n", basename (a.c_str())); |
224 |
224 |
225 for (NamedEnumInfo & e : namedEnumerations) |
225 for (NamedEnumInfo& e : namedEnumerations) |
226 { |
226 { |
227 fprintf (fp, "\nstatic const char* g%sNames[] =\n{\n", e.name.c_str()); |
227 fprintf (fp, "\nstatic const char* g_%sNames[] =\n{\n", e.name.c_str()); |
228 |
228 |
229 for (const string & a : e.enumerators) |
229 for (const string& a : e.enumerators) |
230 fprintf (fp, "\t\"%s\",\n", a.c_str()); |
230 fprintf (fp, "\t\"%s\",\n", a.c_str()); |
231 |
231 |
232 fprintf (fp, "};\n\n"); |
232 fprintf (fp, "};\n\n"); |
233 |
233 |
234 fprintf (fp, "inline const char* Get%sString (%s a)\n" |
234 fprintf (fp, "inline const char* get%sString (%s a)\n" |
235 "{\n" |
235 "{\n" |
236 "\treturn g%sNames[a];\n" |
236 "\treturn g_%sNames[a];\n" |
237 "}\n", |
237 "}\n", |
238 e.name.c_str(), e.name.c_str(), e.name.c_str()); |
238 e.name.c_str(), e.name.c_str(), e.name.c_str()); |
239 } |
239 } |
240 |
240 |
241 printf ("Wrote named enumerations to %s\n", argv[argc - 1]); |
241 printf ("Wrote named enumerations to %s\n", argv[argc - 1]); |