103#include "reckon_export.h"
113#define RECKON_NUM_SUPPORTED_FORMATS 21
123#define RECKON_MK_FRMT_OPT(frmt) (1ULL << (frmt))
136#define RECKON_ENV_VAR_DEBUG "RECKON_DEBUG"
#define RECKON_NUM_SUPPORTED_FORMATS
The total number of supported text formats, including supported programming languages.
Definition reckon.h:113
#define RECKON_MK_FRMT_OPT(frmt)
Macro to create a format option bitmask.
Definition reckon.h:123
void rcnCount(RcnCountStatistics *stats, RcnStatOptions options)
Performs counting operations using the specified statistics options.
RcnSourceFormatDetection rcnDetectSourceFormat(const RcnSourceFile *file)
Performs lightweight text format detection for a source file.
RcnCountOption
Options to specify which counting operations to perform.
Definition reckon.h:817
@ RCN_OPT_COUNT_CODE_LINES
Count lines of code (LOC).
Definition reckon.h:859
@ RCN_OPT_COUNT_WORDS
Count the number of words (WRD).
Definition reckon.h:830
@ RCN_OPT_COUNT_LOGICAL_LINES
Count logical lines of code (LLC).
Definition reckon.h:847
@ RCN_OPT_COUNT_PHYSICAL_LINES
Count hard physical lines (PHL).
Definition reckon.h:837
@ RCN_OPT_COUNT_CHARACTERS
Count the number of characters (CHR).
Definition reckon.h:825
uint64_t RcnCount
A count number of some metric within source text.
Definition reckon.h:375
RcnSourceText rcnMarkLogicalLinesInFile(const char *path)
Marks the counted logical lines in the source code of the specified file.
RcnFileOpStatus
Enumeration of file processing operation status codes.
Definition reckon.h:523
@ RCN_FILE_OP_OK
No error has occurred.
Definition reckon.h:528
@ RCN_FILE_OP_IO_ERROR
An I/O error has occurred during file processing.
Definition reckon.h:549
@ RCN_FILE_OP_FILE_NOT_FOUND
The provided file was not found in the file system.
Definition reckon.h:541
@ RCN_FILE_OP_ALLOC_FAILURE
A memory allocation failure has occurred during file processing.
Definition reckon.h:554
@ RCN_FILE_OP_INVALID_PATH
A provided file path is invalid or malformed.
Definition reckon.h:536
@ RCN_FILE_OP_UNKNOWN_ERROR
An unknown error has occurred.
Definition reckon.h:569
@ RCN_FILE_OP_FILE_TOO_LARGE
The file is too large to be processed.
Definition reckon.h:562
RcnFormatOption
Options for format-specific analysis behaviours.
Definition reckon.h:870
@ RCN_OPT_LANG_C
Option to select statistics for source code files written in the C programming language.
Definition reckon.h:937
@ RCN_OPT_LANG_TYPESCRIPT
Option to select statistics for source code files written in the TypeScript programming language.
Definition reckon.h:967
@ RCN_OPT_LANG_ASSEMBLY
Option to select statistics for assembly source files.
Definition reckon.h:931
@ RCN_OPT_TEXT_CMAKE
Option to select statistics for CMake source files.
Definition reckon.h:916
@ RCN_OPT_TEXT_FXML
Option to select statistics for FXML files.
Definition reckon.h:891
@ RCN_OPT_TEXT_YAML
Option to select statistics for YAML files.
Definition reckon.h:926
@ RCN_OPT_TEXT_MARKDOWN
Option to select statistics for Markdown text files.
Definition reckon.h:881
@ RCN_OPT_LANG_BATCH
Option to select statistics for Windows DOS batch files.
Definition reckon.h:978
@ RCN_OPT_LANG_BASH
Option to select statistics for source files containing Bash shell code.
Definition reckon.h:983
@ RCN_OPT_TEXT_JSON
Option to select statistics for JSON text files.
Definition reckon.h:896
@ RCN_OPT_LANG_R
Option to select statistics for source code files written in the R programming language.
Definition reckon.h:973
@ RCN_OPT_TEXT_CSS
Option to select statistics for CSS text files.
Definition reckon.h:901
@ RCN_OPT_TEXT_MAKE
Option to select statistics for Make build script files.
Definition reckon.h:921
@ RCN_OPT_TEXT_UNFORMATTED
Option to select statistics for plain text files written without any explicit formatting.
Definition reckon.h:876
@ RCN_OPT_LANG_CPP
Option to select statistics for source code files written in the C++ programming language.
Definition reckon.h:955
@ RCN_OPT_TEXT_HTML
Option to select statistics for HTML text files.
Definition reckon.h:906
@ RCN_OPT_TEXT_XML
Option to select statistics for XML files.
Definition reckon.h:886
@ RCN_OPT_LANG_JAVASCRIPT
Option to select statistics for source code files written in the JavaScript programming language.
Definition reckon.h:961
@ RCN_OPT_LANG_PYTHON
Option to select statistics for source code files written in the Python programming language.
Definition reckon.h:949
@ RCN_OPT_TEXT_SQL
Option to select statistics for SQL text files.
Definition reckon.h:911
@ RCN_OPT_LANG_JAVA
Option to select statistics for source code files written in the Java programming language.
Definition reckon.h:943
void rcnFreeSourceText(RcnSourceText *source)
Frees the previously allocated data of a RcnSourceText struct.
bool rcnIsLlcCountingSupported(RcnTextFormat format)
Indicates whether the LLC metric is supported for the specified format.
RcnCountResult rcnCountLogicalLinesStrict(RcnTextFormat language, RcnSourceText sourceCode)
Counts logical lines of code in the given source text with strict syntax checking.
RcnSourceText rcnMarkLogicalLinesInSourceText(RcnTextFormat language, RcnSourceText sourceCode)
Marks the counted logical lines in the specified source code text.
bool rcnIsLocCountingSupported(RcnTextFormat format)
Indicates whether the LOC metric is supported for the specified format.
void rcnFreeCountStatistics(RcnCountStatistics *stats)
Frees a previously allocated RcnCountStatistics struct.
RcnTextFormat
Enumeration of supported text formats and programming languages.
Definition reckon.h:145
@ RCN_LANG_R
Source files for the R programming language.
Definition reckon.h:245
@ RCN_TEXT_YAML
Text formatted in YAML, as found in files with a '.yaml' or '.yml' extension.
Definition reckon.h:204
@ RCN_LANG_JAVASCRIPT
Source files for the JavaScript programming language.
Definition reckon.h:235
@ RCN_TEXT_CMAKE
Source files for the CMake script language, as found in files with a '.cmake' extension.
Definition reckon.h:192
@ RCN_TEXT_CSS
Text formatted in CSS, as found in files with a '.css' extension.
Definition reckon.h:176
@ RCN_TEXT_MAKE
Source files for Make build scripts, as found in files with a '.mk' extension or standard names such ...
Definition reckon.h:198
@ RCN_LANG_CPP
Source files for the C++ programming language.
Definition reckon.h:230
@ RCN_TEXT_FXML
Text formatted in FXML, as found in files with a '.fxml' extension.
Definition reckon.h:166
@ RCN_TEXT_SQL
Text formatted in SQL, as found in files with a '.sql' extension.
Definition reckon.h:186
@ RCN_TEXT_HTML
Text formatted in HTML, as found in files with a '.html' extension.
Definition reckon.h:181
@ RCN_LANG_JAVA
Source files for the Java programming language.
Definition reckon.h:220
@ RCN_LANG_TYPESCRIPT
Source files for the TypeScript programming language.
Definition reckon.h:240
@ RCN_TEXT_UNFORMATTED
Text with no specific formatting, as usually found in files with a '.txt' extension.
Definition reckon.h:151
@ RCN_LANG_BATCH
Source files for Windows DOS batch scripts, as found in files with a '.bat' or '.cmd' extension.
Definition reckon.h:251
@ RCN_LANG_ASSEMBLY
Source files written in assembly, as found in files with a '.s', '.S' or '.asm' extension.
Definition reckon.h:210
@ RCN_TEXT_MARKDOWN
Text formatted in Markdown, as found in files with a '.md' extension.
Definition reckon.h:156
@ RCN_LANG_BASH
Source files for Bash shell scripts.
Definition reckon.h:256
@ RCN_LANG_C
Source files for the C programming language.
Definition reckon.h:215
@ RCN_TEXT_JSON
Text formatted in JSON, as found in files with a '.json' extension.
Definition reckon.h:171
@ RCN_LANG_PYTHON
Source files for the Python programming language.
Definition reckon.h:225
@ RCN_TEXT_XML
Text formatted in XML, as found in files with a '.xml' extension.
Definition reckon.h:161
RcnCountResult rcnCountLinesOfCode(RcnTextFormat language, RcnSourceText sourceCode)
Counts the number of lines of code (LOC) in the specified source.
RcnCountStatistics * rcnAllocCountStatistics(size_t size)
Allocates a new zero-initialized RcnCountStatistics struct.
const char * rcnGetTextFormatLabel(RcnTextFormat format)
Returns a human-readable label for the given text format.
RcnCountResult rcnCountLogicalLines(RcnTextFormat language, RcnSourceText sourceCode)
Counts the number of logical lines of code in the specified source text.
RcnCountResult rcnCountCharacters(RcnSourceText source)
Counts the number of characters in the specified source text.
RcnErrorCode
Enumeration of error states.
Definition reckon.h:267
@ RCN_ERR_NONE
No error has occurred.
Definition reckon.h:272
@ RCN_ERR_UNSUPPORTED_FORMAT
The input format or programming language is not supported.
Definition reckon.h:277
@ RCN_ERR_ALLOC_FAILURE
A memory allocation failure has occurred.
Definition reckon.h:305
@ RCN_ERR_INPUT_TOO_LARGE
The input is too large to be processed.
Definition reckon.h:289
@ RCN_ERR_INVALID_INPUT
The input provided was invalid.
Definition reckon.h:282
@ RCN_ERR_SYNTAX_ERROR
A syntax error was detected.
Definition reckon.h:298
@ RCN_ERR_UNKNOWN
An unknown error has occurred.
Definition reckon.h:312
RcnCountResult rcnCountPhysicalLines(RcnSourceText source)
Counts the number of hard physical lines in the specified source text.
RcnCountStatistics * rcnCreateCountStatistics(const char *path)
Creates a new RcnCountStatistics struct for the specified file path.
RcnCountResult rcnCountWords(RcnSourceText source)
Counts the number of words in the specified source text.
Result type for a group of analysis operations on a single source entity.
Definition reckon.h:405
bool isProcessed
Indicates whether the source entity was actually processed.
Definition reckon.h:458
RcnCount logicalLines
The counted logical lines of code.
Definition reckon.h:410
RcnCount physicalLines
The counted hard physical lines.
Definition reckon.h:425
bool hasLogicalLines
Indicates whether logical lines can be computed for the source entity.
Definition reckon.h:471
RcnCount codeLines
The counted lines of code (LOC).
Definition reckon.h:420
RcnResultState state
The state of performed operations, indicating success or failure.
Definition reckon.h:445
bool hasCodeLines
Indicates whether lines of code (LOC) can be computed for the source entity.
Definition reckon.h:485
RcnCount sourceSize
The size of the source entity in bytes.
Definition reckon.h:440
RcnCount characters
The counted characters.
Definition reckon.h:435
RcnCount words
The counted words.
Definition reckon.h:430
The count results for a set of source files.
Definition reckon.h:671
RcnSourceFile * files
The list of files subject to analysis.
Definition reckon.h:678
size_t sizeProcessed
The number of files in files that were analyzed.
Definition reckon.h:698
size_t size
The number of files in the files list.
Definition reckon.h:690
RcnCountResultGroup * results
The list of results corresponding to the analyzed files.
Definition reckon.h:685
The result type for a single code analysis operation.
Definition reckon.h:384
RcnCount count
The counted result number.
Definition reckon.h:389
RcnResultState state
The result state of the operation, indicating success or failure.
Definition reckon.h:394
A collection of source code metrics.
Definition reckon.h:710
RcnCount physicalLines[RECKON_NUM_SUPPORTED_FORMATS]
The number of hard physical lines per supported programming language.
Definition reckon.h:770
RcnResultState state
The state of the compound operation, indicating success or failure.
Definition reckon.h:807
RcnCount totalWords
The total number of words, across all files and formats.
Definition reckon.h:734
RcnCount logicalLines[RECKON_NUM_SUPPORTED_FORMATS]
The number of logical lines of code per supported programming language.
Definition reckon.h:754
RcnCountResultSet count
The set of results for each analyzed source code file.
Definition reckon.h:797
RcnCount characters[RECKON_NUM_SUPPORTED_FORMATS]
The number of characters per supported format.
Definition reckon.h:784
RcnCount totalCharacters
The total number of characters, across all files and formats.
Definition reckon.h:739
RcnCount totalSourceSize
The sum of the sizes of the source code files processed, measured in bytes.
Definition reckon.h:747
RcnCount totalLogicalLines
The total number of logical lines of code, across all files and programming languages.
Definition reckon.h:716
RcnCount totalCodeLines
The total number of lines of code (LOC), across all files and programming languages.
Definition reckon.h:724
RcnCount totalPhysicalLines
The total number of hard physical lines, across all files and formats.
Definition reckon.h:729
RcnCount words[RECKON_NUM_SUPPORTED_FORMATS]
The number of words per supported format.
Definition reckon.h:777
RcnCount sourceSize[RECKON_NUM_SUPPORTED_FORMATS]
The total size of the processed source code files per supported format.
Definition reckon.h:792
RcnCount codeLines[RECKON_NUM_SUPPORTED_FORMATS]
The number of lines of code (LOC) per supported programming language.
Definition reckon.h:763
The result status type of an operation indicating success or failure.
Definition reckon.h:334
bool ok
Whether the operation has completed without critical errors.
Definition reckon.h:363
const char * errorMessage
An optional error message describing the encountered error.
Definition reckon.h:352
RcnErrorCode errorCode
The error code indicating the type of error that has occurred.
Definition reckon.h:342
A structure representing a text source file.
Definition reckon.h:588
bool ignore
Indicates whether this file should be skipped during processing.
Definition reckon.h:629
char * path
The absolute file path of the source code file.
Definition reckon.h:593
RcnSourceText content
The text content of the source file.
Definition reckon.h:612
char * name
The name of the source code file, including the file extension.
Definition reckon.h:598
bool isContentRead
Indicates whether the content of the file has been read from the file system.
Definition reckon.h:618
RcnFileOpStatus status
The status code indicating the processing state of the source code file.
Definition reckon.h:634
char * extension
The file extension of the source code file, without a leading dot.
Definition reckon.h:603
A block of source text.
Definition reckon.h:497
char * text
The source text content, as a pointer to a byte array.
Definition reckon.h:502
size_t size
The size of the source text in bytes.
Definition reckon.h:510
Options to customize the behaviour of counting operations.
Definition reckon.h:995
uint32_t operations
Options to specify which counting operations to perform.
Definition reckon.h:1005
uint32_t formats
Options to specify which text formats to include in the counting.
Definition reckon.h:1016
bool useMultiThreading
Whether to use multi-threading when processing multiple files.
Definition reckon.h:1063
bool stopOnError
Whether to stop the processing on the first encountered error.
Definition reckon.h:1028
bool keepFileContent
Whether to keep the original file content in memory.
Definition reckon.h:1038
bool strict
Whether to use strict syntax checking when parsing source code.
Definition reckon.h:1052