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.

112 lines
2.2 KiB

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