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

冰果

技術群:26678700     
交流QQ: 704839634
合作: 1) 可兼職遠程辦公開發; 2) 有一套Go+Python開發的行業短信云平臺可合作;3)目前正在開發物聯網、大數據平臺。

腳本:根據模板生成簡單代碼

         在UNIX系統上進行C++開發,公司規定用vi編輯,所以寫個簡單腳本,可以根據簡單模板簡單生成C++代碼文件,  可以偷一下懶,文件頭也比較規范。里面大量使用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(通過模板生成代碼, 完成后自動進入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: 追加一個新類到已經存在的頭文件和源文件"
 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 冰果 閱讀(535) 評論(0)  編輯 收藏 引用

                                            
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美亚州一区二区三区 | 亚洲欧洲精品成人久久奇米网| 国产精品jizz在线观看美国| 欧美体内she精视频在线观看| 欧美区一区二| 欧美午夜视频一区二区| 国产欧美精品一区二区三区介绍| 国产午夜精品一区二区三区视频 | 99国产精品久久| 亚洲一区二区三区免费在线观看| 欧美一区2区视频在线观看| 久久精品国产第一区二区三区| 久久久久久久久岛国免费| 欧美高清在线视频| 国产精品三上| 亚洲国产网站| 亚洲欧美日韩成人| 你懂的视频一区二区| 99在线精品视频在线观看| 欧美中文字幕在线观看| 欧美美女操人视频| 激情五月婷婷综合| 亚洲午夜国产一区99re久久| 巨胸喷奶水www久久久免费动漫| 亚洲日产国产精品| 亚洲香蕉伊综合在人在线视看| 久久久久久久综合色一本| 国产精品igao视频网网址不卡日韩 | 性欧美暴力猛交69hd| 免费在线视频一区| 国产亚洲美州欧州综合国| 日韩一二在线观看| 免费欧美网站| 欧美伊人久久大香线蕉综合69| 欧美精品v日韩精品v国产精品| 国产三区二区一区久久| 一区二区三区欧美在线| 欧美激情片在线观看| 欧美一级久久久久久久大片| 欧美日韩天堂| 日韩系列欧美系列| 欧美大片网址| 久久精视频免费在线久久完整在线看 | 一区二区三区日韩在线观看 | 国产精品网站在线播放| 亚洲美女少妇无套啪啪呻吟| 久久夜色精品| 香蕉尹人综合在线观看| 欧美性猛交视频| 99亚洲一区二区| 欧美激情第一页xxx| 久久精品在线播放| 国产亚洲一区二区精品| 午夜精品久久| 亚洲影视在线播放| 欧美亚一区二区| 亚洲欧美成人一区二区在线电影| 亚洲精品乱码久久久久久按摩观 | 欧美成人激情视频| 亚洲国产成人在线播放| 免费在线视频一区| 老司机aⅴ在线精品导航| 在线观看福利一区| 欧美69视频| 久久综合色8888| 亚洲精品欧美精品| 亚洲区第一页| 欧美日韩一区在线视频| 亚洲影院污污.| 亚洲欧美久久久| 国产一区再线| 欧美风情在线观看| 欧美高潮视频| 亚洲愉拍自拍另类高清精品| 亚洲一卡二卡三卡四卡五卡| 国产模特精品视频久久久久 | 欧美日韩激情网| 午夜精品区一区二区三| 欧美在线电影| 亚洲欧洲精品一区| 一区二区三区久久久| 国产欧美一区二区精品仙草咪| 久久久水蜜桃| 欧美国产日本韩| 香蕉成人啪国产精品视频综合网| 新67194成人永久网站| 伊人精品在线| 亚洲精品美女| 国产一区二区观看| 亚洲高清视频在线| 国产精品久久久久久亚洲毛片| 久久夜色撩人精品| 欧美日韩国产麻豆| 久久久久久一区二区| 欧美美女操人视频| 久久久久在线| 欧美日韩精品欧美日韩精品一| 欧美在线观看视频| 欧美韩日精品| 国产亚洲欧美一区二区| 韩国视频理论视频久久| 亚洲国产成人一区| 国产精品专区一| 亚洲国产日韩在线一区模特| 国产精品久久一卡二卡| 牛人盗摄一区二区三区视频| 欧美视频日韩视频| 欧美二区在线观看| 国产欧美精品一区| 日韩视频免费大全中文字幕| 国产在线视频欧美| 一二三区精品福利视频| 亚洲高清久久网| 欧美一区二区三区婷婷月色| 99国产精品国产精品久久| 性欧美8khd高清极品| 亚洲欧美制服中文字幕| 欧美日韩美女| 亚洲人体1000| 亚洲国产第一页| 久久国产天堂福利天堂| 性色一区二区| 欧美三级中文字幕在线观看| 亚洲二区视频在线| 伊人久久噜噜噜躁狠狠躁| 亚洲午夜精品17c| 亚洲图片欧洲图片日韩av| 欧美精品三级在线观看| 亚洲第一网站| 亚洲黄色精品| 免费不卡亚洲欧美| 欧美成人一区二区三区| 亚洲成色999久久网站| 久久久久久有精品国产| 久久性天堂网| 在线免费一区三区| 久久久精品动漫| 美女黄毛**国产精品啪啪 | 亚洲特黄一级片| 欧美区日韩区| 夜夜爽av福利精品导航| 亚洲视频香蕉人妖| 欧美午夜不卡| 午夜精品福利一区二区三区av| 欧美在线高清| 伊人成人开心激情综合网| 久久国产福利国产秒拍| 欧美+日本+国产+在线a∨观看| 亚洲国产裸拍裸体视频在线观看乱了 | 亚洲精选大片| 亚洲一区二区三区久久| 国产精品久久久久久久久久三级| 亚洲午夜在线| 噜噜噜噜噜久久久久久91| 亚洲国产精品视频| 欧美理论大片| 亚洲综合第一| 欧美aⅴ一区二区三区视频| 亚洲最新中文字幕| 国产精品少妇自拍| 久久久久久**毛片大全| 欧美激情第二页| 亚洲欧美成人综合| 极品日韩久久| 欧美日韩一级片在线观看| 久久久欧美精品| 欧美一区二区三区免费视频| 久久夜色精品亚洲噜噜国产mv | 亚洲激情视频网站| 欧美手机在线视频| 校园春色综合网| 最新国产精品拍自在线播放| 亚洲欧美激情视频在线观看一区二区三区| 国产日韩欧美在线视频观看| 男女视频一区二区| 亚洲在线观看免费| 亚洲电影在线免费观看| 欧美一区二视频| 亚洲美女视频在线观看| 国内精品视频一区| 欧美日韩你懂的| 久久综合给合| 午夜精品视频在线| 夜夜嗨av一区二区三区四季av| 久久综合五月| 亚洲欧美在线一区二区| 日韩视频在线一区| 精品成人乱色一区二区| 国产精品你懂得| 欧美激情bt| 久久久久综合一区二区三区| 亚洲性夜色噜噜噜7777| 最新中文字幕一区二区三区| 久久人人爽人人| 亚洲男人av电影| 亚洲精品欧洲精品| 一区二区在线观看av| 国产午夜精品在线| 国产精品美女久久久| 欧美另类综合|