]> www.ginac.de Git - cln.git/blob - include/cln/io.h
* */*: Removed problematic stdin, stdout and stderr definitions.
[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 typedef std::istream& cl_istream;
22 typedef std::ostream& cl_ostream;
23 extern std::ostream* cl_debugout_stream;
24 #define cl_debugout  (*cl_debugout_stream)
25
26 // Elementary operations on cl_istream
27
28 #define cl_EOF  (-1)
29
30 inline int freadchar (cl_istream stream)
31 {
32         char c;
33         if (stream.get(c))
34                 return c;
35         else
36                 // EOF or error
37                 return cl_EOF;
38 }
39
40 inline int funreadchar (cl_istream stream, int c)
41 {
42         if (c != cl_EOF)
43                 stream.putback((char)c);
44         return c;
45 }
46
47 // Elementary operations on cl_ostream
48
49 inline void fprintchar (cl_ostream stream, char c)
50 {
51         stream.put(c);
52 }
53
54 inline void fprint (cl_ostream stream, const char * string)
55 {
56         stream << string;
57 }
58
59
60 extern void fprintdecimal (cl_ostream stream, unsigned long x);
61 extern void fprintdecimal (cl_ostream stream, long x);
62
63 inline void fprintdecimal (cl_ostream stream, unsigned int x)
64 {
65         fprintdecimal(stream,(unsigned long)x);
66 }
67 inline void fprintdecimal (cl_ostream stream, int x)
68 {
69         fprintdecimal(stream,(long)x);
70 }
71
72 extern void fprinthexadecimal (cl_ostream stream, unsigned long x);
73 extern void fprinthexadecimal (cl_ostream stream, long x);
74
75 inline void fprinthexadecimal (cl_ostream stream, unsigned int x)
76 {
77         fprinthexadecimal(stream,(unsigned long)x);
78 }
79 inline void fprinthexadecimal (cl_ostream stream, int x)
80 {
81         fprinthexadecimal(stream,(long)x);
82 }
83
84
85 class cl_print_flags;
86 class cl_print_number_flags;
87 class cl_print_real_flags;
88 class cl_print_rational_flags;
89 class cl_print_float_flags;
90 CL_REQUIRE(cl_prin_globals)
91
92
93 // Define the customary << and >> operators.
94
95 #define CL_DEFINE_PRINT_OPERATOR(_class_)  \
96 inline cl_ostream operator<< (cl_ostream stream, const _class_& x)      \
97 {                                                                       \
98         fprint(stream,x);                                               \
99         return stream;                                                  \
100 }
101         
102 }  // namespace cln
103
104 #endif /* _CL_IO_H */