2 Copyright (C) 1994-2007 Frans Slothouber, Jacco van Weert, Petteri Kettunen,
3 Bernd Koesling, Thomas Aglassinger, Anthon Pang, Stefan Kost, David Druffner,
4 Sasha Vasko, Kai Hofmann, Thierry Pierron, Friedrich Haase, and Gergely Budai.
6 This file is part of ROBODoc
8 ROBODoc is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 /****h* ROBODoc/HeaderTypes
27 * Headers come in different types. This module defines what kind
28 * of headertypes ROBODoc recognizes, and contains functions to add
29 * new headertypes and to compare headertypes. All the headertypes
30 * are stored in an array, header_type_lookup_table.
37 #include "headertypes.h"
40 /****v* HeaderTypes/header_type_lookup_table
42 * A lookup table for all the header types that ROBODoc recognizes.
43 * At the moment is has about 127 entries. About as many as there
44 * are characters in the standard ASCII set. The first 32 entries
45 * can be used for special purposes.
47 * Two of them are use:
52 * HT_MASTERINDEXTYPE is a wildcard type. All headertypes match this
53 * type. This is used to collect all the headers for the
56 * HT_SOURCEHEADERTYPE is used to pretend that the name of
57 * a sourcefile is a kind of header. This makes it possible to
58 * include the names of the source files in the master index.
62 struct RB_HeaderType header_type_lookup_table[MAX_HEADER_TYPE + 1] = {
63 {'\0', NULL, NULL, 0},
64 {HT_SOURCEHEADERTYPE, "Sourcefiles", "robo_sourcefiles", 0},
65 {HT_MASTERINDEXTYPE, "Index", "masterindex", 0}, /* no robo_ prefix for backwards compatibility */
66 {'\0', NULL, NULL, 0},
67 {'\0', NULL, NULL, 0},
68 {'\0', NULL, NULL, 0},
69 {'\0', NULL, NULL, 0},
70 {'\0', NULL, NULL, 0},
71 {'\0', NULL, NULL, 0},
72 {'\0', NULL, NULL, 0},
73 {'\0', NULL, NULL, 0},
74 {'\0', NULL, NULL, 0},
75 {'\0', NULL, NULL, 0},
76 {'\0', NULL, NULL, 0},
77 {'\0', NULL, NULL, 0},
78 {'\0', NULL, NULL, 0},
79 {'\0', NULL, NULL, 0},
80 {'\0', NULL, NULL, 0},
81 {'\0', NULL, NULL, 0},
82 {'\0', NULL, NULL, 0},
83 {'\0', NULL, NULL, 0},
84 {'\0', NULL, NULL, 0},
85 {'\0', NULL, NULL, 0},
86 {'\0', NULL, NULL, 0},
87 {'\0', NULL, NULL, 0},
88 {'\0', NULL, NULL, 0},
89 {'\0', NULL, NULL, 0},
90 {'\0', NULL, NULL, 0},
91 {'\0', NULL, NULL, 0},
92 {'\0', NULL, NULL, 0},
93 {'\0', NULL, NULL, 0},
94 {'\0', NULL, NULL, 0},
100 {'%', NULL, NULL, 0},
101 {'&', NULL, NULL, 0},
102 {'\0', NULL, NULL, 0},
103 {'(', NULL, NULL, 0},
104 {')', NULL, NULL, 0},
105 {'*', "Generics", "robo_generics", 0},
106 {'+', NULL, NULL, 0},
107 {',', NULL, NULL, 0},
108 {'-', NULL, NULL, 0},
109 {'.', NULL, NULL, 0},
110 {'/', NULL, NULL, 0},
111 {'0', NULL, NULL, 0},
112 {'1', NULL, NULL, 0},
113 {'2', NULL, NULL, 0},
114 {'3', NULL, NULL, 0},
115 {'4', NULL, NULL, 0},
116 {'5', NULL, NULL, 0},
117 {'6', NULL, NULL, 0},
118 {'7', NULL, NULL, 0},
119 {'8', NULL, NULL, 0},
120 {'9', NULL, NULL, 0},
121 {':', NULL, NULL, 0},
122 {';', NULL, NULL, 0},
123 {'<', NULL, NULL, 0},
124 {'=', NULL, NULL, 0},
125 {'>', NULL, NULL, 0},
126 {'?', NULL, NULL, 0},
127 {'@', NULL, NULL, 0},
128 {'A', NULL, NULL, 0},
129 {'B', "Businessrules", "robo_businessrules", 0},
130 {'C', "Contracts", "robo_contracts", 0},
131 {'D', "Datasources", "robo_datasources", 0},
132 {'E', "Ensure contracts", "robo_ensure_contracts", 0},
133 {'F', NULL, NULL, 0},
134 {'G', NULL, NULL, 0},
135 {'H', NULL, NULL, 0},
136 {'I', "Invariants", "robo_invariants", 0},
137 {'J', NULL, NULL, 0},
138 {'K', NULL, NULL, 0},
139 {'L', NULL, NULL, 0},
140 {'M', "Metadata", "robo_metadata", 0},
141 {'N', NULL, NULL, 0},
142 {'O', NULL, NULL, 0},
143 {'P', "Process", "robo_processes", 0},
144 {'Q', NULL, NULL, 0},
145 {'R', "Require contracts", "robo_require_contracts", 0},
146 {'S', "Subjects", "robo_subjects", 0},
147 {'T', NULL, NULL, 0},
148 {'U', NULL, NULL, 0},
149 {'V', NULL, NULL, 0},
150 {'W', NULL, NULL, 0},
151 {'X', NULL, NULL, 0},
152 {'Y', NULL, NULL, 0},
153 {'Z', NULL, NULL, 0},
154 {'[', NULL, NULL, 0},
155 {'\0', NULL, NULL, 0}, /* Separator / */
156 {']', NULL, NULL, 0},
157 {'^', NULL, NULL, 0},
158 {'_', NULL, NULL, 0},
159 {'`', NULL, NULL, 0},
160 {'a', NULL, NULL, 0},
161 {'b', NULL, NULL, 0},
162 {'c', "Classes", "robo_classes", 0},
163 {'d', "Definitions", "robo_definitions", 0},
164 {'e', "Exceptions", "robo_exceptions", 0},
165 {'f', "Functions", "robo_functions", 0},
166 {'g', NULL, NULL, 0},
167 {'h', "Modules", "robo_modules", 1},
168 {'\0', NULL, NULL, 0}, /* Internal header flag */
169 {'j', NULL, NULL, 0},
170 {'k', NULL, NULL, 0},
171 {'l', NULL, NULL, 0},
172 {'m', "Methods", "robo_methods", 0},
173 {'n', NULL, NULL, 0},
174 {'o', NULL, NULL, 0},
175 {'p', "Procedures", "robo_procedures", 0},
176 {'q', NULL, NULL, 0},
177 {'r', NULL, NULL, 0},
178 {'s', "Structures", "robo_strutures", 0},
179 {'t', "Types", "robo_types", 0},
180 {'u', "Unittest", "robo_unittests", 0},
181 {'v', "Variables", "robo_variables", 0},
182 {'w', "Warehouses", "robo_warehouses", 0},
183 {'x', NULL, NULL, 0},
184 {'y', NULL, NULL, 0},
185 {'z', NULL, NULL, 0},
186 {'{', NULL, NULL, 0},
187 {'|', NULL, NULL, 0},
188 {'}', NULL, NULL, 0},
189 {'~', NULL, NULL, 0},
190 {'\0', NULL, NULL, 0}
196 /****f* HeaderTypes/RB_AddHeaderType
198 * Add a new headertype to the list of header type
199 * that robodoc recognizes.
201 * * FALSE -- it is a new header type.
202 * * TRUE -- header type already existed.
206 int RB_AddHeaderType(
207 unsigned int typeCharacter,
210 unsigned int priority )
212 if ( header_type_lookup_table[typeCharacter].typeCharacter )
214 header_type_lookup_table[typeCharacter].indexName = indexName;
215 header_type_lookup_table[typeCharacter].fileName = fileName;
216 header_type_lookup_table[typeCharacter].priority = priority;
221 ( "The character %c is not allowed as a headertype character\n",
232 /****f* HeaderTypes/RB_CompareHeaderTypes
234 * Compare two header types and check if they are equal. If one of
235 * the header types is a HT_MASTERINDEXTYPE the comparison is always
236 * TRUE. (This to make sure that all headers appear in the Index.)
238 * int RB_CompareHeaderTypes(
239 * struct RB_HeaderType* ht1, struct RB_HeaderType* ht2 )
241 * o ht1 and ht2 -- the header types to compare.
243 * o 0 -- header types are not equal
244 * o != 0 -- header type are equal
248 int RB_CompareHeaderTypes(
249 struct RB_HeaderType *ht1,
250 struct RB_HeaderType *ht2 )
254 return ( ht1->typeCharacter == HT_MASTERINDEXTYPE ) ||
255 ( ht2->typeCharacter == HT_MASTERINDEXTYPE ) ||
256 ( ht1->typeCharacter == ht2->typeCharacter );
263 /****f* HeaderTypes/RB_FindHeaderType
265 * Return the header type that corresponds to the type character.
267 * * 0 -- there is no such header type
268 * * pointer to the header type otherwise.
272 struct RB_HeaderType *RB_FindHeaderType(
273 unsigned char typeCharacter )
275 struct RB_HeaderType *headertype = 0;
277 if ( typeCharacter < MAX_HEADER_TYPE )
279 headertype = &( header_type_lookup_table[typeCharacter] );
280 if ( ( headertype->typeCharacter == typeCharacter ) &&
281 ( headertype->indexName ) )
292 /****f* HeaderTypes/RB_IsInternalHeader
294 * Given the typeCharacter is this an internal header?
296 * * TRUE -- yes it is
297 * * FALSE -- no it is not
301 int RB_IsInternalHeader(
302 unsigned char type_character )
304 return ( type_character == 'i' );
312 char *RB_GetIndexName(
313 struct RB_HeaderType *ht1 )
315 /* TODO should be used to access indexName */