Debian Codegraph @

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