ohcount
Functions
loc.h File Reference
#include "structs.h"

Go to the source code of this file.

Functions

Locohcount_loc_new (const char *language, int code, int comments, int blanks, int filecount)
 
int ohcount_loc_total (Loc *loc)
 
void ohcount_loc_add_loc (Loc *loc, Loc *other)
 
int ohcount_loc_is_equal (Loc *loc, Loc *other)
 
void ohcount_loc_free (Loc *loc)
 
LocListohcount_loc_list_new ()
 
void ohcount_loc_list_add_loc (LocList *list, Loc *loc)
 
void ohcount_loc_list_add_loc_list (LocList *list, LocList *loc_list)
 
Locohcount_loc_list_get_loc (LocList *list, const char *language)
 
int ohcount_loc_list_code (LocList *list)
 
int ohcount_loc_list_comments (LocList *list)
 
int ohcount_loc_list_blanks (LocList *list)
 
int ohcount_loc_list_total (LocList *list)
 
int ohcount_loc_list_filecount (LocList *list)
 
LocListohcount_loc_list_new_compact (LocList *list)
 
void ohcount_loc_list_free (LocList *list)
 
LocDeltaohcount_loc_delta_new (const char *language, int code_added, int code_removed, int comments_added, int comments_removed, int blanks_added, int blanks_removed)
 
int ohcount_loc_delta_net_code (LocDelta *delta)
 
int ohcount_loc_delta_net_comments (LocDelta *delta)
 
int ohcount_loc_delta_net_blanks (LocDelta *delta)
 
int ohcount_loc_delta_net_total (LocDelta *delta)
 
void ohcount_loc_delta_add_loc_delta (LocDelta *delta, LocDelta *other)
 
int ohcount_loc_delta_is_changed (LocDelta *delta)
 
int ohcount_loc_delta_is_equal (LocDelta *delta, LocDelta *other)
 
void ohcount_loc_delta_free (LocDelta *delta)
 
LocDeltaListohcount_loc_delta_list_new ()
 
void ohcount_loc_delta_list_add_loc_delta (LocDeltaList *list, LocDelta *delta)
 
void ohcount_loc_delta_list_add_loc_delta_list (LocDeltaList *list, LocDeltaList *loc_delta_list)
 
LocDeltaohcount_loc_delta_list_get_loc_delta (LocDeltaList *list, const char *language)
 
int ohcount_loc_delta_list_code_added (LocDeltaList *list)
 
int ohcount_loc_delta_list_code_removed (LocDeltaList *list)
 
int ohcount_loc_delta_list_comments_added (LocDeltaList *list)
 
int ohcount_loc_delta_list_comments_removed (LocDeltaList *list)
 
int ohcount_loc_delta_list_blanks_added (LocDeltaList *list)
 
int ohcount_loc_delta_list_blanks_removed (LocDeltaList *list)
 
int ohcount_loc_delta_list_net_code (LocDeltaList *list)
 
int ohcount_loc_delta_list_net_comments (LocDeltaList *list)
 
int ohcount_loc_delta_list_net_blanks (LocDeltaList *list)
 
int ohcount_loc_delta_list_net_total (LocDeltaList *list)
 
LocDeltaListohcount_loc_delta_list_new_compact (LocDeltaList *list)
 
void ohcount_loc_delta_list_free (LocDeltaList *list)
 

Function Documentation

◆ ohcount_loc_add_loc()

void ohcount_loc_add_loc ( Loc loc,
Loc other 
)

Adds a Loc to another, provided they use the same language. The results are stored in the first Loc given. The second Loc may be 'free'd immediately.

Parameters
locA Loc created from ohcount_loc_new().
otherAnother Loc.

◆ ohcount_loc_delta_add_loc_delta()

void ohcount_loc_delta_add_loc_delta ( LocDelta delta,
LocDelta other 
)

Adds a LocDelta to another, provided they use the same language. The results are stored in the first LocDelta given. The second LocDelta may be 'free'd immediately.

Parameters
deltaA LocDelta created from ohcount_loc_delta_new().
otherAnother LocDelta.

◆ ohcount_loc_delta_free()

void ohcount_loc_delta_free ( LocDelta delta)

Frees the memory allocated for a given LocDelta.

Parameters
deltaA LocDelta created from ohcount_loc_delta_new().

◆ ohcount_loc_delta_is_changed()

int ohcount_loc_delta_is_changed ( LocDelta delta)

Returns whether or not a given LocDelta has any line changes.

Parameters
deltaA LocDelta created from ohcount_loc_delta_new().

◆ ohcount_loc_delta_is_equal()

int ohcount_loc_delta_is_equal ( LocDelta delta,
LocDelta other 
)

Returns whether or not two given LocDeltas are equivalent.

Parameters
deltaA LocDelta created from ohcount_loc_delta_new().
otherAnother LocDelta.

◆ ohcount_loc_delta_list_add_loc_delta()

void ohcount_loc_delta_list_add_loc_delta ( LocDeltaList list,
LocDelta delta 
)

Adds a given LocDelta to a LocDeltaList. The given LocDelta is copied and may be 'free'd immediately.

Parameters
listA LocDeltaList created from ohcount_loc_delta_list_new().
deltaA LocDelta created from ohcount_loc_delta_new().

◆ ohcount_loc_delta_list_add_loc_delta_list()

void ohcount_loc_delta_list_add_loc_delta_list ( LocDeltaList list,
LocDeltaList loc_delta_list 
)

Adds a given LocDeltaList to another LocDeltaList. The results are stored in the first LocDeltaList given. The second LocDeltaList may be 'free'd immediately.

Parameters
listA LocDeltaList created from ohcount_loc_delta_list_new().
loc_delta_listAnother LocDeltaList.

◆ ohcount_loc_delta_list_blanks_added()

int ohcount_loc_delta_list_blanks_added ( LocDeltaList list)

Returns the number of blank lines added for the given LocDeltaList.

Parameters
listA LocDeltaList created from ohcount_loc_delta_list_new().

◆ ohcount_loc_delta_list_blanks_removed()

int ohcount_loc_delta_list_blanks_removed ( LocDeltaList list)

Returns the number of blank lines removed for the given LocDeltaList.

Parameters
listA LocDeltaList created from ohcount_loc_delta_list_new().

◆ ohcount_loc_delta_list_code_added()

int ohcount_loc_delta_list_code_added ( LocDeltaList list)

Returns the number of lines of code added for the given LocDeltaList.

Parameters
listA LocDeltaList created from ohcount_loc_delta_list_new().

◆ ohcount_loc_delta_list_code_removed()

int ohcount_loc_delta_list_code_removed ( LocDeltaList list)

Returns the number of lines of code removed for the given LocDeltaList.

Parameters
listA LocDeltaList created from ohcount_loc_delta_list_new().

◆ ohcount_loc_delta_list_comments_added()

int ohcount_loc_delta_list_comments_added ( LocDeltaList list)

Returns the number of lines of comments added for the given LocDeltaList.

Parameters
listA LocDeltaList created from ohcount_loc_delta_list_new().

◆ ohcount_loc_delta_list_comments_removed()

int ohcount_loc_delta_list_comments_removed ( LocDeltaList list)

Returns the number of lines of comments removed for the given LocDeltaList.

Parameters
listA LocDeltaList created from ohcount_loc_delta_list_new().

◆ ohcount_loc_delta_list_free()

void ohcount_loc_delta_list_free ( LocDeltaList list)

Frees the memory allocated for a given LocDeltaList.

Parameters
listA LocDeltaList created from ohcount_loc_delta_list_new().

◆ ohcount_loc_delta_list_get_loc_delta()

LocDelta * ohcount_loc_delta_list_get_loc_delta ( LocDeltaList list,
const char *  language 
)

Returns a LocDelta from a given LocDeltaList and language. The returned pointer is used internally and may not be 'free'd.

Parameters
listA LocDeltaList created from ohcount_loc_delta_list_new().
languageThe language of the LocDelta to retrieve.
Returns
LocDelta or NULL.

◆ ohcount_loc_delta_list_net_blanks()

int ohcount_loc_delta_list_net_blanks ( LocDeltaList list)

Returns the net number of blank lines for the given LocDeltaList.

Parameters
listA LocDeltaList created from ohcount_loc_delta_list_new().

◆ ohcount_loc_delta_list_net_code()

int ohcount_loc_delta_list_net_code ( LocDeltaList list)

Returns the net number of lines of code for the given LocDeltaList.

Parameters
listA LocDeltaList created from ohcount_loc_delta_list_new().

◆ ohcount_loc_delta_list_net_comments()

int ohcount_loc_delta_list_net_comments ( LocDeltaList list)

Returns the net number of lines of comments for the given LocDeltaList.

Parameters
listA LocDeltaList created from ohcount_loc_delta_list_new().

◆ ohcount_loc_delta_list_net_total()

int ohcount_loc_delta_list_net_total ( LocDeltaList list)

Returns the net number of lines for the given LocDeltaList.

Parameters
listA LocDeltaList created from ohcount_loc_delta_list_new().

◆ ohcount_loc_delta_list_new()

LocDeltaList * ohcount_loc_delta_list_new ( )

Creates a new LocDeltaList that is initially empty. LocDeltas can be added using ohcount&oc_delta_list_add_loc_delta().

Returns
LocDeltaList

◆ ohcount_loc_delta_list_new_compact()

LocDeltaList * ohcount_loc_delta_list_new_compact ( LocDeltaList list)

Creates a new LocDeltaList from a given one, excluding all LocDeltas with no counted lines. The given list may be 'free'd immediately.

Parameters
listA LocDeltaList created from ohcount_loc_delta_list_new().

◆ ohcount_loc_delta_net_blanks()

int ohcount_loc_delta_net_blanks ( LocDelta delta)

Returns the net number of blank lines in a given LocDelta.

Parameters
deltaA LocDelta created from ohcount_loc_delta_new().

◆ ohcount_loc_delta_net_code()

int ohcount_loc_delta_net_code ( LocDelta delta)

Returns the net number of lines of code in a given LocDelta.

Parameters
deltaA LocDelta created from ohcount_loc_delta_new().

◆ ohcount_loc_delta_net_comments()

int ohcount_loc_delta_net_comments ( LocDelta delta)

Returns the net number of lines of comments in a given LocDelta.

Parameters
deltaA LocDelta created from ohcount_loc_delta_new().

◆ ohcount_loc_delta_net_total()

int ohcount_loc_delta_net_total ( LocDelta delta)

Returns the net number of lines in a given LocDelta.

Parameters
deltaA LocDelta created from ohcount_loc_delta_new().

◆ ohcount_loc_delta_new()

LocDelta * ohcount_loc_delta_new ( const char *  language,
int  code_added,
int  code_removed,
int  comments_added,
int  comments_removed,
int  blanks_added,
int  blanks_removed 
)

Creates a new LocDelta from the given language and lines of code, comments, and blanks added and removed. The given language is not copied and may not be 'free'd. Use a language defined in src/languages.h.

Parameters
languageThe language being counted.
code_addedThe number of lines of code added in this delta.
code_removedThe number of lines of code removed in this delta.
comments_addedThe number of lines of comments added in this delta.
comments_removedThe number of lines of comments removed in this delta.
blanks_addedThe number of blank lines added in this delta.
blanks_removedThe number of blank lines removed in this delta.
Returns
LocDelta

◆ ohcount_loc_free()

void ohcount_loc_free ( Loc loc)

Frees the memory allocated for a given Loc.

Parameters
locA Loc created from ohcount_loc_new().

◆ ohcount_loc_is_equal()

int ohcount_loc_is_equal ( Loc loc,
Loc other 
)

Returns whether or not two given Locs are equivalent.

Parameters
locA Loc created from ohcount_loc_new().
otherAnother Loc.

◆ ohcount_loc_list_add_loc()

void ohcount_loc_list_add_loc ( LocList list,
Loc loc 
)

Adds a given Loc to a LocList. The given Loc is copied and may be 'free'd immediately.

Parameters
lista LocList created from ohcount_loc_list_new().
locA Loc created from ohcount_loc_new().

◆ ohcount_loc_list_add_loc_list()

void ohcount_loc_list_add_loc_list ( LocList list,
LocList loc_list 
)

Adds a given LocList to another LocList. The results are stored in the first LocList given. The second LocList may be 'free'd immediately.

Parameters
listA LocList created from ohcount_loc_list_new().
loc_listAnother LocList.

◆ ohcount_loc_list_blanks()

int ohcount_loc_list_blanks ( LocList list)

Returns the number of blank lines for all Locs in this LocList.

Parameters
listA LocList created from ohcount_loc_list_new().

◆ ohcount_loc_list_code()

int ohcount_loc_list_code ( LocList list)

Returns the number of lines of code for all Locs in this LocList.

Parameters
listA LocList created from ohcount_loc_list_new().

◆ ohcount_loc_list_comments()

int ohcount_loc_list_comments ( LocList list)

Returns the number of lines of commentsfor all Locs in this LocList.

Parameters
listA LocList created from ohcount_loc_list_new().

◆ ohcount_loc_list_filecount()

int ohcount_loc_list_filecount ( LocList list)

Returns the number of files counted for all Locs in this LocList.

Parameters
listA LocList created from ohcount_loc_list_new().

◆ ohcount_loc_list_free()

void ohcount_loc_list_free ( LocList list)

Frees the memory allocated for a given LocList.

Parameters
listA LocList created from ohcount_loc_list_new().

◆ ohcount_loc_list_get_loc()

Loc * ohcount_loc_list_get_loc ( LocList list,
const char *  language 
)

Returns a Loc from a given LocList and language. The returned pointer is used internally and may not be 'free'd.

Parameters
listA LocList created from ohcount_loc_list_new().
languageThe language of the Loc to retrieve.
Returns
Loc or NULL.

◆ ohcount_loc_list_new()

LocList * ohcount_loc_list_new ( )

Creates a new LocList that is initially empty. Locs can be added using ohcount_loc_list_add_loc().

Returns
LocList

◆ ohcount_loc_list_new_compact()

LocList * ohcount_loc_list_new_compact ( LocList list)

Creates a new LocList from a given one, excluding all Locs with no counted lines. The given list may be 'free'd immediately.

Parameters
listA LocList created from ohcount_loc_list_new().

◆ ohcount_loc_list_total()

int ohcount_loc_list_total ( LocList list)

Returns the total number of lines for all Locs in this LocList.

Parameters
listA LocList created from ohcount_loc_list_new().

◆ ohcount_loc_new()

Loc * ohcount_loc_new ( const char *  language,
int  code,
int  comments,
int  blanks,
int  filecount 
)

Creates a new Loc from the given language, lines of code, comments, and blanks, and number of files counted. The given language is not copied and may not be 'free'd. Use a language defined in src/languages.h.

Parameters
languageThe language being counted.
codeThe number of lines of code counted.
commentsThe number of lines of comments counted.
blanksThe number of blank lines counted.
filecountThe number of files counted for this set.
Returns
Loc

◆ ohcount_loc_total()

int ohcount_loc_total ( Loc loc)

Returns the total number of lines counted for a given Loc.

Parameters
locA Loc created from ohcount_loc_new().