Files
createClass/createClass.sh
2026-02-18 10:37:42 +01:00

95 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: createClass ClassName"
exit 1
fi
CLASS_NAME=$1
UPPER_NAME=$(echo "$CLASS_NAME" | tr '[:lower:]' '[:upper:]')
mkdir -p "$CLASS_NAME"
CPP_FILE="$CLASS_NAME/$CLASS_NAME.cpp"
HPP_FILE="$CLASS_NAME/$CLASS_NAME.hpp"
cat <<EOL > "$CPP_FILE"
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ${CLASS_NAME}.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: $(date +"%Y/%m/%d %H:%M:%S") by aortigos #+# #+# */
/* Updated: $(date +"%Y/%m/%d %H:%M:%S") by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "${CLASS_NAME}.hpp"
//////////////////
// Constructors //
//////////////////
${CLASS_NAME}::${CLASS_NAME}()
{
// std::cout << "${CLASS_NAME} default constructor called" << std::endl;
}
${CLASS_NAME}::${CLASS_NAME}(const ${CLASS_NAME} &other)
{
*this = other;
// std::cout << "${CLASS_NAME} copy constructor called" << std::endl;
}
${CLASS_NAME}& ${CLASS_NAME}::operator=(const ${CLASS_NAME} &other)
{
if (this != &other)
{
// Copy attributes here
}
// std::cout << "${CLASS_NAME} copy assignment operator called" << std::endl;
return (*this);
}
${CLASS_NAME}::~${CLASS_NAME}()
{
// std::cout << "${CLASS_NAME} destructor called" << std::endl;
}
EOL
cat <<EOL > "$HPP_FILE"
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ${CLASS_NAME}.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: $(date +"%Y/%m/%d %H:%M:%S") by aortigos #+# #+# */
/* Updated: $(date +"%Y/%m/%d %H:%M:%S") by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ${UPPER_NAME}_HPP
# define ${UPPER_NAME}_HPP
# include <iostream>
class ${CLASS_NAME}
{
private:
public:
${CLASS_NAME}();
${CLASS_NAME}(const ${CLASS_NAME} &other);
${CLASS_NAME}& operator=(const ${CLASS_NAME} &other);
~${CLASS_NAME}();
};
#endif
EOL
echo "Class ${CLASS_NAME} created successfully."