3 #ifndef _CL_INTEGER_IO_H
4 #define _CL_INTEGER_IO_H
6 #include "cln/number_io.h"
7 #include "cln/integer_class.h"
13 // Wandelt eine Zeichenkette mit Integer-Syntax in ein Integer um.
14 // Punkte werden überlesen.
15 // read_integer(base,sign,string,index1,index2)
16 // > base: Lesebasis (>=2, <=36)
17 // > sign: Vorzeichen (/=0 falls negativ)
18 // > string: Simple-String (enthält Ziffern mit Wert <base und evtl. Punkt)
19 // > index1: Index der ersten Ziffer
20 // > index2: Index nach der letzten Ziffer
21 // (also index2-index1 Ziffern, incl. evtl. Dezimalpunkt am Schluß)
22 // < ergebnis: Integer
23 extern const cl_I read_integer (unsigned int base,
24 cl_signean sign, const char * string, uintC index1, uintC index2);
26 // The following does strictly the same as the general read_complex.
27 // It is here only so that you don't need the rational, complex and float number
28 // readers in order to read an integer. ("Treeshaking")
29 extern const cl_I read_integer (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse);
30 extern const cl_I read_integer (std::istream& stream, const cl_read_flags& flags);
32 inline std::istream& operator>> (std::istream& stream, cl_I& result)
34 extern cl_read_flags cl_I_read_flags;
35 result = read_integer(stream,cl_I_read_flags);
42 // Liefert zu einem Integer >=0 (write-to-string integer :base 10 :radix nil),
43 // also die Ziffernfolge als String.
44 // Mit malloc_hook() alloziert, mit free_hook() freizugeben.
45 extern char * cl_decimal_string (const cl_I& x);
47 // Gibt ein Integer aus.
48 // print_integer(stream,base,z);
50 // > base: Basis (>=2, <=36)
52 extern void print_integer (std::ostream& stream, unsigned int base, const cl_I& z);
53 // Dasselbe als String. Mit malloc_hook() alloziert, mit free_hook() freizugeben.
54 extern char * print_integer_to_string (unsigned int base, const cl_I& z);
56 inline void fprintdecimal (std::ostream& stream, const cl_I& x)
58 print_integer(stream,10,x);
61 inline void fprintbinary (std::ostream& stream, const cl_I& x)
63 print_integer(stream,2,x);
66 inline void fprintoctal (std::ostream& stream, const cl_I& x)
68 print_integer(stream,8,x);
71 inline void fprinthexadecimal (std::ostream& stream, const cl_I& x)
73 print_integer(stream,16,x);
76 // Gibt eine Zahl aus.
77 // print_integer(stream,flags,z);
80 // > flags: Ausgabe-Parameter
81 extern void print_integer (std::ostream& stream, const cl_print_flags& flags, const cl_I& z);
82 extern void print_integer (std::ostream& stream, const cl_print_number_flags& flags, const cl_I& z);
83 extern void print_integer (std::ostream& stream, const cl_print_real_flags& flags, const cl_I& z);
84 extern void print_integer (std::ostream& stream, const cl_print_rational_flags& flags, const cl_I& z);
86 // The following does strictly the same as the general `fprint' for numbers.
87 // It is here only so that you don't need the rational number printer
88 // in order to print an integer. ("Treeshaking")
90 inline void fprint (std::ostream& stream, const cl_I& x)
92 extern cl_print_flags default_print_flags;
93 print_integer(stream,default_print_flags,x);
96 CL_DEFINE_PRINT_OPERATOR(cl_I)
100 #endif /* _CL_INTEGER_IO_H */