-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_cpp
executable file
·68 lines (64 loc) · 1.88 KB
/
generate_cpp
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
#!/bin/bash
if [ "$#" != 1 ]
then
echo -e "$0 <name of the class to generate>"
exit
fi
if [ ! -f $1.hpp ]
then
touch $1.hpp
echo "/*" >> $1.hpp
echo "** EPITECH PROJECT, 2018" >> $1.hpp
echo "** \$NAME_OF_THE_PROJECT" >> $1.hpp
echo "** File description:" >> $1.hpp
echo "** Here is coded a super function" >> $1.hpp
echo "*/" >> $1.hpp
echo "" >> $1.hpp
echo "#ifndef `echo "$1" | tr '[:lower:]' '[:upper:]'`_H_" >> $1.hpp
echo "#define `echo "$1" | tr '[:lower:]' '[:upper:]'`_H_" >> $1.hpp
echo "" >> $1.hpp
echo "#include <iostream>" >> $1.hpp
echo "#include <string>" >> $1.hpp
echo "" >> $1.hpp
echo "class $1" >> $1.hpp
echo "{" >> $1.hpp
echo "private:" >> $1.hpp
echo "" >> $1.hpp
echo "public:" >> $1.hpp
echo "$1();" >> $1.hpp
echo "~$1();" >> $1.hpp
echo "};" >> $1.hpp
echo "" >> $1.hpp
echo "#endif" >> $1.hpp
echo -e "$1.hpp well created!"
else
echo -e "$1.hpp already exists!"
echo -e "`cat $1.cpp 2> /dev/null | grep "^[a-z]" | sed -e 's/)/);/g' | sed -e "s/$1:://g"`" >> $1.hpp
fi
find . -name "$1.hpp" -type f -exec vim -en "+normal 7gg=GZZ" {} \;
if [ ! -f $1.cpp ]
then
touch $1.cpp
echo "/*" >> $1.cpp
echo "** EPITECH PROJECT, 2018" >> $1.cpp
echo "** \$NAME_OF_THE_PROJECT" >> $1.cpp
echo "** File description:" >> $1.cpp
echo "** Here is coded a super function" >> $1.cpp
echo "*/" >> $1.cpp
echo "" >> $1.cpp
echo "#include \"$1.hpp\"" >> $1.cpp
echo "" >> $1.cpp
echo "$1::$1()" >> $1.cpp
echo "{" >> $1.cpp
echo " " >> $1.cpp
echo "}" >> $1.cpp
echo " " >> $1.cpp
echo "$1::~$1()" >> $1.cpp
echo "{" >> $1.cpp
echo " " >> $1.cpp
echo "}" >> $1.cpp
find . -name "$1.cpp" -type f -exec vim -en "+normal 7gg=GZZ" {} \;
echo -e "$1.cpp well created!"
else
echo -e "$1.cpp already exists!"
fi