-
Notifications
You must be signed in to change notification settings - Fork 2
/
Cpp_OrthodoxGenerator.sh
executable file
·153 lines (129 loc) · 5.09 KB
/
Cpp_OrthodoxGenerator.sh
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash
printf "\n"
printf "░█████╗░██████╗░██████╗░ ░██████╗░███████╗███╗░░██╗
██╔══██╗██╔══██╗██╔══██╗ ██╔════╝░██╔════╝████╗░██║
██║░░╚═╝██████╔╝██████╔╝ ██║░░██╗░█████╗░░██╔██╗██║
██║░░██╗██╔═══╝░██╔═══╝░ ██║░░╚██╗██╔══╝░░██║╚████║
╚█████╔╝██║░░░░░██║░░░░░ ╚██████╔╝███████╗██║░╚███║
░╚════╝░╚═╝░░░░░╚═╝░░░░░ ░╚═════╝░╚══════╝╚═╝░░╚══╝\033[m\n"
printf "\n By : \x1b[33mmarbenMB\033[m [mbenbajj]\n"
echo ""
echo -n "Current Directory : "
pwd
#Variables
PATH=""
CLASS=""
OPTION=""
#PATH
echo "*******************************************************"
echo -ne "\x1b[33mEnter Path Of Creation : \033[m"
read PATH
if [ -d $PATH ] &> /dev/null
then
cd $PATH
echo "Changing Directory to : " $PATH
echo "*******************************************************"
echo -ne "\x1b[33mEnter Class Name : \033[m"
read CLASS
if [ $CLASS != "" ] 2> /dev/null
then
echo "Class Name : " $CLASS
echo "*******************************************************"
/usr/bin/touch $CLASS.cpp $CLASS.hpp
# *** Printing To Class.hpp ***
echo "#ifndef _"$CLASS"_HPP_" >> $CLASS.hpp
echo "#define _"$CLASS"_HPP_" >> $CLASS.hpp
printf "\n" >> $CLASS.hpp
echo "#include <iostream>" >> $CLASS.hpp
printf "\n" >> $CLASS.hpp
echo "// ******************************************************** //" >> $CLASS.hpp
echo "// CLASSES //" >> $CLASS.hpp
echo "// ****************************************************** //" >> $CLASS.hpp
printf "\nclass $CLASS
{
public :
$CLASS ();
$CLASS ($CLASS const &obj);
~$CLASS ();
$CLASS &operator= (const $CLASS &obj);
private :
// DataType attributes.
};\n\n" >> $CLASS.hpp
printf "// ******************************************************** //
// FUNCTIONS //
// ****************************************************** //\n\n" >> $CLASS.hpp
echo "#endif" >> $CLASS.hpp
# *** Printing To Class.cpp ***
printf "#include \"$CLASS.hpp\"
$CLASS::$CLASS()
{
std::cout << \"$CLASS : Default Constructor Called\" << std::endl;
}
$CLASS::~$CLASS()
{
std::cout << \"$CLASS : Destructor Called\" << std::endl;
}
$CLASS::$CLASS($CLASS const &obj)
{
std::cout << \"Copy Constructor Called\" << std::endl;
if (this != &obj)
*this = obj;
}
$CLASS &$CLASS::operator= (const $CLASS &obj)
{
std::cout << \"Copy Assignment Operator Called\" << std::endl;
if (this != &obj)
{
// this->attributes = obj.attributes;
// ...
}
return (*this);
}\n" > $CLASS.cpp
echo -ne "\x1b[33mCreate main.cpp and Makefile \033[m[\x1b[32my\033[m/\x1b[31mn\033[m] : "
read OPTION
if [ $OPTION == "y" ] || [ $OPTION == "yes" ] &> /dev/null
then
/usr/bin/touch main.cpp Makefile
# *** Printing To Makefile ***
printf "NAME = $CLASS \n
CXXFLAGS = -Wall -Wextra -Werror -fsanitize=address\n
CC = c++ \n
STD = -std=c++98 \n
SRC = $CLASS.cpp main.cpp \n
INC = $CLASS.hpp \n
OBJ = \$(SRC:.cpp=.o) \n
all : \$(NAME) \n
\$(NAME) : \$(OBJ)
\$(CC) \$(CXXFLAGS) \$(STD) \$(OBJ) -o \$(NAME) \n\n" >> Makefile
echo %.o : %.cpp "\$(INC)" >> Makefile
printf " \$(CC) \$(CXXFLAGS) -c \$< -o \$@ \n
clean :
rm -rf \$(OBJ) \n
fclean : clean
rm -rf \$(NAME) \n
re : fclean all \n
.PHONY : all clean fclean re\n" >> Makefile
# *** Printing To main.cpp ***
printf "#include \"$CLASS.hpp\"\n
int main()
{
// You Code\n
std::cout << \"****** MAR_BEN CREATION √ ******\" << std::endl;\n
return (0);
}\n" > main.cpp
fi
printf "\n░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█████╗█████╗█████╗█████╗█████╗█████╗█████╗
╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n\n"
echo -e "\x1b[32m+> " $CLASS " : Files Created !\033[m\n"
else
echo -e "______________________________________\n"
echo -e "\x1b[31mNo Class Name Entred\033[m\n"
fi
else
echo -e "______________________________________\n"
echo -e "\x1b[31m*** $PATH : ** Path not found !! **\033[m\n"
fi