]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/m2/pge-boot/GStringConvert.h
Merge modula-2 front end onto gcc.
[thirdparty/gcc.git] / gcc / m2 / pge-boot / GStringConvert.h
1 /* do not edit automatically generated by mc from StringConvert. */
2 /* StringConvert.def provides functions to convert numbers to and from strings.
3
4 Copyright (C) 2001-2021 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 (_StringConvert_H)
30 # define _StringConvert_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 "GDynamicStrings.h"
44
45 # if defined (_StringConvert_C)
46 # define EXTERN
47 # else
48 # define EXTERN extern
49 # endif
50
51
52 /*
53 IntegerToString - converts INTEGER, i, into a String. The field with
54 can be specified if non zero. Leading characters
55 are defined by padding and this function will
56 prepend a + if sign is set to TRUE.
57 The base allows the caller to generate binary,
58 octal, decimal, hexidecimal numbers.
59 The value of lower is only used when hexidecimal
60 numbers are generated and if TRUE then digits
61 abcdef are used, and if FALSE then ABCDEF are used.
62 */
63
64 EXTERN DynamicStrings_String StringConvert_IntegerToString (int i, unsigned int width, char padding, unsigned int sign, unsigned int base, unsigned int lower);
65
66 /*
67 CardinalToString - converts CARDINAL, c, into a String. The field
68 width can be specified if non zero. Leading
69 characters are defined by padding.
70 The base allows the caller to generate binary,
71 octal, decimal, hexidecimal numbers.
72 The value of lower is only used when hexidecimal
73 numbers are generated and if TRUE then digits
74 abcdef are used, and if FALSE then ABCDEF are used.
75 */
76
77 EXTERN DynamicStrings_String StringConvert_CardinalToString (unsigned int c, unsigned int width, char padding, unsigned int base, unsigned int lower);
78
79 /*
80 StringToInteger - converts a string, s, of, base, into an INTEGER.
81 Leading white space is ignored. It stops converting
82 when either the string is exhausted or if an illegal
83 numeral is found.
84 The parameter found is set TRUE if a number was found.
85 */
86
87 EXTERN int StringConvert_StringToInteger (DynamicStrings_String s, unsigned int base, unsigned int *found);
88
89 /*
90 StringToCardinal - converts a string, s, of, base, into a CARDINAL.
91 Leading white space is ignored. It stops converting
92 when either the string is exhausted or if an illegal
93 numeral is found.
94 The parameter found is set TRUE if a number was found.
95 */
96
97 EXTERN unsigned int StringConvert_StringToCardinal (DynamicStrings_String s, unsigned int base, unsigned int *found);
98
99 /*
100 LongIntegerToString - converts LONGINT, i, into a String. The field with
101 can be specified if non zero. Leading characters
102 are defined by padding and this function will
103 prepend a + if sign is set to TRUE.
104 The base allows the caller to generate binary,
105 octal, decimal, hexidecimal numbers.
106 The value of lower is only used when hexidecimal
107 numbers are generated and if TRUE then digits
108 abcdef are used, and if FALSE then ABCDEF are used.
109 */
110
111 EXTERN DynamicStrings_String StringConvert_LongIntegerToString (long int i, unsigned int width, char padding, unsigned int sign, unsigned int base, unsigned int lower);
112
113 /*
114 StringToLongInteger - converts a string, s, of, base, into an LONGINT.
115 Leading white space is ignored. It stops converting
116 when either the string is exhausted or if an illegal
117 numeral is found.
118 The parameter found is set TRUE if a number was found.
119 */
120
121 EXTERN long int StringConvert_StringToLongInteger (DynamicStrings_String s, unsigned int base, unsigned int *found);
122
123 /*
124 LongCardinalToString - converts LONGCARD, c, into a String. The field
125 width can be specified if non zero. Leading
126 characters are defined by padding.
127 The base allows the caller to generate binary,
128 octal, decimal, hexidecimal numbers.
129 The value of lower is only used when hexidecimal
130 numbers are generated and if TRUE then digits
131 abcdef are used, and if FALSE then ABCDEF are used.
132 */
133
134 EXTERN DynamicStrings_String StringConvert_LongCardinalToString (long unsigned int c, unsigned int width, char padding, unsigned int base, unsigned int lower);
135
136 /*
137 StringToLongCardinal - converts a string, s, of, base, into a LONGCARD.
138 Leading white space is ignored. It stops converting
139 when either the string is exhausted or if an illegal
140 numeral is found.
141 The parameter found is set TRUE if a number was found.
142 */
143
144 EXTERN long unsigned int StringConvert_StringToLongCardinal (DynamicStrings_String s, unsigned int base, unsigned int *found);
145
146 /*
147 ShortCardinalToString - converts SHORTCARD, c, into a String. The field
148 width can be specified if non zero. Leading
149 characters are defined by padding.
150 The base allows the caller to generate binary,
151 octal, decimal, hexidecimal numbers.
152 The value of lower is only used when hexidecimal
153 numbers are generated and if TRUE then digits
154 abcdef are used, and if FALSE then ABCDEF are used.
155 */
156
157 EXTERN DynamicStrings_String StringConvert_ShortCardinalToString (short unsigned int c, unsigned int width, char padding, unsigned int base, unsigned int lower);
158
159 /*
160 StringToShortCardinal - converts a string, s, of, base, into a SHORTCARD.
161 Leading white space is ignored. It stops converting
162 when either the string is exhausted or if an illegal
163 numeral is found.
164 The parameter found is set TRUE if a number was found.
165 */
166
167 EXTERN short unsigned int StringConvert_StringToShortCardinal (DynamicStrings_String s, unsigned int base, unsigned int *found);
168
169 /*
170 stoi - decimal string to INTEGER
171 */
172
173 EXTERN int StringConvert_stoi (DynamicStrings_String s);
174
175 /*
176 itos - integer to decimal string.
177 */
178
179 EXTERN DynamicStrings_String StringConvert_itos (int i, unsigned int width, char padding, unsigned int sign);
180
181 /*
182 ctos - cardinal to decimal string.
183 */
184
185 EXTERN DynamicStrings_String StringConvert_ctos (unsigned int c, unsigned int width, char padding);
186
187 /*
188 stoc - decimal string to CARDINAL
189 */
190
191 EXTERN unsigned int StringConvert_stoc (DynamicStrings_String s);
192
193 /*
194 hstoi - hexidecimal string to INTEGER
195 */
196
197 EXTERN int StringConvert_hstoi (DynamicStrings_String s);
198
199 /*
200 ostoi - octal string to INTEGER
201 */
202
203 EXTERN int StringConvert_ostoi (DynamicStrings_String s);
204
205 /*
206 bstoi - binary string to INTEGER
207 */
208
209 EXTERN int StringConvert_bstoi (DynamicStrings_String s);
210
211 /*
212 hstoc - hexidecimal string to CARDINAL
213 */
214
215 EXTERN unsigned int StringConvert_hstoc (DynamicStrings_String s);
216
217 /*
218 ostoc - octal string to CARDINAL
219 */
220
221 EXTERN unsigned int StringConvert_ostoc (DynamicStrings_String s);
222
223 /*
224 bstoc - binary string to CARDINAL
225 */
226
227 EXTERN unsigned int StringConvert_bstoc (DynamicStrings_String s);
228
229 /*
230 StringToLongreal - returns a LONGREAL and sets found to TRUE
231 if a legal number is seen.
232 */
233
234 EXTERN long double StringConvert_StringToLongreal (DynamicStrings_String s, unsigned int *found);
235
236 /*
237 LongrealToString - converts a LONGREAL number, Real, which has,
238 TotalWidth, and FractionWidth into a string.
239
240 So for example:
241
242 LongrealToString(1.0, 4, 2) -> '1.00'
243 LongrealToString(12.3, 5, 2) -> '12.30'
244 LongrealToString(12.3, 6, 2) -> ' 12.30'
245 LongrealToString(12.3, 6, 3) -> '12.300'
246
247 if total width is too small then the fraction
248 becomes truncated.
249
250 LongrealToString(12.3, 5, 3) -> '12.30'
251
252 If TotalWidth is 0 then the function
253 will return the value of x which is converted
254 into as a fixed point number with exhaustive
255 precision.
256 */
257
258 EXTERN DynamicStrings_String StringConvert_LongrealToString (long double x, unsigned int TotalWidth, unsigned int FractionWidth);
259
260 /*
261 stor - returns a REAL given a string.
262 */
263
264 EXTERN double StringConvert_stor (DynamicStrings_String s);
265
266 /*
267 stolr - returns a LONGREAL given a string.
268 */
269
270 EXTERN long double StringConvert_stolr (DynamicStrings_String s);
271
272 /*
273 ToSigFig - returns a floating point or base 10 integer
274 string which is accurate to, n, significant
275 figures. It will return a new String
276 and, s, will be destroyed.
277
278
279 So: 12.345
280
281 rounded to the following significant figures yields
282
283 5 12.345
284 4 12.34
285 3 12.3
286 2 12
287 1 10
288 */
289
290 EXTERN DynamicStrings_String StringConvert_ToSigFig (DynamicStrings_String s, unsigned int n);
291
292 /*
293 ToDecimalPlaces - returns a floating point or base 10 integer
294 string which is accurate to, n, decimal
295 places. It will return a new String
296 and, s, will be destroyed.
297 Decimal places yields, n, digits after
298 the .
299
300 So: 12.345
301
302 rounded to the following decimal places yields
303
304 5 12.34500
305 4 12.3450
306 3 12.345
307 2 12.34
308 1 12.3
309 */
310
311 EXTERN DynamicStrings_String StringConvert_ToDecimalPlaces (DynamicStrings_String s, unsigned int n);
312 # ifdef __cplusplus
313 }
314 # endif
315
316 # undef EXTERN
317 #endif