]> www.ginac.de Git - cln.git/blob - include/cl_integer_io.h
Distinguish between cl_word_size and the ABI's pointer size.
[cln.git] / include / cl_integer_io.h
1 // I/O of integers.
2
3 #ifndef _CL_INTEGER_IO_H
4 #define _CL_INTEGER_IO_H
5
6 #include "cl_number_io.h"
7 #include "cl_integer_class.h"
8
9
10 // Undocumented input functions
11
12 // Wandelt eine Zeichenkette mit Integer-Syntax in ein Integer um.
13 // Punkte werden überlesen.
14 // read_integer(base,sign,string,index1,index2)
15 // > base: Lesebasis (>=2, <=36)
16 // > sign: Vorzeichen (/=0 falls negativ)
17 // > string: Simple-String (enthält Ziffern mit Wert <base und evtl. Punkt)
18 // > index1: Index der ersten Ziffer
19 // > index2: Index nach der letzten Ziffer
20 //   (also index2-index1 Ziffern, incl. evtl. Dezimalpunkt am Schluß)
21 // < ergebnis: Integer
22 extern const cl_I read_integer (unsigned int base,
23                   cl_signean sign, const char * string, uintL index1, uintL index2);
24
25 // The following does strictly the same as the general read_complex.
26 // It is here only so that you don't need the rational, complex and float number
27 // readers in order to read an integer. ("Treeshaking")
28 extern const cl_I read_integer (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse);
29 extern const cl_I read_integer (cl_istream stream, const cl_read_flags& flags);
30
31 // Documented input functions
32
33 inline cl_istream operator>> (cl_istream stream, cl_I& result)
34 {
35         extern cl_read_flags cl_I_read_flags;
36         result = read_integer(stream,cl_I_read_flags);
37         return stream;
38 }
39
40
41 // Undocumented output functions
42
43 // Liefert zu einem Integer >=0  (write-to-string integer :base 10 :radix nil),
44 // also die Ziffernfolge als String.
45 // Mit cl_malloc_hook() alloziert, mit cl_free_hook() freizugeben.
46 extern char * cl_decimal_string (const cl_I& x);
47
48 // Gibt ein Integer aus.
49 // print_integer(stream,base,z);
50 // > z: Integer
51 // > base: Basis (>=2, <=36)
52 // > stream: Stream
53 extern void print_integer (cl_ostream stream, unsigned int base, const cl_I& z);
54 // Dasselbe als String. Mit cl_malloc_hook() alloziert, mit cl_free_hook() freizugeben.
55 extern char * print_integer_to_string (unsigned int base, const cl_I& z);
56
57
58 // Documented output functions
59
60 inline void fprintdecimal (cl_ostream stream, const cl_I& x)
61 {
62         print_integer(stream,10,x);
63 }
64
65 inline void fprintbinary (cl_ostream stream, const cl_I& x)
66 {
67         print_integer(stream,2,x);
68 }
69
70 inline void fprintoctal (cl_ostream stream, const cl_I& x)
71 {
72         print_integer(stream,8,x);
73 }
74
75 inline void fprinthexadecimal (cl_ostream stream, const cl_I& x)
76 {
77         print_integer(stream,16,x);
78 }
79
80 // Gibt eine Zahl aus.
81 // print_integer(stream,flags,z);
82 // > z: Zahl
83 // > stream: Stream
84 // > flags: Ausgabe-Parameter
85 extern void print_integer (cl_ostream stream, const cl_print_flags& flags, const cl_I& z);
86 extern void print_integer (cl_ostream stream, const cl_print_number_flags& flags, const cl_I& z);
87 extern void print_integer (cl_ostream stream, const cl_print_real_flags& flags, const cl_I& z);
88 extern void print_integer (cl_ostream stream, const cl_print_rational_flags& flags, const cl_I& z);
89
90 // The following does strictly the same as the general `fprint' for numbers.
91 // It is here only so that you don't need the rational number printer
92 // in order to print an integer. ("Treeshaking")
93
94 inline void fprint (cl_ostream stream, const cl_I& x)
95 {
96         extern cl_print_flags cl_default_print_flags;
97         print_integer(stream,cl_default_print_flags,x);
98 }
99
100 CL_DEFINE_PRINT_OPERATOR(cl_I)
101
102
103 #endif /* _CL_INTEGER_IO_H */