main.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // code_generator_command.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
  2. //
  3. #include <iostream>
  4. #include <chrono>
  5. #include "class_view.hpp"
  6. int main(int argc, char* argv[])
  7. {
  8. system("chcp 65001");
  9. if (argc <= 0) {
  10. std::cout << "参数错误!" << std::endl;
  11. return -1;
  12. }
  13. for (int i = 0; i < argc; ++i) {
  14. std::cout << "参数:"<< argv[i] << std::endl;
  15. }
  16. std::string project_path = argv[argc - 1];
  17. std::string reflect_path;
  18. if (project_path[project_path.size() - 1] == '/' || project_path[project_path.size() - 1] == '\\') {
  19. reflect_path = project_path + "reflect.h";
  20. }
  21. else {
  22. reflect_path = project_path + "/reflect.h";
  23. }
  24. std::cout << "项目反射文件:" << reflect_path << std::endl;
  25. //std::vector<class_view_info> classViews = code_analysis_core::getClassView(project_path);
  26. std::string code = analysis::code_analysis::generate_code(project_path);
  27. std::cout << "项目反射代码生成完成" << std::endl;
  28. std::ofstream file(reflect_path, std::ios::out);
  29. if (!file.is_open()) {
  30. std::cerr << "无法打开文件" << std::endl;
  31. return -1;
  32. }
  33. file << code;
  34. file.close();
  35. return 0;
  36. }
  37. // 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
  38. // 调试程序: F5 或调试 >“开始调试”菜单
  39. // 入门使用技巧:
  40. // 1. 使用解决方案资源管理器窗口添加/管理文件
  41. // 2. 使用团队资源管理器窗口连接到源代码管理
  42. // 3. 使用输出窗口查看生成输出和其他消息
  43. // 4. 使用错误列表窗口查看错误
  44. // 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
  45. // 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件