]> www.ginac.de Git - cln.git/blob - include/cln/io.h
Support x32 ABI.
[cln.git] / include / cln / io.h
1 // I/O through <iostream>
2
3 #ifndef _CL_IO_H
4 #define _CL_IO_H
5
6 #include "cln/types.h"
7 #include "cln/modules.h"
8
9 // I/O through <iostream>
10
11 #ifdef floor
12   #undef floor
13   #include <iostream>
14   #define floor cln_floor
15 #else
16   #include <iostream>
17 #endif
18
19 namespace cln {
20
21 // compatibility:
22 typedef std::istream& cl_istream;
23 typedef std::ostream& cl_ostream;
24 extern std::ostream* cl_debugout_stream;
25 #define cl_debugout  (*cl_debugout_stream)
26
27 // Elementary operations on std::ostream&
28
29 inline void fprintchar (std::ostream& stream, char c)
30 {
31         stream.put(c);
32 }
33
34 inline void fprint (std::ostream& stream, const char * string)
35 {
36         stream << string;
37 }
38
39
40 extern void fprintdecimal (std::ostream& stream, unsigned long x);
41 extern void fprintdecimal (std::ostream& stream, long x);
42
43 inline void fprintdecimal (std::ostream& stream, unsigned int x)
44 {
45         fprintdecimal(stream,(unsigned long)x);
46 }
47 inline void fprintdecimal (std::ostream& stream, int x)
48 {
49         fprintdecimal(stream,(long)x);
50 }
51
52 extern void fprinthexadecimal (std::ostream& stream, unsigned long x);
53 extern void fprinthexadecimal (std::ostream& stream, long x);
54
55 inline void fprinthexadecimal (std::ostream& stream, unsigned int x)
56 {
57         fprinthexadecimal(stream,(unsigned long)x);
58 }
59 inline void fprinthexadecimal (std::ostream& stream, int x)
60 {
61         fprinthexadecimal(stream,(long)x);
62 }
63
64
65 struct cl_print_flags;
66 struct cl_print_number_flags;
67 struct cl_print_real_flags;
68 struct cl_print_rational_flags;
69 struct cl_print_float_flags;
70
71 class cl_prin_globals_init_helper
72 {
73         static int count;
74 public:
75         cl_prin_globals_init_helper();
76         ~cl_prin_globals_init_helper();
77 };
78 static cl_prin_globals_init_helper cl_prin_globals_init_helper_instance;
79
80 // Define the customary << and >> operators.
81
82 #define CL_DEFINE_PRINT_OPERATOR(_class_)  \
83 inline std::ostream& operator<< (std::ostream& stream, const _class_& x)        \
84 {                                                                       \
85         fprint(stream,x);                                               \
86         return stream;                                                  \
87 }
88         
89 }  // namespace cln
90
91 #endif /* _CL_IO_H */