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