]> www.ginac.de Git - cln.git/blob - include/cln/io.h
Finalize CLN 1.3.7 release.
[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 int x);
41 extern void fprintdecimal (std::ostream& stream, int x);
42
43 extern void fprintdecimal (std::ostream& stream, unsigned long x);
44 extern void fprintdecimal (std::ostream& stream, long x);
45
46 extern void fprintdecimal (std::ostream& stream, unsigned long long x);
47 extern void fprintdecimal (std::ostream& stream, long long x);
48
49 extern void fprinthexadecimal (std::ostream& stream, unsigned int x);
50 extern void fprinthexadecimal (std::ostream& stream, int x);
51
52 extern void fprinthexadecimal (std::ostream& stream, unsigned long x);
53 extern void fprinthexadecimal (std::ostream& stream, long x);
54
55 extern void fprinthexadecimal (std::ostream& stream, unsigned long long x);
56 extern void fprinthexadecimal (std::ostream& stream, long long x);
57
58
59 struct cl_print_flags;
60 struct cl_print_number_flags;
61 struct cl_print_real_flags;
62 struct cl_print_rational_flags;
63 struct cl_print_float_flags;
64
65 class cl_prin_globals_init_helper
66 {
67         static int count;
68 public:
69         cl_prin_globals_init_helper();
70         ~cl_prin_globals_init_helper();
71 };
72 static cl_prin_globals_init_helper cl_prin_globals_init_helper_instance;
73
74 // Define the customary << and >> operators.
75
76 #define CL_DEFINE_PRINT_OPERATOR(_class_)  \
77 inline std::ostream& operator<< (std::ostream& stream, const _class_& x)        \
78 {                                                                       \
79         fprint(stream,x);                                               \
80         return stream;                                                  \
81 }
82         
83 }  // namespace cln
84
85 #endif /* _CL_IO_H */