C API Functions

## udbMetricEntity

### Description

Return the metric value associated with the specified entity, for the specified metric.

### Syntax

     #include "udb/udb.h"
     int  udbMetricEntity(UdbEntity entity, UdbMetric metric)

### Arguments

Argument | description
--- | ---
UdbEntity entity | Specified entity to obtain metrics for.
UdbMetric metric | Specified metric to obtain.

Not all metrics are valid for all types of entities. Use udbMetricIsDefined to check if a particular metric is valid for a particular entity.

The metric names are language-specific and are defined as follows:

### Ada Body Metrics

:

Ada BODY Metrics | DESCRIPTION
--- | ---
Udb_adaMetricBCyclomatic | Also known as the McCabe (Cyclomatic) complexity. The average number of independent paths through the body
Udb_adaMetricBCyclomaticCaseOne | Average cyclomatic complexity except that each when statement is not counted; the entire case counts as 1
Udb_adaMetricBLines | Number of lines (code, comment, blank) in the body, excluding any nested program units.
Udb_adaMetricBLinesComment | Number of comment lines in the body, excluding any nested program units. Note that code lines which also contain comments will be counted in both LinesCode and LinesComment.
Udb_adaMetricBLinesBlank | Number of blank lines in the body, excluding any nested program units.
Udb_adaMetricBLinesCode | Number of code lines in the body, excluding any nested program units. Note that code lines which also contain comments will be counted in both LinesCode and LinesComment.
Udb_adaMetricBLinesCodeExe | Number of code lines in the executable section of the body, excluding any nested program units.
Udb_adaMetricBLinesCodeDec | Number of code lines in the declaration section of the body, excluding any nested program units.
Udb_adaMetricBSemiDec | Number of semicolons in the declaration section of the body, excluding any nested program units.
Udb_adaMetricBSemiExe | Number of semicolons in the executable section of the body, excluding any nested program units.
Udb_adaMetricBDecls | Number of declaration statements in the body, excluding any nested program units.
Udb_adaMetricBTLines | Number of total lines (code, comment, blank) in the body including nested program units.
Udb_adaMetricBTLinesComment | Total number of comment lines in the body including nested program units. Note that code lines which also contain comments will be counted in both LinesCode and LinesComment.
Udb_adaMetricBTLinesBlank | Total number of blank lines in the body including nested program units.
Udb_adaMetricBTLinesCode | Total number of code lines in the body including nested program units. Note that code lines which also contain comments will be counted in both LinesCode and LinesComment.
Udb_adaMetricBTLinesCodeExe | Total number of code lines in the exectuable section of the body including nested program units.
Udb_adaMetricBTLinesCodeDec | Total number of code lines in the declaration section of the body including nested program units.
Udb_adaMetricBTSemiDec | Total number of semicolons in the declaration section of the body including nested program units.
Udb_adaMetricBTSemiExe | Total number of semicolons in the executable section of the body including nested program units.
Udb_adaMetricBTDecls | Total number of semicolons in the declaration section of the body including nested program units.

### Ada Spec Metrics

:

Ada spec Metrics | DESCRIPTION
--- | ---
Udb_adaMetricSLines | Number of lines (code, comment, blank) in the spec, excluding any nested program units.
Udb_adaMetricSLinesComment | Number of comment lines in the spec, excluding any nested program units. Note that code lines which also contain comments will be counted in both LinesCode and LinesComment.
Udb_adaMetricSLinesBlank | Number of blank lines in the spec, excluding any nested program units.
Udb_adaMetricSLinesCode | Number of code lines in the spec, excluding any nested program units Note that code lines which also contain comments will be counted in both LinesCode and LinesComment.
Udb_adaMetricSLinesCodeExe | Number of code lines in the executable section of the spec, excluding any nested program units.
Udb_adaMetricSLinesCodeDec | Number of code lines in the declaration section of the spec, excluding any nested program units.
Udb_adaMetricSSemiDec | Number of semicolons in the declaration section of the spec, excluding any nested program units.
Udb_adaMetricSSemiExe | Number of semicolons in the executable section of the spec, excluding any nested program units.
Udb_adaMetricSDecls | Number of declaration statements in the spec, excluding any nested program units.
Udb_adaMetricSTLines | Total number of lines (code, comment, blank) in the spec, including nested program units.
Udb_adaMetricSTLinesComment | Total number of comment lines in the spec, including nested program units. Note that code lines which also contain comments will be counted in both LinesCode and LinesComment.
Udb_adaMetricSTLinesBlank | Total number of blank lines in the spec, including nested program units.
Udb_adaMetricSTLinesCode | Total number of code lines in the spec, including nested program units. Note that code lines which also contain comments will be counted in both LinesCode and LinesComment.
Udb_adaMetricSTLinesCodeExe | Total number of code lines in the executable section of the spec, including nested program units.
Udb_adaMetricSTLinesCodeDec | Total number of code lines in the declaration section of the spec, including nested program units.
Udb_adaMetricSTSemiDec | Total number of semicolons in the declaration section of the spec, including nested program units
Udb_adaMetricSTSemiExe | Total number of semicolons in the executable section of the spec, including nested program units
Udb_adaMetricSTDecls | Total number of declaration statements in the spec, including nested program units

### Ada File Metrics

:

Ada file Metrics | DESCRIPTION
--- | ---
Udb_adaMetricFTLines | Total number of lines (code, comment, blank) in the file.
Udb_adaMetricFTLinesComment | Total number of comment lines in the file. Note that code lines which also contain comments will be counted in both LinesCode and LinesComment.
Udb_adaMetricFTLinesBlank | Total number of blank lines in the file.
Udb_adaMetricFTLinesCode | Total number of code lines in the file. Note that code lines which also contain comments will be counted in both LinesCode and LinesComment.
Udb_adaMetricFTLinesCodeExe | Total number of code lines in the executable section of the file.
Udb_adaMetricFTLinesCodeDec | Total number of code lines in the declaration section of the file.
Udb_adaMetricFTSemiDec | Total number of semicolons in the declaration section of the file.
Udb_adaMetricFTSemiExe | Total number of semicolons in the executable section of the file.
Udb_adaMetricFTDecls | Total number of declaration statements in the file.

### C Entity Metrics

C Entity Metrics | DEscription
--- | ---
Udb_cMetricAvgCyclomatic | Also known as the McCabe (Cyclomatic) complexity. The average number of independent paths through all functions of the file.
Udb_cMetricAvgCyclomaticModified | Average cyclomatic complexity except that each case statement is not counted; the entire switch counts as 1
Udb_cMetricAvgCyclomaticStrict | Average cyclomatic complexity except that each && and || also count as one.
Udb_cMetricAvgLine | Average number of lines (blank, code, and comments) per function in the file.
Udb_cMetricAvgLineBlank | Average number of blank lines per function in the file.
Udb_cMetricAvgLineCode | Average number of lines of code per function in the file. Note that code lines which also contain comments will be counted in both LineCode and LineComment.
Udb_cMetricAvgLineComment | Average number of lines of comments per function in the file. Note that code lines which also contain comments will be counted in both LineCode and LineComment.
Udb_cMetricCountClass | Number of classes in the file.
Udb_cMetricCountFunction | Number of functions in the file.
Udb_cMetricCountLine | Number of lines (blank, code, and comments) in the file or function.
Udb_cMetricCountLineBlank | Number of blank lines in the file or function.
Udb_cMetricCountLineCode | Number of lines of code in the function or file. Note that code lines which also contain comments will be counted in both LineCode and LineComment
Udb_cMetricCountLineComment | Number of lines of comments in the function or file. Note that code lines which also contain comments will be counted in both LineCode and LineComment
Udb_cMetricCyclomatic | Also known as the McCabe (Cyclomatic) complexity. The number of independent paths through a function.
Udb_cMetricCyclomaticModified | Cyclomatic complexity except that each case statement is not counted; the entire switch counts as 1
Udb_cMetricCyclomaticStrict | Cyclomatic complexity except that each && and || also count as one.
Udb_cMetricRatioCommentCode | The ratio of comments to code for the file or function.

### Fortran Entity Metrics

FORTRAN Entity METRICS | description
--- | ---
Udb_ftnMetricAvgCyclomatic | Also known as the McCabe (Cyclomatic) complexity. The average number of independent paths through all functions of the file.
Udb_ftnMetricAvgCyclomaticCaseOne | Average cyclomatic complexity except that each case statement is not counted; the entire case select counts as 1
Udb_ftnMetricAvgLine | Average number of lines (blank, code, and comments) per function in the file.
Udb_ftnMetricAvgLineBlank | Average number of blank lines per function in the file.
Udb_ftnMetricAvgLineCode | Average number of code lines per function in the file. Note that code lines which also contain comments will be counted in both LineCode and LineComment.
Udb_ftnMetricAvgLineComment | Average number of comment lines per function in the file. Note that code lines which also contain comments will be counted in both LineCode and LineComment.
Udb_ftnMetricAvgStmtDec | Average number of declaration statements per function in the file.
Udb_ftnMetricAvgStmtExe | Average number of executable statements per function in the file.
Udb_ftnMetricCountSubprogram | Number of subprograms in the file.
Udb_ftnMetricCountLine | Total number of lines (blank, code, and comments) in the function or file.
Udb_ftnMetricCountLineBlank | Total number of blank lines in the function or file.
Udb_ftnMetricCountLineCode | Total number of code lines in the function or file. Note that code lines which also contain comments will be counted in both LineCode and LineComment.
Udb_ftnMetricCountLineComment | Total number of comment lines in the function or file. Note that code lines which also contain comments will be counted in both LineCode and LineComment.
Udb_ftnMetricCountModule | Total number of modules.
Udb_ftnMetricCountStmtDec | Total number of declarative statements in the function or file.
Udb_ftnMetricCountStmtExe | Total number of executable statements in the function or file.
Udb_ftnMetricCyclomatic | Also known as the McCabe (Cyclomatic) complexity. The number of independent paths through the function..
Udb_ftnMetricCyclomaticCaseOne | Cyclomatic complexity except that each case statement is not counted; the entire case select counts as 1
Udb_ftnMetricRatioCommentCode | The ratio of comments to code for the program unit or file.

### Return Values

Return Value | description
--- | ---
int | Returns the value of the specified metric for the specified entity.

### Example Usage

     codelines = udbMetricEntity(entity,
                                 Udb_cMetricCountLineCode);

### See Also

udbMetricEntityIsDefined to check if a particular metric is defined for a specified entity.

udbMetricIsRatio to check if the metric is a ratio.

udbMetricProject to get project-level metrics.

Scientific Toolworks, Inc. http://www.scitools.com Voice: (802) 763-2995 Fax: (802) 763-3066 support@scitools.com sales@scitools.com