Newer
Older
libj / tool / copy-class.sh
Nomura Kei on 9 Jun 733 bytes first commit
#!/bin/sh
#
I_CLASS=$1
O_CLASS=$2
EXT=$3
if [ "${I_CLASS}" = "" ] || [ "${O_CLASS}" = "" ] || [ "${EXT}" = "" ]; then
	echo "Usage) $0 in_class out_class ext > out_class_file"
	echo "Ex) $0 \"Exception\" \"RuntimeException\" ".hpp" > runtime_exception.hpp"
	exit 1
fi

I_SNAKE=`echo ${I_CLASS} | sed -E 's/(.)([A-Z])/\1_\2/g'`
O_SNAKE=`echo ${O_CLASS} | sed -E 's/(.)([A-Z])/\1_\2/g'`

I_LOWER=`echo "${I_SNAKE}" | tr "[:upper:]" "[:lower:]"`
O_LOWER=`echo "${O_SNAKE}" | tr "[:upper:]" "[:lower:]"`

I_UPPER=`echo "${I_SNAKE}" | tr "[:lower:]" "[:upper:]"`
O_UPPER=`echo "${O_SNAKE}" | tr "[:lower:]" "[:upper:]"`

sed -e "s/${I_CLASS}/${O_CLASS}/g" -e "s/${I_LOWER}/${O_LOWER}/g" -e "s/${I_UPPER}/${O_UPPER}/g" "${I_LOWER}${EXT}"