You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.1 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
  1. // I/O through <stdio.h> or <iostream>
  2. #ifndef _CL_IO_H
  3. #define _CL_IO_H
  4. #include "cln/types.h"
  5. #include "cln/modules.h"
  6. // I/O through <iostream>
  7. #ifdef floor
  8. #undef floor
  9. #include <iostream>
  10. #define floor cln_floor
  11. #else
  12. #include <iostream>
  13. #endif
  14. namespace cln {
  15. typedef std::istream& cl_istream;
  16. typedef std::ostream& cl_ostream;
  17. extern cl_istream stdin;
  18. extern cl_ostream stdout;
  19. extern cl_ostream stderr;
  20. extern std::ostream* cl_debugout_stream;
  21. #define cl_debugout (*cl_debugout_stream)
  22. // Elementary operations on cl_istream
  23. #define cl_EOF (-1)
  24. inline int freadchar (cl_istream stream)
  25. {
  26. char c;
  27. if (stream.get(c))
  28. return c;
  29. else
  30. // EOF or error
  31. return cl_EOF;
  32. }
  33. inline int funreadchar (cl_istream stream, int c)
  34. {
  35. if (c != cl_EOF)
  36. stream.putback((char)c);
  37. return c;
  38. }
  39. // Elementary operations on cl_ostream
  40. inline void fprintchar (cl_ostream stream, char c)
  41. {
  42. stream.put(c);
  43. }
  44. inline void fprint (cl_ostream stream, const char * string)
  45. {
  46. stream << string;
  47. }
  48. extern void fprintdecimal (cl_ostream stream, unsigned long x);
  49. extern void fprintdecimal (cl_ostream stream, long x);
  50. inline void fprintdecimal (cl_ostream stream, unsigned int x)
  51. {
  52. fprintdecimal(stream,(unsigned long)x);
  53. }
  54. inline void fprintdecimal (cl_ostream stream, int x)
  55. {
  56. fprintdecimal(stream,(long)x);
  57. }
  58. extern void fprinthexadecimal (cl_ostream stream, unsigned long x);
  59. extern void fprinthexadecimal (cl_ostream stream, long x);
  60. inline void fprinthexadecimal (cl_ostream stream, unsigned int x)
  61. {
  62. fprinthexadecimal(stream,(unsigned long)x);
  63. }
  64. inline void fprinthexadecimal (cl_ostream stream, int x)
  65. {
  66. fprinthexadecimal(stream,(long)x);
  67. }
  68. class cl_print_flags;
  69. class cl_print_number_flags;
  70. class cl_print_real_flags;
  71. class cl_print_rational_flags;
  72. class cl_print_float_flags;
  73. CL_REQUIRE(cl_prin_globals)
  74. // Define the customary << and >> operators.
  75. #define CL_DEFINE_PRINT_OPERATOR(_class_) \
  76. inline cl_ostream operator<< (cl_ostream stream, const _class_& x) \
  77. { \
  78. fprint(stream,x); \
  79. return stream; \
  80. }
  81. } // namespace cln
  82. #endif /* _CL_IO_H */