Skip to content

xuck-devel/SimpleStepCounter

Repository files navigation

SimpleStepCounter

Simple step counter for multi-language,with CLI & Java API

function overview

  • use as CLI,as automation for getting steps of many source files,aggregating,and so on.
  • also use as Java API,for development of your programs/tools.
  • multi-language support,by customizing configuration files.

how to use

as CLI:

1.call SimpleStepCounter as below:
 
for windwos:

call SimpleStepCounter.bat [rootdir including files getting steps] [output file]

for linux,other unix:

./SimpleStepCounter.sh [rootdir including files getting steps] [output file]

2.get [output file]. If need, also get log file([output file].log):
 

3.use output file(tab divided text file),by looking text editor,copy into spreadsheet,use as another program input,and so on.

as Java API:

1.add SimpleStepCounter.jar into your classpath.If use Eclipse,import Eclipse project(eclipse_project/SimpleStepCounter) into your workspace.

2.call API as below from you Java code.

File yourfile;
 
//get line count
util.stepcounter.StepCounter.getLineCount(yourfile);
 
//get execution step count,excluding comments,empty lines
util.stepcounter.StepCounter.getExecStep(yourfile);  

multi-language support

for multi-language support,change StepCounter.properties as below:

1.add supported_filetypes(in this sample, add "cppsample")

supported_filetypes=java,c,shell,general1,general2,cppsample  

2.add configration for your types ,as below:

#extentions of appended filetype
cppsample.extentions=cpp,hpp
 
#block comment start string
cppsample.blockCommentStart=/*
 
#block comment end string
cppsample.blockCommentEnd=*/
 
#line comment start string
cppsample.lineCommentStart=//
 
#line comment end string
cppsample.lineCommentEnd=\n
 
#char literal start character
cppsample.charLiteralDelim='
 
#char literal escape character
cppsample.escapeChar_charLiteral=\\
 
#string literal start character
cppsample.stringLiteralDelim="
 
#string literal escape character
cppsample.escapeChar_stringLiteral=\\