ohcount: /Users/andy/dev/ohcount/src/loc.h File Reference

# /Users/andy/dev/ohcount/src/loc.h File Reference

`#include "structs.h"`

Go to the source code of this file.

## Functions
Loc * | ohcount_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)
LocList * | ohcount_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)
Loc * | ohcount_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)
LocList * | ohcount_loc_list_new_compact (LocList *list)
void | ohcount_loc_list_free (LocList *list)
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)
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)
LocDeltaList * | ohcount_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)
LocDelta * | ohcount_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)
LocDeltaList * | ohcount_loc_delta_list_new_compact (LocDeltaList *list)
void | ohcount_loc_delta_list_free (LocDeltaList *list)

## Function Documentation

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:

  | loc | A Loc created from ohcount_loc_new().
  | other | Another Loc.

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:

  | delta | A LocDelta created from ohcount_loc_delta_new().
  | other | Another LocDelta.

void ohcount_loc_delta_free | ( | LocDelta * | delta | ) |

Frees the memory allocated for a given LocDelta.

Parameters:

  | delta | A LocDelta created from ohcount_loc_delta_new().

int ohcount_loc_delta_is_changed | ( | LocDelta * | delta | ) |

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

Parameters:

  | delta | A LocDelta created from ohcount_loc_delta_new().

int ohcount_loc_delta_is_equal | ( | LocDelta * | delta,
|  | LocDelta * | other |
| ) |  |  |

Returns whether or not two given LocDeltas are equivalent.

Parameters:

  | delta | A LocDelta created from ohcount_loc_delta_new().
  | other | Another LocDelta.

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:

  | list | A LocDeltaList created from ohcount_loc_delta_list_new().
  | delta | A LocDelta created from ohcount_loc_delta_new().

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:

  | list | A LocDeltaList created from ohcount_loc_delta_list_new().
  | loc_delta_list | Another LocDeltaList.

int ohcount_loc_delta_list_blanks_added | ( | LocDeltaList * | list | ) |

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

Parameters:

  | list | A LocDeltaList created from ohcount_loc_delta_list_new().

int ohcount_loc_delta_list_blanks_removed | ( | LocDeltaList * | list | ) |

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

Parameters:

  | list | A LocDeltaList created from ohcount_loc_delta_list_new().

int ohcount_loc_delta_list_code_added | ( | LocDeltaList * | list | ) |

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

Parameters:

  | list | A LocDeltaList created from ohcount_loc_delta_list_new().

int ohcount_loc_delta_list_code_removed | ( | LocDeltaList * | list | ) |

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

Parameters:

  | list | A LocDeltaList created from ohcount_loc_delta_list_new().

int ohcount_loc_delta_list_comments_added | ( | LocDeltaList * | list | ) |

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

Parameters:

  | list | A LocDeltaList created from ohcount_loc_delta_list_new().

int ohcount_loc_delta_list_comments_removed | ( | LocDeltaList * | list | ) |

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

Parameters:

  | list | A LocDeltaList created from ohcount_loc_delta_list_new().

void ohcount_loc_delta_list_free | ( | LocDeltaList * | list | ) |

Frees the memory allocated for a given LocDeltaList.

Parameters:

  | list | A LocDeltaList created from ohcount_loc_delta_list_new().

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:

  | list | A LocDeltaList created from ohcount_loc_delta_list_new().
  | language | The language of the LocDelta to retrieve.

Returns:
  LocDelta or NULL.

int ohcount_loc_delta_list_net_blanks | ( | LocDeltaList * | list | ) |

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

Parameters:

  | list | A LocDeltaList created from ohcount_loc_delta_list_new().

int ohcount_loc_delta_list_net_code | ( | LocDeltaList * | list | ) |

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

Parameters:

  | list | A LocDeltaList created from ohcount_loc_delta_list_new().

int ohcount_loc_delta_list_net_comments | ( | LocDeltaList * | list | ) |

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

Parameters:

  | list | A LocDeltaList created from ohcount_loc_delta_list_new().

int ohcount_loc_delta_list_net_total | ( | LocDeltaList * | list | ) |

Returns the net number of lines for the given LocDeltaList.

Parameters:

  | list | A LocDeltaList created from 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

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:

  | list | A LocDeltaList created from ohcount_loc_delta_list_new().

int ohcount_loc_delta_net_blanks | ( | LocDelta * | delta | ) |

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

Parameters:

  | delta | A LocDelta created from ohcount_loc_delta_new().

int ohcount_loc_delta_net_code | ( | LocDelta * | delta | ) |

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

Parameters:

  | delta | A LocDelta created from ohcount_loc_delta_new().

int ohcount_loc_delta_net_comments | ( | LocDelta * | delta | ) |

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

Parameters:

  | delta | A LocDelta created from ohcount_loc_delta_new().

int ohcount_loc_delta_net_total | ( | LocDelta * | delta | ) |

Returns the net number of lines in a given LocDelta.

Parameters:

  | delta | A LocDelta created from 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:

  | language | The language being counted.
  | code_added | The number of lines of code added in this delta.
  | code_removed | The number of lines of code removed in this delta.
  | comments_added | The number of lines of comments added in this delta.
  | comments_removed | The number of lines of comments removed in this delta.
  | blanks_added | The number of blank lines added in this delta.
  | blanks_removed | The number of blank lines removed in this delta.

Returns:
  LocDelta

void ohcount_loc_free | ( | Loc * | loc | ) |

Frees the memory allocated for a given Loc.

Parameters:

  | loc | A Loc created from ohcount_loc_new().

int ohcount_loc_is_equal | ( | Loc * | loc,
|  | Loc * | other |
| ) |  |  |

Returns whether or not two given Locs are equivalent.

Parameters:

  | loc | A Loc created from ohcount_loc_new().
  | other | Another 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:

  | list | a LocList created from ohcount_loc_list_new().
  | loc | A Loc created from ohcount_loc_new().

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:

  | list | A LocList created from ohcount_loc_list_new().
  | loc_list | Another LocList.

int ohcount_loc_list_blanks | ( | LocList * | list | ) |

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

Parameters:

  | list | A LocList created from ohcount_loc_list_new().

int ohcount_loc_list_code | ( | LocList * | list | ) |

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

Parameters:

  | list | A LocList created from ohcount_loc_list_new().

int ohcount_loc_list_comments | ( | LocList * | list | ) |

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

Parameters:

  | list | A LocList created from ohcount_loc_list_new().

int ohcount_loc_list_filecount | ( | LocList * | list | ) |

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

Parameters:

  | list | A LocList created from ohcount_loc_list_new().

void ohcount_loc_list_free | ( | LocList * | list | ) |

Frees the memory allocated for a given LocList.

Parameters:

  | list | A LocList created from ohcount_loc_list_new().

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:

  | list | A LocList created from ohcount_loc_list_new().
  | language | The language of the Loc to retrieve.

Returns:
  Loc or NULL.

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

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:

  | list | A LocList created from ohcount_loc_list_new().

int ohcount_loc_list_total | ( | LocList * | list | ) |

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

Parameters:

  | list | A LocList created from ohcount_loc_list_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:

  | language | The language being counted.
  | code | The number of lines of code counted.
  | comments | The number of lines of comments counted.
  | blanks | The number of blank lines counted.
  | filecount | The number of files counted for this set.

Returns:
  Loc

int ohcount_loc_total | ( | Loc * | loc | ) |

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

Parameters:

  | loc | A Loc created from ohcount_loc_new().