Removed gestalt options from C ohcount (use ruby/gestalt.rb).
[ohcount] / src / loc.h
1 // loc.h written by Mitchell Foral. mitchell<att>caladbolg.net.
2 // See COPYING for license information.
3
4 #ifndef OHCOUNT_LOC_H
5 #define OHCOUNT_LOC_H
6
7 #include "structs.h"
8
9 /**
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.
19  * @return Loc
20  */
21 Loc *ohcount_loc_new(const char *language, int code, int comments, int blanks,
22                      int filecount);
23
24 /**
25  * Returns the total number of lines counted for a given Loc.
26  * @param loc A Loc created from ohcount_loc_new().
27  */
28 int ohcount_loc_total(Loc *loc);
29
30 /**
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
33  * immediately.
34  * @param loc A Loc created from ohcount_loc_new().
35  * @param other Another Loc.
36  */
37 void ohcount_loc_add_loc(Loc *loc, Loc *other);
38
39 /**
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.
43  */
44 int ohcount_loc_is_equal(Loc *loc, Loc *other);
45
46 /**
47  * Frees the memory allocated for a given Loc.
48  * @param loc A Loc created from ohcount_loc_new().
49  */
50 void ohcount_loc_free(Loc *loc);
51
52 /**
53  * Creates a new LocList that is initially empty.
54  * Locs can be added using ohcount_loc_list_add_loc().
55  * @return LocList
56  */
57 LocList *ohcount_loc_list_new();
58
59 /**
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().
64  */
65 void ohcount_loc_list_add_loc(LocList *list, Loc *loc);
66
67 /**
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.
73  */
74 void ohcount_loc_list_add_loc_list(LocList *list, LocList *loc_list);
75
76 /**
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.
82  */
83 Loc *ohcount_loc_list_get_loc(LocList *list, const char *language);
84
85 /**
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().
88  */
89 int ohcount_loc_list_code(LocList *list);
90
91 /**
92  * Returns the number of lines of commentsfor all Locs in this LocList.
93  * @param list A LocList created from ohcount_loc_list_new().
94  */
95 int ohcount_loc_list_comments(LocList *list);
96
97 /**
98  * Returns the number of blank lines for all Locs in this LocList.
99  * @param list A LocList created from ohcount_loc_list_new().
100  */
101 int ohcount_loc_list_blanks(LocList *list);
102
103 /**
104  * Returns the total number of lines for all Locs in this LocList.
105  * @param list A LocList created from ohcount_loc_list_new().
106  */
107 int ohcount_loc_list_total(LocList *list);
108
109 /**
110  * Returns the number of files counted for all Locs in this LocList.
111  * @param list A LocList created from ohcount_loc_list_new().
112  */
113 int ohcount_loc_list_filecount(LocList *list);
114
115 /**
116  * Creates a new LocList from a given one, excluding all Locs with no counted
117  * lines.
118  * The given list may be 'free'd immediately.
119  * @param list A LocList created from ohcount_loc_list_new().
120  */
121 LocList *ohcount_loc_list_new_compact(LocList *list);
122
123 /**
124  * Frees the memory allocated for a given LocList.
125  * @param list A LocList created from ohcount_loc_list_new().
126  */
127 void ohcount_loc_list_free(LocList *list);
128
129 /**
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
139  *   delta.
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.
142  * @return LocDelta
143  */
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,
147                                 int blanks_removed);
148
149 /**
150  * Returns the net number of lines of code in a given LocDelta.
151  * @param delta A LocDelta created from ohcount_loc_delta_new().
152  */
153 int ohcount_loc_delta_net_code(LocDelta *delta);
154
155 /**
156  * Returns the net number of lines of comments in a given LocDelta.
157  * @param delta A LocDelta created from ohcount_loc_delta_new().
158  */
159 int ohcount_loc_delta_net_comments(LocDelta *delta);
160
161 /**
162  * Returns the net number of blank lines in a given LocDelta.
163  * @param delta A LocDelta created from ohcount_loc_delta_new().
164  */
165 int ohcount_loc_delta_net_blanks(LocDelta *delta);
166
167 /**
168  * Returns the net number of lines in a given LocDelta.
169  * @param delta A LocDelta created from ohcount_loc_delta_new().
170  */
171 int ohcount_loc_delta_net_total(LocDelta *delta);
172
173 /**
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.
179  */
180 void ohcount_loc_delta_add_loc_delta(LocDelta *delta, LocDelta *other);
181
182 /**
183  * Returns whether or not a given LocDelta has any line changes.
184  * @param delta A LocDelta created from ohcount_loc_delta_new().
185  */
186 int ohcount_loc_delta_is_changed(LocDelta *delta);
187
188 /**
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.
192  */
193 int ohcount_loc_delta_is_equal(LocDelta *delta, LocDelta *other);
194
195 /**
196  * Frees the memory allocated for a given LocDelta.
197  * @param delta A LocDelta created from ohcount_loc_delta_new().
198  */
199 void ohcount_loc_delta_free(LocDelta *delta);
200
201 /**
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
205  */
206 LocDeltaList *ohcount_loc_delta_list_new();
207
208 /**
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().
213  */
214 void ohcount_loc_delta_list_add_loc_delta(LocDeltaList *list, LocDelta *delta);
215
216 /**
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.
222  */
223 void ohcount_loc_delta_list_add_loc_delta_list(LocDeltaList *list,
224                                                LocDeltaList *loc_delta_list);
225
226 /**
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.
232  */
233 LocDelta *ohcount_loc_delta_list_get_loc_delta(LocDeltaList *list,
234                                                const char *language);
235
236 /**
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().
239  */
240 int ohcount_loc_delta_list_code_added(LocDeltaList *list);
241
242 /**
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().
245  */
246 int ohcount_loc_delta_list_code_removed(LocDeltaList *list);
247
248 /**
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().
251  */
252 int ohcount_loc_delta_list_comments_added(LocDeltaList *list);
253
254 /**
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().
257  */
258 int ohcount_loc_delta_list_comments_removed(LocDeltaList *list);
259
260 /**
261  * Returns the number of blank lines added for the given LocDeltaList.
262  * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
263  */
264 int ohcount_loc_delta_list_blanks_added(LocDeltaList *list);
265
266 /**
267  * Returns the number of blank lines removed for the given LocDeltaList.
268  * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
269  */
270 int ohcount_loc_delta_list_blanks_removed(LocDeltaList *list);
271
272 /**
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().
275  */
276 int ohcount_loc_delta_list_net_code(LocDeltaList *list);
277
278 /**
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().
281  */
282 int ohcount_loc_delta_list_net_comments(LocDeltaList *list);
283
284 /**
285  * Returns the net number of blank lines for the given LocDeltaList.
286  * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
287  */
288 int ohcount_loc_delta_list_net_blanks(LocDeltaList *list);
289
290 /**
291  * Returns the net number of lines for the given LocDeltaList.
292  * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
293  */
294 int ohcount_loc_delta_list_net_total(LocDeltaList *list);
295
296 /**
297  * Creates a new LocDeltaList from a given one, excluding all LocDeltas with no
298  * counted lines.
299  * The given list may be 'free'd immediately.
300  * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
301  */
302 LocDeltaList *ohcount_loc_delta_list_new_compact(LocDeltaList *list);
303
304 /**
305  * Frees the memory allocated for a given LocDeltaList.
306  * @param list A LocDeltaList created from ohcount_loc_delta_list_new().
307  */
308 void ohcount_loc_delta_list_free(LocDeltaList *list);
309
310 #endif