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.

104 lines
2.0 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 <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 std::ostream* cl_debugout_stream;
  18. #define cl_debugout (*cl_debugout_stream)
  19. // Elementary operations on cl_istream
  20. #define cl_EOF (-1)
  21. inline int freadchar (cl_istream stream)
  22. {
  23. char c;
  24. if (stream.get(c))
  25. return c;
  26. else
  27. // EOF or error
  28. return cl_EOF;
  29. }
  30. inline int funreadchar (cl_istream stream, int c)
  31. {
  32. if (c != cl_EOF)
  33. stream.putback((char)c);
  34. return c;
  35. }
  36. // Elementary operations on cl_ostream
  37. inline void fprintchar (cl_ostream stream, char c)
  38. {
  39. stream.put(c);
  40. }
  41. inline void fprint (cl_ostream stream, const char * string)
  42. {
  43. stream << string;
  44. }
  45. extern void fprintdecimal (cl_ostream stream, unsigned long x);
  46. extern void fprintdecimal (cl_ostream stream, long x);
  47. inline void fprintdecimal (cl_ostream stream, unsigned int x)
  48. {
  49. fprintdecimal(stream,(unsigned long)x);
  50. }
  51. inline void fprintdecimal (cl_ostream stream, int x)
  52. {
  53. fprintdecimal(stream,(long)x);
  54. }
  55. extern void fprinthexadecimal (cl_ostream stream, unsigned long x);
  56. extern void fprinthexadecimal (cl_ostream stream, long x);
  57. inline void fprinthexadecimal (cl_ostream stream, unsigned int x)
  58. {
  59. fprinthexadecimal(stream,(unsigned long)x);
  60. }
  61. inline void fprinthexadecimal (cl_ostream stream, int x)
  62. {
  63. fprinthexadecimal(stream,(long)x);
  64. }
  65. class cl_print_flags;
  66. class cl_print_number_flags;
  67. class cl_print_real_flags;
  68. class cl_print_rational_flags;
  69. class cl_print_float_flags;
  70. CL_REQUIRE(cl_prin_globals)
  71. // Define the customary << and >> operators.
  72. #define CL_DEFINE_PRINT_OPERATOR(_class_) \
  73. inline cl_ostream operator<< (cl_ostream stream, const _class_& x) \
  74. { \
  75. fprint(stream,x); \
  76. return stream; \
  77. }
  78. } // namespace cln
  79. #endif /* _CL_IO_H */