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

冰果

技術(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>
            亚洲国产精品一区二区三区| 狂野欧美性猛交xxxx巴西| 久久久久久国产精品mv| 亚洲中字在线| 欧美一区三区二区在线观看| 欧美影片第一页| 久久久精品999| 欧美在线三级| 久久久亚洲高清| 久久香蕉国产线看观看av| 免费试看一区| 欧美日韩视频第一区| 欧美午夜视频| 伊人成人开心激情综合网| 在线精品视频一区二区三四| 亚洲人成在线观看| 亚洲视频大全| 久久久蜜桃一区二区人| 亚洲二区在线视频| 99热这里只有精品8| 亚洲香蕉网站| 欧美成人激情在线| 国产精品一区二区三区久久久| 国产小视频国产精品| 亚洲国产成人午夜在线一区| 亚洲卡通欧美制服中文| 一区二区av| 亚洲精品中文字幕有码专区| 亚洲免费视频在线观看| 久久精品日韩欧美| 亚洲国产综合在线| 欧美呦呦网站| 欧美日韩亚洲系列| 黄色亚洲在线| 亚洲视频欧洲视频| 欧美a级理论片| 中文日韩电影网站| 欧美电影免费观看高清| 国产精品无码永久免费888| 91久久久精品| 久久综合精品一区| 亚洲女人av| 欧美日韩成人网| 狠狠狠色丁香婷婷综合久久五月| 亚洲视屏在线播放| 久久综合狠狠综合久久综合88| 亚洲免费高清| 麻豆成人在线| 亚洲日本乱码在线观看| 亚洲区一区二| 裸体歌舞表演一区二区| 夜色激情一区二区| 老牛嫩草一区二区三区日本| 国产精品免费aⅴ片在线观看| 91久久精品国产91性色tv| 欧美在线啊v| 欧美不卡视频| 久久九九免费| 国内视频一区| 久久久综合网| 亚洲一区二区三区高清| 欧美日韩在线综合| 一本色道久久综合亚洲精品按摩| 欧美高清在线视频| 久久综合网络一区二区| 狠狠久久婷婷| 久久综合九色综合欧美狠狠| 欧美一区二区三区四区在线| 国模叶桐国产精品一区| 欧美在线视频在线播放完整版免费观看 | 久久免费的精品国产v∧| 国产伦理一区| 久久亚洲欧美国产精品乐播| 蜜臀av性久久久久蜜臀aⅴ四虎| 国产女同一区二区| 久久久一二三| 久久午夜羞羞影院免费观看| 亚洲精品在线三区| 欧美三区在线观看| 欧美影院久久久| 欧美中文字幕视频| 亚洲国产经典视频| 亚洲第一区在线观看| 久久男女视频| 91久久综合| 亚洲视频一区| 国产综合色一区二区三区 | 在线播放视频一区| 亚洲国产精品va在线看黑人| 欧美日韩视频在线第一区| 香蕉久久国产| 久久伊人亚洲| 亚洲一区精品电影| 午夜影视日本亚洲欧洲精品| 欧美一级在线视频| 亚洲精品视频免费观看| 中文亚洲欧美| 亚洲第一区在线观看| 中国av一区| 亚洲第一成人在线| 美女网站久久| 米奇777在线欧美播放| 美女网站在线免费欧美精品| 国产精品久久夜| 久久精品亚洲一区| 欧美精选一区| 久久久999国产| 欧美日韩免费一区| 免费人成网站在线观看欧美高清| 欧美激情亚洲激情| 久久免费精品视频| 久久国产一区| 欧美在线短视频| 欧美成在线视频| 欧美亚洲一区二区三区| 欧美精品v国产精品v日韩精品| 欧美在线观看视频一区二区三区| 欧美国产成人精品| 老司机aⅴ在线精品导航| 国产精品女主播在线观看| 亚洲人体大胆视频| 国产欧美精品久久| 中文欧美在线视频| 在线综合视频| 欧美国产亚洲视频| 欧美激情一级片一区二区| 很黄很黄激情成人| 久久不见久久见免费视频1| 午夜视频在线观看一区二区三区| 麻豆国产精品777777在线| 久久久久综合网| 国产人成精品一区二区三| 日韩一区二区久久| 艳女tv在线观看国产一区| 免费在线观看日韩欧美| 久久免费少妇高潮久久精品99| 国产精品中文字幕欧美| 在线视频你懂得一区二区三区| 一区二区三区四区五区在线| 欧美激情自拍| 亚洲黄色成人久久久| 日韩视频在线观看| 欧美日韩精品免费观看视频| 亚洲精品国产精品乱码不99| 亚洲乱码久久| 欧美中文字幕在线播放| 理论片一区二区在线| 国产一在线精品一区在线观看| 欧美专区亚洲专区| 久久久久国产精品人| 1024成人| 欧美日韩三级在线| 一本色道久久综合| 亚洲欧美视频| 国产一区二区三区在线观看免费视频 | 欧美成人黄色小视频| **性色生活片久久毛片| 欧美激情一区二区三区四区| 亚洲日本欧美日韩高观看| 一区二区三区免费观看| 国产精品一级久久久| 欧美在线地址| 欧美不卡激情三级在线观看| 亚洲久久一区| 国产精品最新自拍| 久久久久久999| 亚洲欧洲在线视频| 欧美一区二区高清在线观看| 国内精品99| 免费试看一区| 亚洲免费网址| 亚洲高清不卡| 亚洲女人小视频在线观看| 国产日韩欧美不卡在线| 最近中文字幕日韩精品| 久久精品三级| 日韩网站免费观看| 国产精品一区二区你懂的| 久久久久国产精品人| 日韩午夜视频在线观看| 久久久午夜视频| 日韩小视频在线观看| 国产精品视频免费观看www| 久久亚洲综合网| 亚洲少妇一区| 欧美激情2020午夜免费观看| 亚洲欧美国产制服动漫| 亚洲国产欧美一区| 国产精品美女在线| 欧美区国产区| 美女诱惑一区| 久久国产精品久久国产精品| 亚洲无限乱码一二三四麻| 亚洲第一在线视频| 久久久亚洲高清| 午夜在线成人av| 一级日韩一区在线观看| 国产在线欧美| 国产精品乱码一区二区三区| 欧美日韩日本国产亚洲在线|