Debian Codegraph @

gcc/m2/mc-boot/GDynamicStrings.h

raw
1 /* do not edit automatically generated by mc from DynamicStrings. */
2 /* DynamicStrings.def provides a dynamic string type and procedures.
3
4 Copyright (C) 2001-2025 Free Software Foundation, Inc.
5 Contributed by Gaius Mulley <[email protected]>.
6
7 This file is part of GNU Modula-2.
8
9 GNU Modula-2 is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
12 any later version.
13
14 GNU Modula-2 is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
18
19 Under Section 7 of GPL version 3, you are granted additional
20 permissions described in the GCC Runtime Library Exception, version
21 3.1, as published by the Free Software Foundation.
22
23 You should have received a copy of the GNU General Public License and
24 a copy of the GCC Runtime Library Exception along with this program;
25 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
26 <http://www.gnu.org/licenses/>. */
27
28
29 #if !defined (_DynamicStrings_H)
30 # define _DynamicStrings_H
31
32 #include "config.h"
33 #include "system.h"
34 # ifdef __cplusplus
35 extern "C" {
36 # endif
37 #include <stdbool.h>
38 # if !defined (PROC_D)
39 # define PROC_D
40 typedef void (*PROC_t) (void);
41 typedef struct { PROC_t proc; } PROC;
42 # endif
43
44 # include "GSYSTEM.h"
45
46 # if defined (_DynamicStrings_C)
47 # define EXTERN
48 # else
49 # define EXTERN extern
50 # endif
51
52 #if !defined (DynamicStrings_String_D)
53 # define DynamicStrings_String_D
54 typedef void *DynamicStrings_String;
55 #endif
56
57
58 /*
59 InitString - creates and returns a String type object.
60 Initial contents are, a.
61 */
62
63 EXTERN DynamicStrings_String DynamicStrings_InitString (const char *a_, unsigned int _a_high);
64
65 /*
66 KillString - frees String, s, and its contents.
67 NIL is returned.
68 */
69
70 EXTERN DynamicStrings_String DynamicStrings_KillString (DynamicStrings_String s);
71
72 /*
73 Fin - finishes with a string, it calls KillString with, s.
74 The purpose of the procedure is to provide a short cut
75 to calling KillString and then testing the return result.
76 */
77
78 EXTERN void DynamicStrings_Fin (DynamicStrings_String s);
79
80 /*
81 InitStringCharStar - initializes and returns a String to contain
82 the C string.
83 */
84
85 EXTERN DynamicStrings_String DynamicStrings_InitStringCharStar (void * a);
86
87 /*
88 InitStringChar - initializes and returns a String to contain the
89 single character, ch.
90 */
91
92 EXTERN DynamicStrings_String DynamicStrings_InitStringChar (char ch);
93
94 /*
95 Mark - marks String, s, ready for garbage collection.
96 */
97
98 EXTERN DynamicStrings_String DynamicStrings_Mark (DynamicStrings_String s);
99
100 /*
101 Length - returns the length of the String, s.
102 */
103
104 EXTERN unsigned int DynamicStrings_Length (DynamicStrings_String s);
105
106 /*
107 ConCat - returns String, a, after the contents of, b,
108 have been appended.
109 */
110
111 EXTERN DynamicStrings_String DynamicStrings_ConCat (DynamicStrings_String a, DynamicStrings_String b);
112
113 /*
114 ConCatChar - returns String, a, after character, ch,
115 has been appended.
116 */
117
118 EXTERN DynamicStrings_String DynamicStrings_ConCatChar (DynamicStrings_String a, char ch);
119
120 /*
121 Assign - assigns the contents of, b, into, a.
122 String, a, is returned.
123 */
124
125 EXTERN DynamicStrings_String DynamicStrings_Assign (DynamicStrings_String a, DynamicStrings_String b);
126
127 /*
128 ReplaceChar - returns string s after it has changed all
129 occurances of from to to.
130 */
131
132 EXTERN DynamicStrings_String DynamicStrings_ReplaceChar (DynamicStrings_String s, char from, char to);
133
134 /*
135 Dup - duplicate a String, s, returning the copy of s.
136 */
137
138 EXTERN DynamicStrings_String DynamicStrings_Dup (DynamicStrings_String s);
139
140 /*
141 Add - returns a new String which contains the contents of a and b.
142 */
143
144 EXTERN DynamicStrings_String DynamicStrings_Add (DynamicStrings_String a, DynamicStrings_String b);
145
146 /*
147 Equal - returns TRUE if String, a, and, b, are equal.
148 */
149
150 EXTERN bool DynamicStrings_Equal (DynamicStrings_String a, DynamicStrings_String b);
151
152 /*
153 EqualCharStar - returns TRUE if contents of String, s, is
154 the same as the string, a.
155 */
156
157 EXTERN bool DynamicStrings_EqualCharStar (DynamicStrings_String s, void * a);
158
159 /*
160 EqualArray - returns TRUE if contents of String, s, is the
161 same as the string, a.
162 */
163
164 EXTERN bool DynamicStrings_EqualArray (DynamicStrings_String s, const char *a_, unsigned int _a_high);
165
166 /*
167 Mult - returns a new string which is n concatenations of String, s.
168 If n<=0 then an empty string is returned.
169 */
170
171 EXTERN DynamicStrings_String DynamicStrings_Mult (DynamicStrings_String s, unsigned int n);
172
173 /*
174 Slice - returns a new string which contains the elements
175 low..high-1
176
177 strings start at element 0
178 Slice(s, 0, 2) will return elements 0, 1 but not 2
179 Slice(s, 1, 3) will return elements 1, 2 but not 3
180 Slice(s, 2, 0) will return elements 2..max
181 Slice(s, 3, -1) will return elements 3..max-1
182 Slice(s, 4, -2) will return elements 4..max-2
183 */
184
185 EXTERN DynamicStrings_String DynamicStrings_Slice (DynamicStrings_String s, int low, int high);
186
187 /*
188 Index - returns the indice of the first occurance of, ch, in
189 String, s. -1 is returned if, ch, does not exist.
190 The search starts at position, o.
191 */
192
193 EXTERN int DynamicStrings_Index (DynamicStrings_String s, char ch, unsigned int o);
194
195 /*
196 RIndex - returns the indice of the last occurance of, ch,
197 in String, s. The search starts at position, o.
198 -1 is returned if ch is not found. The search
199 is performed left to right.
200 */
201
202 EXTERN int DynamicStrings_RIndex (DynamicStrings_String s, char ch, unsigned int o);
203
204 /*
205 ReverseIndex - returns the indice of the last occurance of ch
206 in String s. The search starts at position o
207 and searches from right to left. The start position
208 may be indexed negatively from the right (-1 is the
209 last index).
210 The return value if ch is found will always be positive.
211 -1 is returned if ch is not found.
212 */
213
214 EXTERN int DynamicStrings_ReverseIndex (DynamicStrings_String s, char ch, int o);
215
216 /*
217 RemoveComment - assuming that, comment, is a comment delimiter
218 which indicates anything to its right is a comment
219 then strip off the comment and also any white space
220 on the remaining right hand side.
221 It leaves any white space on the left hand side
222 alone.
223 */
224
225 EXTERN DynamicStrings_String DynamicStrings_RemoveComment (DynamicStrings_String s, char comment);
226
227 /*
228 RemoveWhitePrefix - removes any leading white space from String, s.
229 A new string is returned.
230 */
231
232 EXTERN DynamicStrings_String DynamicStrings_RemoveWhitePrefix (DynamicStrings_String s);
233
234 /*
235 RemoveWhitePostfix - removes any leading white space from String, s.
236 A new string is returned.
237 */
238
239 EXTERN DynamicStrings_String DynamicStrings_RemoveWhitePostfix (DynamicStrings_String s);
240
241 /*
242 ToUpper - returns string, s, after it has had its lower case
243 characters replaced by upper case characters.
244 The string, s, is not duplicated.
245 */
246
247 EXTERN DynamicStrings_String DynamicStrings_ToUpper (DynamicStrings_String s);
248
249 /*
250 ToLower - returns string, s, after it has had its upper case
251 characters replaced by lower case characters.
252 The string, s, is not duplicated.
253 */
254
255 EXTERN DynamicStrings_String DynamicStrings_ToLower (DynamicStrings_String s);
256
257 /*
258 CopyOut - copies string, s, to a.
259 */
260
261 EXTERN void DynamicStrings_CopyOut (char *a, unsigned int _a_high, DynamicStrings_String s);
262
263 /*
264 char - returns the character, ch, at position, i, in String, s.
265 As Slice the index can be negative so:
266
267 char(s, 0) will return the first character
268 char(s, 1) will return the second character
269 char(s, -1) will return the last character
270 char(s, -2) will return the penultimate character
271
272 a nul character is returned if the index is out of range.
273 */
274
275 EXTERN char DynamicStrings_char (DynamicStrings_String s, int i);
276
277 /*
278 string - returns the C style char * of String, s.
279 */
280
281 EXTERN void * DynamicStrings_string (DynamicStrings_String s);
282
283 /*
284 InitStringDB - the debug version of InitString.
285 */
286
287 EXTERN DynamicStrings_String DynamicStrings_InitStringDB (const char *a_, unsigned int _a_high, const char *file_, unsigned int _file_high, unsigned int line);
288
289 /*
290 InitStringCharStarDB - the debug version of InitStringCharStar.
291 */
292
293 EXTERN DynamicStrings_String DynamicStrings_InitStringCharStarDB (void * a, const char *file_, unsigned int _file_high, unsigned int line);
294
295 /*
296 InitStringCharDB - the debug version of InitStringChar.
297 */
298
299 EXTERN DynamicStrings_String DynamicStrings_InitStringCharDB (char ch, const char *file_, unsigned int _file_high, unsigned int line);
300
301 /*
302 MultDB - the debug version of MultDB.
303 */
304
305 EXTERN DynamicStrings_String DynamicStrings_MultDB (DynamicStrings_String s, unsigned int n, const char *file_, unsigned int _file_high, unsigned int line);
306
307 /*
308 DupDB - the debug version of Dup.
309 */
310
311 EXTERN DynamicStrings_String DynamicStrings_DupDB (DynamicStrings_String s, const char *file_, unsigned int _file_high, unsigned int line);
312
313 /*
314 SliceDB - debug version of Slice.
315 */
316
317 EXTERN DynamicStrings_String DynamicStrings_SliceDB (DynamicStrings_String s, int low, int high, const char *file_, unsigned int _file_high, unsigned int line);
318
319 /*
320 PushAllocation - pushes the current allocation/deallocation lists.
321 */
322
323 EXTERN void DynamicStrings_PushAllocation (void);
324
325 /*
326 PopAllocation - test to see that all strings are deallocated since
327 the last push. Then it pops to the previous
328 allocation/deallocation lists.
329
330 If halt is true then the application terminates
331 with an exit code of 1.
332 */
333
334 EXTERN void DynamicStrings_PopAllocation (bool halt);
335
336 /*
337 PopAllocationExemption - test to see that all strings are
338 deallocated, except string e since
339 the last push.
340 Post-condition: it pops to the previous
341 allocation/deallocation lists.
342
343 If halt is true then the application
344 terminates with an exit code of 1.
345
346 The string, e, is returned unmodified,
347 */
348
349 EXTERN DynamicStrings_String DynamicStrings_PopAllocationExemption (bool halt, DynamicStrings_String e);
350 # ifdef __cplusplus
351 }
352 # endif
353
354 # undef EXTERN
355 #endif