Last active
October 24, 2015 18:11
-
-
Save maaatts/4ad00fc1dc911835cdc9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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