3 #ifndef _CL_INTEGER_IO_H
4 #define _CL_INTEGER_IO_H
6 #include "cln/number_io.h"
7 #include "cln/integer_class.h"
11 // Undocumented input functions
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 // Documented input functions
34 inline std::istream& operator>> (std::istream& stream, cl_I& result)
36 extern cl_read_flags cl_I_read_flags;
37 result = read_integer(stream,cl_I_read_flags);
42 // Undocumented output functions
44 // Liefert zu einem Integer >=0 (write-to-string integer :base 10 :radix nil),
45 // also die Ziffernfolge als String.
46 // Mit malloc_hook() alloziert, mit free_hook() freizugeben.
47 extern char * cl_decimal_string (const cl_I& x);
49 // Gibt ein Integer aus.
50 // print_integer(stream,base,z);
52 // > base: Basis (>=2, <=36)
54 extern void print_integer (std::ostream& stream, unsigned int base, const cl_I& z);
55 // Dasselbe als String. Mit malloc_hook() alloziert, mit free_hook() freizugeben.
56 extern char * print_integer_to_string (unsigned int base, const cl_I& z);
59 // Documented output functions
61 inline void fprintdecimal (std::ostream& stream, const cl_I& x)
63 print_integer(stream,10,x);
66 inline void fprintbinary (std::ostream& stream, const cl_I& x)
68 print_integer(stream,2,x);
71 inline void fprintoctal (std::ostream& stream, const cl_I& x)
73 print_integer(stream,8,x);
76 inline void fprinthexadecimal (std::ostream& stream, const cl_I& x)
78 print_integer(stream,16,x);
81 // Gibt eine Zahl aus.
82 // print_integer(stream,flags,z);
85 // > flags: Ausgabe-Parameter
86 extern void print_integer (std::ostream& stream, const cl_print_flags& flags, const cl_I& z);
87 extern void print_integer (std::ostream& stream, const cl_print_number_flags& flags, const cl_I& z);
88 extern void print_integer (std::ostream& stream, const cl_print_real_flags& flags, const cl_I& z);
89 extern void print_integer (std::ostream& stream, const cl_print_rational_flags& flags, const cl_I& z);
91 // The following does strictly the same as the general `fprint' for numbers.
92 // It is here only so that you don't need the rational number printer
93 // in order to print an integer. ("Treeshaking")
95 inline void fprint (std::ostream& stream, const cl_I& x)
97 extern cl_print_flags default_print_flags;
98 print_integer(stream,default_print_flags,x);
101 CL_DEFINE_PRINT_OPERATOR(cl_I)
105 #endif /* _CL_INTEGER_IO_H */