Skip to content

Instantly share code, notes, and snippets.

@maaatts
Last active October 24, 2015 18:11
Show Gist options
  • Save maaatts/4ad00fc1dc911835cdc9 to your computer and use it in GitHub Desktop.
Save maaatts/4ad00fc1dc911835cdc9 to your computer and use it in GitHub Desktop.
#!/bin/bash
printhelp() {
ME=$(basename ${0})
echo "Usage: ${ME} <classname>"
}
if [ "$1" == "--help" ]; then
printhelp
exit 0
fi
if [ "$#" -ne 1 ]; then
printhelp
exit 1
fi
CLASSNAME="${1}"
HEADERFILE="${CLASSNAME,,}.h"
SOURCEFILE="${CLASSNAME,,}.cpp"
if [ -f "${HEADERFILE}" ] || [ -f "${SOURCEFILE}" ]; then
echo "File(s) already exist!" >&2
exit 2
fi
cat <<EOF > ${HEADERFILE}
#pragma once
class ${CLASSNAME} {
public:
${CLASSNAME}();
virtual ~${CLASSNAME}();
};
EOF
cat <<EOF > ${SOURCEFILE}
#include "${HEADERFILE}"
${CLASSNAME}::${CLASSNAME}() {
//ctor
}
${CLASSNAME}::~${CLASSNAME}() {
//dtor
}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment