diff options
Diffstat (limited to 'apps/generate.cpp')
-rw-r--r-- | apps/generate.cpp | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/apps/generate.cpp b/apps/generate.cpp deleted file mode 100644 index a088e6e..0000000 --- a/apps/generate.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include <cstdlib> -#include <iostream> -#include <fstream> -#include <regex> - -using namespace std; - -int main(int argc, char *argv[]) { - cout << "Generating " << argv[1] << endl; - - ofstream out; - - out.open(argv[1], ofstream::out); - - if (!out.is_open()) { - return EXIT_FAILURE; - } - - out << "#pragma once" << endl - << endl - << "#include <string>" << endl - << "#include <boost/algorithm/string/predicate.hpp>" << endl - << endl; - - vector<pair<string, string>> apps; - - regex r("-"); - for (int i = 2; i < argc; i++) { - string app_name = argv[i]; - stringstream buf; - - regex_replace(ostream_iterator<char>(buf), app_name.begin(), app_name.end(), r, "_"); - string class_name = buf.str(); - - apps.emplace_back(make_pair(app_name, class_name)); - } - - for_each(begin(apps), end(apps), [&](pair<string, string> pair) { - // out << "class " << pair.second << ";" << endl; - out << "#include \"" << pair.first << ".h\"" << endl; - }); - out << endl; - - bool first = true; - - out << "namespace trygvis {" << endl - << "namespace apps {" << endl - << endl - << "template<typename App>" << endl - << "int launch_app(int argc, const char *argv[]);" << endl - << endl; - - out << "int launch(const std::string app_name, int argc, const char *argv[]) {" << endl; - - for_each(begin(apps), end(apps), [&](auto pair) { - out << " "; - if (!first) { - out << "} else "; - } else { - first = false; - } - - out << "if (boost::ends_with(app_name, \"" << pair.first << "\")) {" << endl - << " return launch_app<" << pair.second << ">(argc, argv);" << endl; - }); - - out << " } else {" << endl - << " return EXIT_FAILURE;" << endl - << " }" << endl - << "}" << endl - << endl - << "}" << endl - << "}" << endl; - - return EXIT_SUCCESS; -} |