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