青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

冰果

技術(shù)群:26678700     
交流QQ: 704839634
合作: 1) 可兼職遠(yuǎn)程辦公開發(fā); 2) 有一套Go+Python開發(fā)的行業(yè)短信云平臺可合作;3)目前正在開發(fā)物聯(lián)網(wǎng)、大數(shù)據(jù)平臺。

腳本:根據(jù)模板生成簡單代碼

         在UNIX系統(tǒng)上進(jìn)行C++開發(fā),公司規(guī)定用vi編輯,所以寫個簡單腳本,可以根據(jù)簡單模板簡單生成C++代碼文件,  可以偷一下懶,文件頭也比較規(guī)范。里面大量使用awk和sed,這是寫sh腳本常用的東東。
          第一部分是代碼,第二部分是我自己常用的簡單模板。
 
=====================================================================
                                                腳本
=====================================================================
#!/bin/sh
#
################################################################################
#
# Auto-create the code file from the template file.
#
# Author:  liangbing
# version:  1.0
# date:  2007-05-19
#
################################################################################


################################################################################
#
# function: print the help
#
################################################################################
usage( )
{
 echo "act.sh [-v] [-h] "
 echo "  Print the help"
 echo "act.sh [-t templFileName] [-f codeFileName] [-c classNameList]"
 echo "     Create the code file by the template file(通過模板生成代碼, 完成后自動進(jìn)入vi編輯)"
 echo "     classNameList is separated by \":\", 即多個類名之間用冒號分隔"
 echo "     default template path(如果缺省路徑不對,請自己修改腳本act.sh中變量templDefaultPath): "
 echo "  $templDefaultPath"
 echo " .e.g:"
 echo "   1. default template path: 使用缺省的模板文件的路徑"
  echo "     AIMC code:"
 echo "  act.sh -t apisvr -f test.cpp"
 echo "  act.sh -t h2sg -f test.cpp"
 echo "  act.sh -t webmail -f test.cpp"
 echo "  act.sh -t wmail -f test.cpp"
 echo ""
  echo "     common code:"
 echo "  act.sh -t main -f test.cpp"
 echo "  act.sh -t head -f test.hpp"
 echo "  act.sh -t src -f test.cpp"
 echo "  act.sh -c clsString -f test"
 echo "  act.sh -c clsString:clsVector:clsList -f test"
 echo ""
 echo "   2. specified template path: 自己指定模板文件的路徑和文件名"
 echo "  act.sh -t ./yourTempl.cpp -f test.cpp"
 echo "  act.sh -t ./yourClassTempl -c clsString -f test"
 echo "  act.sh -t ./yourClassTempl -c clsString:clsVector:clsList -f test"
 echo ""
 echo "   3. append a class into your existed hpp and cpp file: 追加一個新類到已經(jīng)存在的頭文件和源文件"
 echo "  act.sh -c clsString -f test"
 echo "  act.sh -c clsString:clsVector:clsList -f test"
}


################################################################################
#
# function: create the simple file
#
################################################################################
creat_simple_file( )
{
# the definition of the variabl
 templFileName=$1
 codeFileName=$2
 templDefaultPath=$3

# the definiton of the key value
 keyFileName=
 moduleName=
 version=1.0
 date=`date "+%Y-%m-%d"`
 dateTime=`date "+%Y\/%m\/%d %H:%M:%S"`

# test if the template file is existed
 if [ ! -f "$templFileName" ]
 then
  templFileName=`echo ${templDefaultPath}/${templFileName}.act`
  if [ ! -f "$templFileName" ]
  then
   echo "$templFileName is not existed!"
   exit
  fi
 fi

# test if the code file is existed
 if [ -f "$codeFileName" ]
 then
  vi $codeFileName
  exit
 fi

# get the path name, the key file name and the module name
 keyFileName=`echo $codeFileName | awk -F/ '{print $NF}'`
 moduleName=`echo $keyFileName | awk -F. '{print $1}'`

# get the file identifier
 dateStr=`date "+%Y%m%d%H%M%S"`
 fileIdentifier=`echo $moduleName | tr "[a-z]" "[A-Z]"`
 fileIdentifier=`echo ${fileIdentifier}_${dateStr}`

# create the code file
 sed "s/<%file_name%>/$keyFileName/g" $templFileName | \
  sed "s/<%version%>/$version/g" | \
  sed "s/<%login_name%>/$LOGNAME/g" | \
  sed "s/<%date%>/$date/g" | \
  sed "s/<%module_name%>/$moduleName/g" | \
  sed "s/<%file_identifier%>/$fileIdentifier/g" | \
  sed "s/<%date_time%>/$dateTime/g" > $codeFileName

 vi $codeFileName
}


################################################################################
#
# function: append the class code to the existed hpp and cpp file
#
################################################################################
append_class_code( )
{
# the definition of the variabl
 templHeadFileName=`echo ${templDefaultPath}/class.head`
 templSrcFileName=`echo ${templDefaultPath}/class.src`

# test if the template file is existed
 if [ ! -f "$templSrcFileName" ]
 then
  echo "$templSrcFileName is not existed!"
  exit
 elif [ ! -f "$templHeadFileName" ]
 then
  echo "$templHeadFileName is not existed!"
  exit
 fi

# append the class code
 tempHeadFile=`echo ".temp.head.act"`
 tempSrcFile=`echo ".temp.src.act"`

 lineNumList=`sed -n "/#endif/=" $codeHeadFileName`
 lineNum=`echo $lineNumList | awk '{print $NF}'`

 sed "${lineNum}d" $codeHeadFileName > $tempHeadFile
 awk '{print $0}' $codeSourceFileName > $tempSrcFile

 for className in $classNameList
 do
  sed "s/<%class_name%>/$className/g" $templHeadFileName >> $tempHeadFile
  sed "s/<%class_name%>/$className/g" $templSrcFileName >> $tempSrcFile
 done

 sed -n "$lineNum"p $codeHeadFileName >> $tempHeadFile
 awk '{print $0}' $tempHeadFile > $codeHeadFileName
 awk '{print $0}' $tempSrcFile > $codeSourceFileName

# delete the temp file
 if [ -f "$tempHeadFile" ]
 then
  rm $tempHeadFile
 fi

 if [ -f "$tempSrcFile" ]
 then
  rm $tempSrcFile
 fi
}


################################################################################
#
# function: create the class file
#
################################################################################
creat_class_file( )
{
# the definition of the variabl
 templFileName=$1
 classNameList=`echo $2 | sed "s/:/ /g"`
 codeFileName=$3
 templDefaultPath=$4

# the definiton of the key value
 version=1.0
 date=`date "+%Y-%m-%d"`
 dateTime=`date "+%Y\/%m\/%d %H:%M:%S"`

# get template info: the path name, the file name
 count=`echo $templFileName | awk -F/ '{print NF}'`
 tmpFileName=`echo $templFileName | awk -F/ '{print $NF}'`
 templPathName=.
 if [ $count -ge 2 ]
 then
  count=`expr $count - 1`
  templPathName=`echo $templFileName | cut -d/ -f1-$count`
 fi
 templName=`echo $tmpFileName | awk -F. '{print $1}'`
 templHeadFileName=`echo ${templPathName}/${templName}.hpp`
 templSourceFileName=`echo ${templPathName}/${templName}.cpp`

# test if the template file is existed
 if [ ! -f "$templHeadFileName" ]
 then
  templHeadFileName=`echo ${templDefaultPath}/${templName}.hpp`
  if [ ! -f "$templHeadFileName" ]
  then
   echo "$templHeadFileName is not existed!"
   exit
  fi
 fi

 if [ ! -f "$templSourceFileName" ]
 then
  templSourceFileName=`echo ${templDefaultPath}/${templName}.cpp`
  if [ ! -f "$templSourceFileName" ]
  then
   echo "$templSourceFileName is not existed!"
   exit
  fi
 fi

# get code file info: the path name, the file name
 count=`echo $codeFileName | awk -F/ '{print NF}'`
 tmpFileName=`echo $codeFileName | awk -F/ '{print $NF}'`
 codePathName=.
 if [ $count -ge 2 ]
 then
  count=`expr $count - 1`
  codePathName=`echo $codeFileName | cut -d/ -f1-$count`
 fi
 moduleName=`echo $tmpFileName | awk -F. '{print $1}'`
 codeHeadFileName=`echo ${codePathName}/${moduleName}.hpp`
 codeSourceFileName=`echo ${codePathName}/${moduleName}.cpp`
 keyHeadFileName=`echo ${moduleName}.hpp`
 keySourceFileName=`echo ${moduleName}.cpp`

# get the file identifier
 dateStr=`date "+%Y%m%d%H%M%S"`
 fileIdentifier=`echo $moduleName | tr "[a-z]" "[A-Z]"`
 fileIdentifier=`echo ${fileIdentifier}_${dateStr}`

# test if the code file is existed
 if [ -f "$codeHeadFileName" -a -f "$codeSourceFileName" ]
 then
  append_class_code
 fi

 if [ -f "$codeHeadFileName" ]
 then
  vi $codeHeadFileName
  exit
 elif [ -f "$codeSourceFileName" ]
 then
  vi $codeSourceFileName
  exit
 fi

# create the class header file
 beginLineNum=`sed -n "/<%class_begin%>/=" $templHeadFileName`
 endLineNum=`sed -n "/<%class_end%>/=" $templHeadFileName`

 headLineNum=`expr $beginLineNum - 1`
 sed -n "1,$headLineNum"p $templHeadFileName | \
  sed "s/<%file_name%>/$keyHeadFileName/g" | \
  sed "s/<%version%>/$version/g" | \
  sed "s/<%login_name%>/$LOGNAME/g" | \
  sed "s/<%date%>/$date/g" | \
  sed "s/<%module_name%>/$moduleName/g" | \
  sed "s/<%file_identifier%>/$fileIdentifier/g" | \
  sed "s/<%date_time%>/$dateTime/g" > $codeHeadFileName

 for className in $classNameList
 do
  classBeginLineNum=`expr $beginLineNum + 1`
  classEndLineNum=`expr $endLineNum - 1`
  sed -n "$classBeginLineNum,$classEndLineNum"p $templHeadFileName | \
   sed "s/<%class_name%>/$className/g" >> $codeHeadFileName
 done

 rearLineNum=`expr $endLineNum + 1`
 sed -n "$rearLineNum,$"p $templHeadFileName | \
  sed "s/<%file_identifier%>/$fileIdentifier/g" >> $codeHeadFileName

# create the class source file
 beginLineNum=`sed -n "/<%class_begin%>/=" $templSourceFileName`
 endLineNum=`sed -n "/<%class_end%>/=" $templSourceFileName`

 headLineNum=`expr $beginLineNum - 1`
 sed -n "1,$headLineNum"p $templSourceFileName | \
  sed "s/<%file_name%>/$keySourceFileName/g" | \
  sed "s/<%version%>/$version/g" | \
  sed "s/<%login_name%>/$LOGNAME/g" | \
  sed "s/<%date%>/$date/g" | \
  sed "s/<%module_name%>/$moduleName/g" | \
  sed "s/<%header_file_name%>/$keyHeadFileName/g" | \
  sed "s/<%date_time%>/$dateTime/g" > $codeSourceFileName

 for className in $classNameList
 do
  classBeginLineNum=`expr $beginLineNum + 1`
  classEndLineNum=`expr $endLineNum - 1`
  sed -n "$classBeginLineNum,$classEndLineNum"p $templSourceFileName | \
   sed "s/<%class_name%>/$className/g" >> $codeSourceFileName
 done

 vi $codeHeadFileName
}


################################################################################
#
# The main module
#
################################################################################
# the definition of the variabl
templDefaultPath=/export/home/liangb/aimc/autocreate
templFileName=
codeFileName=
className=

# get the code file name
if [ $# -lt 1 ]
then
 usage
 exit
else
 while getopts hvf:t:c: option
 do
  case $option in
  h)
   usage
   exit 1 ;;
  v)
   usage
   exit 1 ;;
  f)
   codeFileName=$OPTARG ;;
  t)
   templFileName=$OPTARG ;;
  c)
   className=$OPTARG ;;
  ?)
   usage
   exit 1 ;;
  esac
 done
fi

# test if the code file name is set
if [ -z "$codeFileName" ]
then
 echo "You don't input the code file name"
 usage
 exit
fi

# test if the class template file name is set
if [ -z "$className" ]
then
 if [ -z "$templFileName" ]
 then
  echo "You don't input the template file name"
  usage
  exit
 else
  creat_simple_file $templFileName $codeFileName $templDefaultPath
  exit
 fi
else
 if [ -z "$templFileName" ]
 then
  templFileName=`echo "class"`
 fi

 creat_class_file $templFileName $className $codeFileName $templDefaultPath
 exit
fi

=====================================================================
                                                模板文件
=====================================================================
1.  class.hpp
 
/**
 *@file  <%file_name%>
 *
 *@brief <%module_name%>.
 *
 *@author <%login_name%>
 *@date  <%date%>
 *@version <%version%>
 *$Id: <%file_name%>,v <%version%> <%date_time%> <%login_name%> Exp $
 */


#ifndef __<%file_identifier%>_H__
#define __<%file_identifier%>_H__

 


<%class_begin%>
//////////////////////////////////////////////////////////////////////////////////////////
/**
 *@name  <%class_name%>
 *@brief 
 */
class <%class_name%> {
 public:
  /**
   *@brief Default constructor
   */
  <%class_name%>( );

  /**
   *@brief Destructor
   */
  ~<%class_name%>( );

 protected:

 private:
  /**
   *@brief Copy constructor
   */
  <%class_name%>( const <%class_name%>& );

  /**
   *@brief Assignment operator
   */
  <%class_name%>& operator=( const <%class_name%>& );

 private:
};


<%class_end%>
#endif//__<%file_identifier%>_H__

-------------------------------------------------------------------------------------------------

2. class.cpp

/**
 *@file  <%file_name%>
 *
 *@brief <%module_name%>.
 *
 *@author <%login_name%>
 *@date  <%date%>
 *@version <%version%>
 *$Id: <%file_name%>,v <%version%> <%date_time%> <%login_name%> Exp $
 */


#include "<%header_file_name%>"

 


<%class_begin%>
//////////////////////////////////////////////////////////////////////////////////////////
//
//    <%class_name%>
//
//////////////////////////////////////////////////////////////////////////////////////////
// Default constructor
<%class_name%>::<%class_name%>( )
{
}


// Destructor
<%class_name%>::~<%class_name%>( )
{
}


<%class_end%>

-------------------------------------------------------------------------------------
3. class.head

//////////////////////////////////////////////////////////////////////////////////////////
/**
 *@name  <%class_name%>
 *@brief 
 */
class <%class_name%> {
 public:
  /**
   *@brief Default constructor
   */
  <%class_name%>( );

  /**
   *@brief Destructor
   */
  ~<%class_name%>( );

 protected:

 private:
  /**
   *@brief Copy constructor
   */
  <%class_name%>( const <%class_name%>& );

  /**
   *@brief Assignment operator
   */
  <%class_name%>& operator=( const <%class_name%>& );

 private:
};


-------------------------------------------------------------------------------------
4. class.src

//////////////////////////////////////////////////////////////////////////////////////////
//
//    <%class_name%>
//
//////////////////////////////////////////////////////////////////////////////////////////
// Default constructor
<%class_name%>::<%class_name%>( )
{
}


// Destructor
<%class_name%>::~<%class_name%>( )
{
}


-------------------------------------------------------------------------------------
5. head.act

/**
 *@file  <%file_name%>
 *
 *@brief <%module_name%>.
 *
 *@author <%login_name%>
 *@date  <%date%>
 *@version <%version%>
 *$Id: <%file_name%>,v <%version%> <%date_time%> <%login_name%> Exp $
 */


#ifndef __<%file_identifier%>_H__
#define __<%file_identifier%>_H__


//---------------------------The external header------------------------------------------

 


//---------------------------The macro definition-----------------------------------------

 


//---------------------------The variable definition--------------------------------------

 


//---------------------------The function definition--------------------------------------

 


#endif//__<%file_identifier%>_H__

 

-------------------------------------------------------------------------------------
6. main.act

/**
 *@file  <%file_name%>
 *
 *@brief <%module_name%>.
 *
 *@author <%login_name%>
 *@date  <%date%>
 *@version <%version%>
 *$Id: <%file_name%>,v <%version%> <%date_time%> <%login_name%> Exp $
 */


#ifdef linux
#include <getopt.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>

 


//---------------------------The macro definition-----------------------------------------
#define MODULE_NAME    "<%module_name%>"

 


//---------------------------The variable definition--------------------------------------

 


//---------------------------The function prototype---------------------------------------

 


//---------------------------The function definition--------------------------------------
// The main function
int main( int argc, char ** argv )
{
 int liRet = 0;
 
 return liRet;
}

posted on 2010-12-19 00:17 冰果 閱讀(541) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


                                            
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            影音先锋另类| 亚洲欧美中文另类| 亚洲欧美日韩第一区| 亚洲国产成人久久| 亚洲电影网站| 亚洲国产精品一区二区三区| **网站欧美大片在线观看| 亚洲国产成人精品视频| 日韩视频免费观看| 亚洲无线一线二线三线区别av| 99视频+国产日韩欧美| 一区二区三区你懂的| 亚洲一区久久久| 久久精品女人的天堂av| 麻豆成人精品| 99av国产精品欲麻豆| 亚洲欧美日韩综合| 久久精品免费播放| 欧美黄色成人网| 国产精品超碰97尤物18| 国产一区二区成人| av不卡在线| 久久久九九九九| 亚洲三级免费观看| 最近看过的日韩成人| 亚洲视频日本| 久久九九国产精品| 欧美视频在线观看 亚洲欧| 国产日韩成人精品| 亚洲三级网站| 久久精品中文| 99视频日韩| 开心色5月久久精品| 国产精品久久99| 亚洲黄色免费| 久久精品视频在线看| 日韩一区二区福利| 欧美成人激情在线| 国内激情久久| 亚洲欧美日韩国产一区二区三区| 美女国产一区| 亚洲一区二区免费| 欧美精品在线一区| 亚洲福利在线观看| 欧美主播一区二区三区美女 久久精品人| 老司机成人网| 午夜精品视频| 国产精品久久久久久久一区探花 | 国产精品成人一区| 国内综合精品午夜久久资源| 亚洲一区欧美二区| 亚洲精品婷婷| 欧美刺激性大交免费视频| 狠狠色丁香久久综合频道| 亚洲色图自拍| 亚洲激情视频网| 免费在线欧美黄色| 亚洲国产综合91精品麻豆| 久久久久久国产精品mv| 亚洲综合色自拍一区| 亚洲人成在线播放网站岛国| 久久久国产精彩视频美女艺术照福利| 国产精品国产三级欧美二区| 在线视频一区二区| 日韩性生活视频| 欧美日韩午夜在线视频| 一二三区精品福利视频| 亚洲精品欧美日韩| 欧美成人自拍| 日韩视频中文| 99国产精品国产精品久久| 欧美日韩精品一区二区三区| aa日韩免费精品视频一| 宅男噜噜噜66一区二区66| 欧美日韩国内| 午夜久久影院| 欧美一区亚洲二区| 在线观看欧美精品| 嫩草成人www欧美| 欧美大色视频| 一本色道婷婷久久欧美| 99亚洲一区二区| 国产精品视频男人的天堂| 欧美在线视频观看免费网站| 欧美一区二区性| 亚洲国产日韩欧美| 一本到高清视频免费精品| 国产精品一国产精品k频道56| 久久久999| 欧美二区在线播放| 亚洲女与黑人做爰| 久久精品国产亚洲一区二区三区| 亚洲高清视频一区| 夜久久久久久| 伊伊综合在线| 99精品视频免费观看视频| 国产视频一区在线观看一区免费| 老牛国产精品一区的观看方式| 欧美成人一区二区| 久久精品国产99| 欧美精品一区在线播放| 欧美在线三级| 欧美日韩一区二区三区在线看| 久久国产精品99久久久久久老狼| 久久综合九色欧美综合狠狠| 亚洲一区二区三区高清不卡| 欧美伊人久久| 亚洲欧美国产视频| 狼人天天伊人久久| 国产欧美日韩在线视频| 欧美顶级少妇做爰| 国产欧美日韩中文字幕在线| 亚洲精品一区二区三区不| 国产三级精品三级| 亚洲毛片在线| 亚洲黄色影片| 久久精品视频播放| 午夜在线电影亚洲一区| 欧美激情视频一区二区三区免费 | 99热在这里有精品免费| 精品69视频一区二区三区| 在线一区二区日韩| 日韩小视频在线观看| 久久亚洲欧美| 久久狠狠亚洲综合| 国产精品久久久一区二区三区| 亚洲福利在线观看| 在线欧美视频| 久久九九电影| 蜜臀av一级做a爰片久久| 国产日韩欧美一区二区| 亚洲亚洲精品三区日韩精品在线视频| 日韩视频在线观看免费| 另类天堂av| 欧美成人免费全部| 亚洲大片免费看| 久久婷婷成人综合色| 久久综合色婷婷| 一区二区亚洲精品国产| 久久久久久久综合狠狠综合| 久久久国产亚洲精品| 国产一区二区三区免费在线观看| 亚洲摸下面视频| 欧美一区二区三区婷婷月色| 国产精品网站在线播放| 西西人体一区二区| 久久久噜噜噜久久狠狠50岁| 国内一区二区三区在线视频| 久久精品日产第一区二区三区| 久久久精品一区| 亚洲国产精品嫩草影院| 欧美国产日韩在线观看| 日韩一级黄色大片| 午夜在线精品| 激情综合网址| 欧美福利电影网| 一本色道久久综合亚洲精品按摩| 一本大道久久a久久精品综合| 欧美日韩国产欧| 亚洲一区黄色| 久久综合九色综合欧美狠狠| 亚洲国产精品va在线看黑人| 欧美激情2020午夜免费观看| 一本大道久久a久久精二百| 久久国产精品毛片| 亚洲国产美女| 国产精品豆花视频| 久久精品91久久久久久再现| 亚洲第一中文字幕| 亚洲视频欧美在线| 国产综合色精品一区二区三区| 久热精品视频在线观看| 99视频精品全部免费在线| 久久久精品性| 一本色道久久综合亚洲精品不| 国产视频丨精品|在线观看| 亚洲精品午夜精品| 麻豆久久婷婷| 日韩视频免费观看高清在线视频| 欧美三级资源在线| 久久av一区二区三区亚洲| 亚洲高清123| 亚洲欧美国产制服动漫| 亚洲高清久久久| 国产日韩精品在线观看| 欧美成人免费播放| 午夜精品免费视频| 亚洲人成在线观看| 欧美aa在线视频| 欧美在线高清| 亚洲图中文字幕| 亚洲第一久久影院| 国产一区二区精品在线观看| 欧美日韩国产成人在线| 久久视频精品在线| 亚洲欧美精品在线观看| 日韩亚洲欧美中文三级| 免费久久99精品国产| 久久精品伊人| 欧美一区二区三区视频|