1 // loc.h written by Mitchell Foral. mitchell<att>caladbolg.net.
2 // See COPYING for license information.
10 * Creates a new Loc from the given language, lines of code, comments, and
11 * blanks, and number of files counted.
12 * The given language is not copied and may not be 'free'd. Use a language
13 * defined in src/languages.h.
14 * @param language The language being counted.
15 * @param code The number of lines of code counted.
16 * @param comments The number of lines of comments counted.
17 * @param blanks The number of blank lines counted.
18 * @param filecount The number of files counted for this set.
21 Loc *ohcount_loc_new(const char *language, int code, int comments, int blanks,
25 * Returns the total number of lines counted for a given Loc.
26 * @param loc A Loc created from ohcount_loc_new().
28 int ohcount_loc_total(Loc *loc);
31 * Adds a Loc to another, provided they use the same language.
32 * The results are stored in the first Loc given. The second Loc may be 'free'd
34 * @param loc A Loc created from ohcount_loc_new().
35 * @param other Another Loc.
37 void ohcount_loc_add_loc(Loc *loc, Loc *other);
40 * Returns whether or not two given Locs are equivalent.
41 * @param loc A Loc created from ohcount_loc_new().
42 * @param other Another Loc.
44 int ohcount_loc_is_equal(Loc *loc, Loc *other);
47 * Frees the memory allocated for a given Loc.
48 * @param loc A Loc created from ohcount_loc_new().
50 void ohcount_loc_free(Loc *loc);
53 * Creates a new LocList that is initially empty.
54 * Locs can be added using ohcount_loc_list_add_loc().
57 LocList *ohcount_loc_list_new();
60 * Adds a given Loc to a LocList.
61 * The given Loc is copied and may be 'free'd immediately.
62 * @param list a LocList created from ohcount_loc_list_new().
63 * @param loc A Loc created from ohcount_loc_new().
65 void ohcount_loc_list_add_loc(LocList *list, Loc *loc);
68 * Adds a given LocList to another LocList.
69 * The results are stored in the first LocList given. The second LocList may be
70 * 'free'd immediately.
71 * @param list A LocList created from ohcount_loc_list_new().
72 * @param loc_list Another LocList.
74 void ohcount_loc_list_add_loc_list(LocList *list, LocList *loc_list);
77 * Returns a Loc from a given LocList and language.
78 * The returned pointer is used internally and may not be 'free'd.
79 * @param list A LocList created from ohcount_loc_list_new().
80 * @param language The language of the Loc to retrieve.
81 * @return Loc or NULL.
83 Loc *ohcount_loc_list_get_loc(LocList *list, const char *language);
86 * Returns the number of lines of code for all Locs in this LocList.
87 * @param list A LocList created from ohcount_loc_list_new().
89 int ohcount_loc_list_code(LocList *list);
92 * Returns the number of lines of commentsfor all Locs in this LocList.
93 * @param list A LocList created from ohcount_loc_list_new().
95 int ohcount_loc_list_comments(LocList *list);
98 * Returns the number of blank lines for all Locs in this LocList.
99 * @param list A LocList created from ohcount_loc_list_new().
101 int ohcount_loc_list_blanks(LocList *list);
104 * Returns the total number of lines for all Locs in this LocList.
105 * @param list A LocList created from ohcount_loc_list_new().
107 int ohcount_loc_list_total(LocList *list);
110 * Returns the number of files counted for all Locs in this LocList.
111 * @param list A LocList created from ohcount_loc_list_new().
113 int ohcount_loc_list_filecount(LocList *list);
116 * Creates a new LocList from a given one, excluding all Locs with no counted
118 * The given list may be 'free'd immediately.
119 * @param list A LocList created from ohcount_loc_list_new().
121 LocList *ohcount_loc_list_new_compact(LocList *list);
124 * Frees the memory allocated for a given LocList.
125 * @param list A LocList created from ohcount_loc_list_new().
127 void ohcount_loc_list_free(LocList *list);
130 * Creates a new LocDelta from the given language and lines of code, comments,
131 * and blanks added and removed.
132 * The given language is not copied and may not be 'free'd. Use a language
133 * defined in src/languages.h.
134 * @param language The language being counted.
135 * @param code_added The number of lines of code added in this delta.
136 * @param code_removed The number of lines of code removed in this delta.
137 * @param comments_added The number of lines of comments added in this delta.
138 * @param comments_removed The number of lines of comments removed in this
140 * @param blanks_added The number of blank lines added in this delta.
141 * @param blanks_removed The number of blank lines removed in this delta.
144 LocDelta *ohcount_loc_delta_new(const char *language, int code_added,
145 int code_removed, int comments_added,
146 int comments_removed, int blanks_added,
150 * Returns the net number of lines of code in a given LocDelta.
151 * @param delta A LocDelta created from ohcount_loc_delta_new().
153 int ohcount_loc_delta_net_code(LocDelta *delta);
156 * Returns the net number of lines of comments in a given LocDelta.
157 * @param delta A LocDelta created from ohcount_loc_delta_new().
159 int ohcount_loc_delta_net_comments(LocDelta *delta);
162 * Returns the net number of blank lines in a given LocDelta.
163 * @param delta A LocDelta created from ohcount_loc_delta_new().
165 int ohcount_loc_delta_net_blanks(LocDelta *delta);
168 * Returns the net number of lines in a given LocDelta.
169 * @param delta A LocDelta created from ohcount_loc_delta_new().
171 int ohcount_loc_delta_net_total(LocDelta *delta);
174 * Adds a LocDelta to another, provided they use the same language.
175 * The results are stored in the first LocDelta given. The second LocDelta may
176 * be 'free'd immediately.
177 * @param delta A LocDelta created from ohcount_loc_delta_new().
178 * @param other Another LocDelta.
180 void ohcount_loc_delta_add_loc_delta(LocDelta *delta, LocDelta *other);
183 * Returns whether or not a given LocDelta has any line changes.
184 * @param delta A LocDelta created from ohcount_loc_delta_new().
186 int ohcount_loc_delta_is_changed(LocDelta *delta);
189 * Returns whether or not two given LocDeltas are equivalent.
190 * @param delta A LocDelta created from ohcount_loc_delta_new().
191 * @param other Another LocDelta.
193 int ohcount_loc_delta_is_equal(LocDelta *delta, LocDelta *other);
196 * Frees the memory allocated for a given LocDelta.
197 * @param delta A LocDelta created from ohcount_loc_delta_new().
199 void ohcount_loc_delta_free(LocDelta *delta);
202 * Creates a new LocDeltaList that is initially empty.
203 * LocDeltas can be added using ohcount&oc_delta_list_add_loc_delta().
204 * @return LocDeltaList
206 LocDeltaList *ohcount_loc_delta_list_new();
209 * Adds a given LocDelta to a LocDeltaList.
210 * The given LocDelta is copied and may be 'free'd immediately.
211 * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
212 * @param delta A LocDelta created from ohcount_loc_delta_new().
214 void ohcount_loc_delta_list_add_loc_delta(LocDeltaList *list, LocDelta *delta);
217 * Adds a given LocDeltaList to another LocDeltaList.
218 * The results are stored in the first LocDeltaList given. The second
219 * LocDeltaList may be 'free'd immediately.
220 * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
221 * @param loc_delta_list Another LocDeltaList.
223 void ohcount_loc_delta_list_add_loc_delta_list(LocDeltaList *list,
224 LocDeltaList *loc_delta_list);
227 * Returns a LocDelta from a given LocDeltaList and language.
228 * The returned pointer is used internally and may not be 'free'd.
229 * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
230 * @param language The language of the LocDelta to retrieve.
231 * @return LocDelta or NULL.
233 LocDelta *ohcount_loc_delta_list_get_loc_delta(LocDeltaList *list,
234 const char *language);
237 * Returns the number of lines of code added for the given LocDeltaList.
238 * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
240 int ohcount_loc_delta_list_code_added(LocDeltaList *list);
243 * Returns the number of lines of code removed for the given LocDeltaList.
244 * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
246 int ohcount_loc_delta_list_code_removed(LocDeltaList *list);
249 * Returns the number of lines of comments added for the given LocDeltaList.
250 * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
252 int ohcount_loc_delta_list_comments_added(LocDeltaList *list);
255 * Returns the number of lines of comments removed for the given LocDeltaList.
256 * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
258 int ohcount_loc_delta_list_comments_removed(LocDeltaList *list);
261 * Returns the number of blank lines added for the given LocDeltaList.
262 * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
264 int ohcount_loc_delta_list_blanks_added(LocDeltaList *list);
267 * Returns the number of blank lines removed for the given LocDeltaList.
268 * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
270 int ohcount_loc_delta_list_blanks_removed(LocDeltaList *list);
273 * Returns the net number of lines of code for the given LocDeltaList.
274 * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
276 int ohcount_loc_delta_list_net_code(LocDeltaList *list);
279 * Returns the net number of lines of comments for the given LocDeltaList.
280 * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
282 int ohcount_loc_delta_list_net_comments(LocDeltaList *list);
285 * Returns the net number of blank lines for the given LocDeltaList.
286 * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
288 int ohcount_loc_delta_list_net_blanks(LocDeltaList *list);
291 * Returns the net number of lines for the given LocDeltaList.
292 * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
294 int ohcount_loc_delta_list_net_total(LocDeltaList *list);
297 * Creates a new LocDeltaList from a given one, excluding all LocDeltas with no
299 * The given list may be 'free'd immediately.
300 * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
302 LocDeltaList *ohcount_loc_delta_list_new_compact(LocDeltaList *list);
305 * Frees the memory allocated for a given LocDeltaList.
306 * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
308 void ohcount_loc_delta_list_free(LocDeltaList *list);