1 Star 0 Fork 4

治平不了的天下/cpps

forked from duyanning/cpps 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
gen.cpp 1.52 KB
一键复制 编辑 原始数据 按行查看 历史
duyanning 提交于 2020-03-08 00:17 +08:00 . 增加生成预编译头文件对的选项
#include "config.h"
#include "global.h"
#include "samples.h"
void generate_pch_file(string pch_base_name)
{
ofstream f;
string pch_h_name = pch_base_name + ".h";
string pch_cpp_name = pch_base_name + ".cpp";
if (fs::exists(pch_h_name) || fs::exists(pch_cpp_name)) {
//cout << "std.h or std.cpp exists." << endl;
cout << pch_h_name << " or " << pch_cpp_name << " exists." << endl;
return;
}
f.open(pch_h_name);
f << std_h_sample;
f.close();
f.open(pch_cpp_name);
f << std_cpp_sample;
f.close();
}
void generate_main_file(string main_file_name)
{
ofstream f;
if (fs::exists(main_file_name)) {
cout << main_file_name << " already exists." << endl;
return;
}
f.open(main_file_name);
f << main_cpp_sample;
f.close();
generate_pch_file("std");
}
void generate_class_files(string class_name)
{
string h_name = class_name + ".h";
string cpp_name = class_name + ".cpp";
ofstream f;
regex pat;
string format;
if (fs::exists(h_name)) {
cout << h_name << " already exists." << endl;
return;
}
f.open(h_name);
pat = "XXX_H";
format = al::to_upper_copy(class_name) + "_H";
string h_content = regex_replace(string(class_h_sample), pat, format);
pat = "XXX";
format = class_name;
h_content = regex_replace(h_content, pat, format);
f << h_content;
f.close();
if (fs::exists(cpp_name)) {
cout << cpp_name << " already exists." << endl;
return;
}
f.open(cpp_name);
pat = "XXX";
format = class_name;
string cpp_content = regex_replace(string(class_cpp_sample), pat, format);
f << cpp_content;
f.close();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/luozhiping/cpps.git
git@gitee.com:luozhiping/cpps.git
luozhiping
cpps
cpps
master

搜索帮助