libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / m2 / mc-boot / GStringConvert.h
blob284eef236cc8f6e3170352fcf663b131c0fc4266
1 /* do not edit automatically generated by mc from StringConvert. */
2 /* StringConvert.def provides functions to convert numbers to and from strings.
4 Copyright (C) 2001-2024 Free Software Foundation, Inc.
5 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
7 This file is part of GNU Modula-2.
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.
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.
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.
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/>. */
29 #if !defined (_StringConvert_H)
30 # define _StringConvert_H
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
44 # include "GDynamicStrings.h"
46 # if defined (_StringConvert_C)
47 # define EXTERN
48 # else
49 # define EXTERN extern
50 # endif
54 IntegerToString - converts INTEGER, i, into a String. The field with
55 can be specified if non zero. Leading characters
56 are defined by padding and this function will
57 prepend a + if sign is set to TRUE.
58 The base allows the caller to generate binary,
59 octal, decimal, hexidecimal numbers.
60 The value of lower is only used when hexidecimal
61 numbers are generated and if TRUE then digits
62 abcdef are used, and if FALSE then ABCDEF are used.
65 EXTERN DynamicStrings_String StringConvert_IntegerToString (int i, unsigned int width, char padding, bool sign, unsigned int base, bool lower);
68 CardinalToString - converts CARDINAL, c, into a String. The field
69 width can be specified if non zero. Leading
70 characters are defined by padding.
71 The base allows the caller to generate binary,
72 octal, decimal, hexidecimal numbers.
73 The value of lower is only used when hexidecimal
74 numbers are generated and if TRUE then digits
75 abcdef are used, and if FALSE then ABCDEF are used.
78 EXTERN DynamicStrings_String StringConvert_CardinalToString (unsigned int c, unsigned int width, char padding, unsigned int base, bool lower);
81 StringToInteger - converts a string, s, of, base, into an INTEGER.
82 Leading white space is ignored. It stops converting
83 when either the string is exhausted or if an illegal
84 numeral is found.
85 The parameter found is set TRUE if a number was found.
88 EXTERN int StringConvert_StringToInteger (DynamicStrings_String s, unsigned int base, bool *found);
91 StringToCardinal - converts a string, s, of, base, into a CARDINAL.
92 Leading white space is ignored. It stops converting
93 when either the string is exhausted or if an illegal
94 numeral is found.
95 The parameter found is set TRUE if a number was found.
98 EXTERN unsigned int StringConvert_StringToCardinal (DynamicStrings_String s, unsigned int base, bool *found);
101 LongIntegerToString - converts LONGINT, i, into a String. The field with
102 can be specified if non zero. Leading characters
103 are defined by padding and this function will
104 prepend a + if sign is set to TRUE.
105 The base allows the caller to generate binary,
106 octal, decimal, hexidecimal numbers.
107 The value of lower is only used when hexidecimal
108 numbers are generated and if TRUE then digits
109 abcdef are used, and if FALSE then ABCDEF are used.
112 EXTERN DynamicStrings_String StringConvert_LongIntegerToString (long int i, unsigned int width, char padding, bool sign, unsigned int base, bool lower);
115 StringToLongInteger - converts a string, s, of, base, into an LONGINT.
116 Leading white space is ignored. It stops converting
117 when either the string is exhausted or if an illegal
118 numeral is found.
119 The parameter found is set TRUE if a number was found.
122 EXTERN long int StringConvert_StringToLongInteger (DynamicStrings_String s, unsigned int base, bool *found);
125 LongCardinalToString - converts LONGCARD, c, into a String. The field
126 width can be specified if non zero. Leading
127 characters are defined by padding.
128 The base allows the caller to generate binary,
129 octal, decimal, hexidecimal numbers.
130 The value of lower is only used when hexidecimal
131 numbers are generated and if TRUE then digits
132 abcdef are used, and if FALSE then ABCDEF are used.
135 EXTERN DynamicStrings_String StringConvert_LongCardinalToString (long unsigned int c, unsigned int width, char padding, unsigned int base, bool lower);
138 StringToLongCardinal - converts a string, s, of, base, into a LONGCARD.
139 Leading white space is ignored. It stops converting
140 when either the string is exhausted or if an illegal
141 numeral is found.
142 The parameter found is set TRUE if a number was found.
145 EXTERN long unsigned int StringConvert_StringToLongCardinal (DynamicStrings_String s, unsigned int base, bool *found);
148 ShortCardinalToString - converts SHORTCARD, c, into a String. The field
149 width can be specified if non zero. Leading
150 characters are defined by padding.
151 The base allows the caller to generate binary,
152 octal, decimal, hexidecimal numbers.
153 The value of lower is only used when hexidecimal
154 numbers are generated and if TRUE then digits
155 abcdef are used, and if FALSE then ABCDEF are used.
158 EXTERN DynamicStrings_String StringConvert_ShortCardinalToString (short unsigned int c, unsigned int width, char padding, unsigned int base, bool lower);
161 StringToShortCardinal - converts a string, s, of, base, into a SHORTCARD.
162 Leading white space is ignored. It stops converting
163 when either the string is exhausted or if an illegal
164 numeral is found.
165 The parameter found is set TRUE if a number was found.
168 EXTERN short unsigned int StringConvert_StringToShortCardinal (DynamicStrings_String s, unsigned int base, bool *found);
171 stoi - decimal string to INTEGER
174 EXTERN int StringConvert_stoi (DynamicStrings_String s);
177 itos - integer to decimal string.
180 EXTERN DynamicStrings_String StringConvert_itos (int i, unsigned int width, char padding, bool sign);
183 ctos - cardinal to decimal string.
186 EXTERN DynamicStrings_String StringConvert_ctos (unsigned int c, unsigned int width, char padding);
189 stoc - decimal string to CARDINAL
192 EXTERN unsigned int StringConvert_stoc (DynamicStrings_String s);
195 hstoi - hexidecimal string to INTEGER
198 EXTERN int StringConvert_hstoi (DynamicStrings_String s);
201 ostoi - octal string to INTEGER
204 EXTERN int StringConvert_ostoi (DynamicStrings_String s);
207 bstoi - binary string to INTEGER
210 EXTERN int StringConvert_bstoi (DynamicStrings_String s);
213 hstoc - hexidecimal string to CARDINAL
216 EXTERN unsigned int StringConvert_hstoc (DynamicStrings_String s);
219 ostoc - octal string to CARDINAL
222 EXTERN unsigned int StringConvert_ostoc (DynamicStrings_String s);
225 bstoc - binary string to CARDINAL
228 EXTERN unsigned int StringConvert_bstoc (DynamicStrings_String s);
231 StringToLongreal - returns a LONGREAL and sets found to TRUE
232 if a legal number is seen.
235 EXTERN long double StringConvert_StringToLongreal (DynamicStrings_String s, bool *found);
238 LongrealToString - converts a LONGREAL number, Real, which has,
239 TotalWidth, and FractionWidth into a string.
241 So for example:
243 LongrealToString(1.0, 4, 2) -> '1.00'
244 LongrealToString(12.3, 5, 2) -> '12.30'
245 LongrealToString(12.3, 6, 2) -> ' 12.30'
246 LongrealToString(12.3, 6, 3) -> '12.300'
248 if total width is too small then the fraction
249 becomes truncated.
251 LongrealToString(12.3, 5, 3) -> '12.30'
253 If TotalWidth is 0 then the function
254 will return the value of x which is converted
255 into as a fixed point number with exhaustive
256 precision.
259 EXTERN DynamicStrings_String StringConvert_LongrealToString (long double x, unsigned int TotalWidth, unsigned int FractionWidth);
262 stor - returns a REAL given a string.
265 EXTERN double StringConvert_stor (DynamicStrings_String s);
268 stolr - returns a LONGREAL given a string.
271 EXTERN long double StringConvert_stolr (DynamicStrings_String s);
274 ToSigFig - returns a floating point or base 10 integer
275 string which is accurate to, n, significant
276 figures. It will return a new String
277 and, s, will be destroyed.
280 So: 12.345
282 rounded to the following significant figures yields
284 5 12.345
285 4 12.34
286 3 12.3
287 2 12
288 1 10
291 EXTERN DynamicStrings_String StringConvert_ToSigFig (DynamicStrings_String s, unsigned int n);
294 ToDecimalPlaces - returns a floating point or base 10 integer
295 string which is accurate to, n, decimal
296 places. It will return a new String
297 and, s, will be destroyed.
298 Decimal places yields, n, digits after
299 the .
301 So: 12.345
303 rounded to the following decimal places yields
305 5 12.34500
306 4 12.3450
307 3 12.345
308 2 12.34
309 1 12.3
312 EXTERN DynamicStrings_String StringConvert_ToDecimalPlaces (DynamicStrings_String s, unsigned int n);
313 # ifdef __cplusplus
315 # endif
317 # undef EXTERN
318 #endif