1 // structs.h written by Mitchell Foral. mitchell<att>caladbolg.net.
2 // See COPYING for license information.
4 #ifndef OHCOUNT_STRUCTS_H
5 #define OHCOUNT_STRUCTS_H
11 * @brief Holds a license and its associated details and patterns.
14 /** The ID name of the license. Should be in defined in licenses.h. */
17 /** The string URL to the license's website. */
20 /** A nice displayable name for the license. */
21 const char *nice_name;
23 /** A PCRE regular expression for text that matches this license. */
26 /** PCRE flags for re. (Typically PCRE_CASELESS or PCRE_MULTILINE). */
30 * A PCRE regular expression for text that matches re, but should not match
31 * this re in order to match this license.
33 const char *exclude_re;
35 /** PCRE flags for exclude_re. */
38 /** The PCRE object for re. (This field is set automatically.) */
41 /** The PCRE object for exclude_re. (This field is set automatically.) */
47 * @struct LicenseListItem
48 * @brief Holds a list of Licenses in a linked list.
50 typedef struct LicenseListItem {
51 /** The particular License in this linked list item. */
54 /** The next LicenseList in the linked list. */
55 struct LicenseListItem *next;
58 * The head of the linked list this LicenseList item is part of.
59 * This field is only used for the list head.
61 struct LicenseListItem *head;
64 * The head of the linked list this LicenseList item is part of.
65 * This field is only used for the list head.
67 struct LicenseListItem *tail;
73 * @brief Tracks total lines of code, comments, and blanks for a single
77 /** The language associated with this Loc. */
80 /** The number of lines of code for this Loc. */
83 /** The number of lines of comments for this Loc. */
86 /** The number of blank lines for this Loc. */
89 /** The number of parsed files associated with this Loc. */
96 * @brief Tracks total lines of code, comments, and blanks for multiple
97 * languages using a linked list.
99 typedef struct LocListItem {
100 /** The particular Loc in this linked list item. */
103 /** The next LocList item in the linked list. */
104 struct LocListItem *next;
107 * The head of the linked list this LocList item is part of.
108 * This field is only used for the list head.
110 struct LocListItem *head;
113 * The tail of the linked list this LocList item is part of.
114 * This field is only used for the list head.
116 struct LocListItem *tail;
122 * @brief Tracks changes in lines of code, comments, and blank lines for a
126 /** The language associated with this LocDelta. */
127 const char *language;
129 /** The number of lines of code added in this LocDelta. */
132 /** The number of lines of code removed in this LocDelta. */
135 /** The number of lines of comments added in this LocDelta. */
138 /** The number of lines of comments removed in this LocDelta. */
139 int comments_removed;
141 /** The number of blank lines added in this LocDelta. */
144 /** The number of blank lines removed in this LocDelta. */
150 * @struct LocDeltaListItem
151 * @brief Tracks changes in lines of code, comments, and blank lines for
152 * multiple languages using a linked list.
154 typedef struct LocDeltaListItem {
155 /** The particular LocDelta in this linked list item. */
158 /** The next LocDeltaList item in the linked list. */
159 struct LocDeltaListItem *next;
162 * The head of the linked list this item is part of.
163 * This field is only used for the list head.
165 struct LocDeltaListItem *head;
168 * The tail of the linked list this item is part of.
169 * This field is only used for the list head.
171 struct LocDeltaListItem *tail;
176 * @struct ParsedLanguage
177 * @brief Represents a single language parsed from a SourceFile.
180 /** The parsed language. */
183 /** The size of the code and comments buffers. */
186 /** Buffer containing the code parsed out for this language. */
189 /** Used for writing parsed code to the code buffer. */
192 /** Number of lines of code for this language. */
195 /** Buffer containing the comments parsed out for this language. */
198 /** Used for writing parsed comments to the comment buffer. */
201 /** Number of lines of comments for this language. */
204 /** Number of blank lines for this language. */
210 * @struct ParsedLanguageListItem
211 * @brief Holds a set of ParsedLanguages in a linked list.
213 typedef struct ParsedLanguageListItem {
214 /** The particular ParsedLanguage in this linked list item. */
217 /** The next ParsedLanguageList item in the linked list. */
218 struct ParsedLanguageListItem *next;
221 * The head of the linked list this ParsedLanguageList item is part of.
222 * This field is only used for the list head.
224 struct ParsedLanguageListItem *head;
227 * The tail of the linked list this ParsedLanguageList item is part of.
228 * This field is only used for the list head.
230 struct ParsedLanguageListItem *tail;
232 } ParsedLanguageList;
236 * @brief Represents a single source code file.
239 /** The entire path to the file. */
243 The last character address considered to be part of the directory path in
244 filepath. This is an address in memory, not a length relative to filepath.
248 /** The filepath's filename. */
251 /** The filepath's file extension. */
255 * If filepath does not represent the real location of the file on disk, this
260 // The following fields should not be accessed directly. Their accessor
261 // functions should be used instead as labeled.
264 * The contents of the file.
265 * Do not use this field. Use ohcount_sourcefile_get_contents() instead.
270 * The size of the file's contents in bytes.
271 * Do not use this field. Use ohcount_sourcefile_get_contents_size() instead.
276 * The file's detected source code language.
277 * Do not use this field. Use ohcount_sourcefile_get_language() instead.
279 const char *language;
282 * Flag used internally for keeping track of whether or not
283 * ohcount_sourcefile_get_language() has been called for this file.
285 int language_detected;
288 * A ParsedLanguageList resulting from parsing the file.
289 * Do not use this field. Use ohcount_sourcefile_get_parsed_language_list()
292 ParsedLanguageList *parsed_language_list;
295 * A LicenseList of licenses detected.
296 * Do not use this field. Use ohcount_sourcefile_get_license_list() instead.
298 LicenseList *license_list;
301 * A LocList of all lines of code in each language in the file.
302 * Do not use this field. Use ohcount_sourcefile_get_loc_list() instead.
306 /** A string array of all filenames in this file's directory. */
312 * @struct SourceFileListItem
313 * @brief Contains a set of SourceFiles.
315 typedef struct SourceFileListItem {
316 /** The particular SourceFile in this linked list item. */
319 /** The next SourceFileList item in the linked list. */
320 struct SourceFileListItem *next;
323 * The head of the linked list this SourceFileList item is part of.
324 * This field is only used for the list head.
326 struct SourceFileListItem *head;
329 * The tail of the linked list this SourceFileList item is part of.
330 * This field is only used for the list head.
332 struct SourceFileListItem *tail;