-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
133 lines (107 loc) · 3.21 KB
/
main.cpp
File metadata and controls
133 lines (107 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <algorithm>
using namespace std;
void gen_main_file();
void gen_headercpp_file();
void gen_header_file();
void gen_makefile();
string convert_upper(string);
string project_name , class_name ;
int main()
{
cout << "\nEnter Project name : ";
getline(cin, project_name);
cout << "\nEnter Class name : ";
getline(cin, class_name);
string folder = "mkdir '" + project_name + "'";
system(folder.c_str());
cout << "\n[+] folder '" << project_name << "' created";
gen_main_file();
cout << "\n[+] main.cpp created";
gen_header_file();
cout << "\n[+] " << class_name << ".h created";
gen_headercpp_file();
cout << "\n[+] " << class_name << ".cpp created";
gen_makefile();
cout << "\n[+] makfile created";
cout << "\n\n[+] Done\n";
return 0;
}
void gen_makefile()
{
ofstream file;
string data , file_name;
file_name = project_name + "/makefile";
data = "OBJS = main.o ";
data += class_name + ".o";
data += "\nmain : $(OBJS)\n\tg++ -o main $(OBJS)";
data += "\n\n$(OBJS): ";
data += class_name + ".h";
data += "\n\nclean :\n rm -rf *.o main";
file.open(file_name.c_str());
file << data;
file.close();
}
void gen_header_file()
{
ofstream file;
string data, documentation, file_name, body;
file_name = project_name + "/" + class_name + ".h";
data = "#ifndef ";
data += convert_upper(class_name);
data += "_H\n#define ";
data += convert_upper(class_name);
data += "_H\n\n#include <iostream>\n#include <fstream>\n#include <string>\n#include <cstdlib>\n\nusing namespace std;\n\n//-----------------Class--------------------\nclass ";
data += class_name;
data += "\n{\n\npublic:\n\t";
data += class_name;
data += "();\n\t~";
data += class_name;
data += "();\n};\n\n#endif";
file.open(file_name.c_str());
file << data;
file.close();
}
string convert_upper(string s)
{
string x = s;
transform(x.begin(), x.end(), x.begin(), ::toupper);
return x;
}
void gen_headercpp_file()
{
ofstream file;
string data, file_name, documentation, body;
file_name = project_name + "/" + class_name + ".cpp";
documentation = "/*\n\t\t\t\tProject Name : ";
documentation += project_name;
documentation += " \n\t\t\t\tDate :\n\t\t\t\tMade By : Vishal Singh\n*/\n\n";
body += "#include \"";
body += class_name;
body += ".h\"\n\n";
body += class_name + "::" + class_name + "()\n{\n\n}\n\n";
body += class_name + "::~" + class_name + "()\n{\n\n}";
data = documentation + body;
file.open(file_name.c_str());
file << data;
file.close();
}
void gen_main_file()
{
ofstream file;
string data, documentation, file_name, body;
file_name = project_name + "/main.cpp";
documentation = "/*\n\t\t\t\tProject Name : ";
documentation += project_name;
documentation += " \n\t\t\t\tDate :\n\t\t\t\tMade By : Vishal Singh\n*/\n\n";
body += "#include \"";
body += class_name;
body += ".h\"\n\nusing namespace std;\n\n//-----------------function prototypes------------------\n\n\n//--------------------main function----------------------\nint main()\n{\n\n\n return 0;\n}\n\n//------------------function definations----------------\n";
data = documentation + body;
file.open(file_name.c_str());
file << data;
file.close();
}