#include "loc.h"
#include "parsed_language.h"
Go to the source code of this file.
|
SourceFile * | ohcount_sourcefile_new (const char *filepath) |
|
void | ohcount_sourcefile_set_diskpath (SourceFile *sourcefile, const char *diskpath) |
|
void | ohcount_sourcefile_set_contents (SourceFile *sourcefile, const char *contents) |
|
char * | ohcount_sourcefile_get_contents (SourceFile *sourcefile) |
|
int | ohcount_sourcefile_get_contents_size (SourceFile *sourcefile) |
|
void | ohcount_sourcefile_set_language (SourceFile *sourcefile, const char *language) |
|
const char * | ohcount_sourcefile_get_language (SourceFile *sourcefile) |
|
void | ohcount_sourcefile_parse (SourceFile *sourcefile) |
|
ParsedLanguageList * | ohcount_sourcefile_get_parsed_language_list (SourceFile *sourcefile) |
|
void | ohcount_sourcefile_parse_with_callback (SourceFile *sourcefile, void(*callback)(const char *, const char *, int, int, void *), void *userdata) |
|
void | ohcount_sourcefile_parse_entities_with_callback (SourceFile *sourcefile, void(*callback)(const char *, const char *, int, int, void *), void *userdata) |
|
LicenseList * | ohcount_sourcefile_get_license_list (SourceFile *sourcefile) |
|
LocList * | ohcount_sourcefile_get_loc_list (SourceFile *sourcefile) |
|
LocDeltaList * | ohcount_sourcefile_diff (SourceFile *from, SourceFile *to) |
|
LocDelta * | ohcount_sourcefile_calc_loc_delta (SourceFile *from, const char *language, SourceFile *to) |
|
void | ohcount_sourcefile_free (SourceFile *sourcefile) |
|
SourceFileList * | ohcount_sourcefile_list_new () |
|
void | ohcount_sourcefile_list_add_file (SourceFileList *list, const char *filepath) |
|
void | ohcount_sourcefile_list_add_directory (SourceFileList *list, const char *directory) |
|
LocList * | ohcount_sourcefile_list_analyze_languages (SourceFileList *list) |
|
void | ohcount_sourcefile_list_free (SourceFileList *list) |
|
◆ ohcount_sourcefile_calc_loc_delta()
Returns a LocDelta reflecting the changes from one revision of a SourceFile to another for a given language. The given language is not copied and may not be 'free'd. Use a language defined in src/languages.h. The returned pointer must be 'free'd.
- Parameters
-
- Returns
- LocDelta
◆ ohcount_sourcefile_diff()
Returns a LocDeltaList reflecting the changes from one revision of a SourceFile to another for all languages. The returned pointer must be 'free'd.
- Parameters
-
- Returns
- LocDeltaList
◆ ohcount_sourcefile_free()
void ohcount_sourcefile_free |
( |
SourceFile * |
sourcefile | ) |
|
◆ ohcount_sourcefile_get_contents()
char * ohcount_sourcefile_get_contents |
( |
SourceFile * |
sourcefile | ) |
|
Returns the file contents of a given SourceFile. The returned pointer is used internally and may not be 'free'd.
- Parameters
-
- Returns
- pointer to string file contents.
◆ ohcount_sourcefile_get_contents_size()
int ohcount_sourcefile_get_contents_size |
( |
SourceFile * |
sourcefile | ) |
|
Returns the size of the file contents of a given SourceFile.
- Parameters
-
- Returns
- size of the file's contents.
◆ ohcount_sourcefile_get_language()
const char * ohcount_sourcefile_get_language |
( |
SourceFile * |
sourcefile | ) |
|
Returns the detected language of a given SourceFile. The returned pointer is used internally and may not be 'free'd.
- Parameters
-
- Returns
- string language name.
◆ ohcount_sourcefile_get_license_list()
Returns a LicenseList of detected licenses in the given SourceFile. The returned list and its contents are used internally and may not be 'free'd.
- Parameters
-
- Returns
- LicenseList
◆ ohcount_sourcefile_get_loc_list()
Returns a LocList of total lines of code in each language in the given SourceFile. The returned list and its contents are used internally and may not be 'free'd.
- Parameters
-
- Returns
- LocList
◆ ohcount_sourcefile_get_parsed_language_list()
Returns the ParsedLanguageList parsed out of the given SourceFile.
- Parameters
-
- Returns
- ParsedLanguageList
◆ ohcount_sourcefile_list_add_directory()
void ohcount_sourcefile_list_add_directory |
( |
SourceFileList * |
list, |
|
|
const char * |
directory |
|
) |
| |
Adds the contents of a given directory to a SourceFileList. The given directory may be 'free'd immediately.
- Parameters
-
◆ ohcount_sourcefile_list_add_file()
void ohcount_sourcefile_list_add_file |
( |
SourceFileList * |
list, |
|
|
const char * |
filepath |
|
) |
| |
Adds a given file to a SourceFileList. The given filepath is copied and may be 'free'd immediately.
- Parameters
-
◆ ohcount_sourcefile_list_analyze_languages()
Returns a new LocList for all files in the given SourceFileList.
- Parameters
-
- Returns
- LocList
◆ ohcount_sourcefile_list_free()
Frees the memory allocated for a given SourceFileList.
- Parameters
-
◆ ohcount_sourcefile_list_new()
◆ ohcount_sourcefile_new()
SourceFile * ohcount_sourcefile_new |
( |
const char * |
filepath | ) |
|
Creates and returns a new SourceFile from a given filepath. The given filepath is copied and may be 'free'd immediately.
- Parameters
-
filepath | The path to a file on disk. |
- Returns
- SourceFile
◆ ohcount_sourcefile_parse()
void ohcount_sourcefile_parse |
( |
SourceFile * |
sourcefile | ) |
|
Parses the given SourceFile with the default callback that keeps track of the number of lines of code, comments, and blank lines.
- Parameters
-
◆ ohcount_sourcefile_parse_entities_with_callback()
void ohcount_sourcefile_parse_entities_with_callback |
( |
SourceFile * |
sourcefile, |
|
|
void(*)(const char *, const char *, int, int, void *) |
callback, |
|
|
void * |
userdata |
|
) |
| |
Parses the given SourceFile with a specific callback. The callback is called for each entity parsed, not line.
- Parameters
-
sourcefile | A SourceFile created by ohcount_sourcefile_new(). |
callback | The callback function to call for every entity parsed. |
userdata | Userdata to pass to the callback function. |
◆ ohcount_sourcefile_parse_with_callback()
void ohcount_sourcefile_parse_with_callback |
( |
SourceFile * |
sourcefile, |
|
|
void(*)(const char *, const char *, int, int, void *) |
callback, |
|
|
void * |
userdata |
|
) |
| |
Parses the given SourceFile with a specific callback. The callback is called for each line parsed, not entity.
- Parameters
-
sourcefile | A SourceFile created by ohcount_sourcefile_new(). |
callback | The callback function to call for every line parsed. |
userdata | Userdata to pass to the callback function. |
◆ ohcount_sourcefile_set_contents()
void ohcount_sourcefile_set_contents |
( |
SourceFile * |
sourcefile, |
|
|
const char * |
contents |
|
) |
| |
Sets the contents of the given SourceFile. The given contents are copied and may be 'free'd immediately.
- Parameters
-
◆ ohcount_sourcefile_set_diskpath()
void ohcount_sourcefile_set_diskpath |
( |
SourceFile * |
sourcefile, |
|
|
const char * |
diskpath |
|
) |
| |
Sets the filepath on the disk of the given SourceFile. This is only used if the SourceFile's filepath field is not accurate, typically only in language detection.
- Parameters
-
◆ ohcount_sourcefile_set_language()
void ohcount_sourcefile_set_language |
( |
SourceFile * |
sourcefile, |
|
|
const char * |
language |
|
) |
| |
Sets the language of a given SourceFile. The given language copied and may be 'free'd immediately.
- Parameters
-