| 1 | #!/bin/bash |
| 2 | # This file is part of ccbuild. |
| 3 | |
| 4 | # ccbuild is free software: you can redistribute it and/or modify |
| 5 | # it under the terms of the GNU General Public License as published by |
| 6 | # the Free Software Foundation, either version 3 of the License, or |
| 7 | # (at your option) any later version. |
| 8 | |
| 9 | # ccbuild is distributed in the hope that it will be useful, |
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | # GNU General Public License for more details. |
| 13 | |
| 14 | # You should have received a copy of the GNU General Public License |
| 15 | # along with ccbuild. If not, see <http://www.gnu.org/licenses/>. |
| 16 | # |
| 17 | HELP="Create a simple class template. |
| 18 | It includes the srcHeader file of the first higher directory named src. |
| 19 | The header file name is given on stdout. |
| 20 | |
| 21 | Usage: $0 <class name> |
| 22 | Example: gedit \`ccClass myFunctionName\` |
| 23 | " |
| 24 | if [ -z "$1" ];then |
| 25 | echo "$HELP" |
| 26 | exit |
| 27 | fi |
| 28 | CNAME=$1 |
| 29 | LNAME=`echo $CNAME|tr '[:upper:]' '[:lower:]'` |
| 30 | CHNAME="$LNAME".hh |
| 31 | CINAME="$LNAME".ih |
| 32 | EHNAME=`echo $CHNAME|tr '.' '_'` |
| 33 | HEADER=`echo $PWD |grep -o "^.*src"`/srcHeader |
| 34 | echo $CHNAME |
| 35 | cat < "$HEADER" >> "$CINAME" |
| 36 | echo "#include \"$CHNAME\"" >> "$CINAME"; |
| 37 | echo "" >> "$CINAME"; |
| 38 | echo "using namespace bneijt;" >> "$CINAME"; |
| 39 | |
| 40 | cat < "$HEADER" >> "$CHNAME" |
| 41 | |
| 42 | cat >> "$CHNAME" <<EOF |
| 43 | |
| 44 | #ifndef ${EHNAME}_included_ |
| 45 | #define ${EHNAME}_included_ |
| 46 | |
| 47 | namespace bneijt |
| 48 | { |
| 49 | |
| 50 | class $CNAME |
| 51 | { |
| 52 | public: |
| 53 | |
| 54 | }; |
| 55 | } //Namespace |
| 56 | #endif |
| 57 | |
| 58 | EOF |
| 59 | |
| 60 |