#!/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 < "$CPP_FILE" /* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ${CLASS_NAME}.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: aortigos +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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 < "$HPP_FILE" /* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ${CLASS_NAME}.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: aortigos +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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 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."