home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / SASC6571.LZX / cxxinclude / stream.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-12-24  |  2.4 KB  |  108 lines

  1. /* Copyright (c) 1993             by SAS Institute Inc., Cary NC     */
  2.  
  3. #ifndef __STREAM_H
  4. #define __STREAM_H
  5.  
  6. #ifndef __IOSTREAM_H
  7. #include <iostream.h>
  8. #endif
  9.  
  10. #ifndef __IOMANIP_H
  11. #include <iomanip.h>
  12. #endif
  13.  
  14. #ifndef __STDIOSTREAM_H
  15. #include <stdiostream.h>
  16. #endif
  17.  
  18. #ifndef __FSTREAM_H
  19. #include <fstream.h>
  20. #endif
  21.  
  22. #ifndef NULL
  23. #define NULL    0
  24. #endif
  25.  
  26.  
  27.  
  28. char* form( char* format, ... );
  29.     // This function is very similar to printf except that
  30.     // instead of printing to standard output, 'form' returns
  31.     // a string formated as specified in 'format'.
  32.  
  33. /*
  34.   These functions format the value of 'l' into a string
  35.   which they return.
  36.   
  37.   oct - formats as an octal number using the digits 0-7.
  38.   hex - as a hexidecimal number using the digits 0-9 and
  39.           upper case digits A-F.
  40.   dec - as a decimal number using the digits 0-9.
  41.   chr - format 'i' as a char.
  42.   str - format 'st' as a string.
  43.  
  44.   If 'size' is zero the returned string will be exactly as
  45.   long as needed to represent the value of 'l'.  Otherwise
  46.   is 'size' is less than the length of the represtation
  47.   the represtation will be truncated on the right, and if 'size'
  48.   is greater than the length of the represtation spaces will be
  49.   added to the left of the representation.
  50.   */
  51.  
  52. #ifdef _OPTINLINE
  53. inline
  54. #endif
  55. char* oct( long l, int size = 0 ) 
  56.     _INLINE_FUNC({ return form( "%*lo", size, l ); })
  57.  
  58. #ifdef _OPTINLINE
  59. inline
  60. #endif
  61. char* hex( long l, int size = 0 ) 
  62.     _INLINE_FUNC({ return form( "%*lx", size, l ); })
  63.  
  64. #ifdef _OPTINLINE
  65. inline
  66. #endif
  67. char* dec( long l, int size = 0 ) 
  68.     _INLINE_FUNC({ return form( "%*ld", size, l ); })
  69.  
  70. #ifdef _OPTINLINE
  71. inline
  72. #endif
  73. char* chr( int i, int size = 0 )
  74.     _INLINE_FUNC({ return form( "%*c",  size, i ); })
  75.  
  76. #ifdef _OPTINLINE
  77. inline
  78. #endif
  79. char* str( char* st, int size = 0 ) 
  80.     _INLINE_FUNC({ return form( "%*s", size, st ); })
  81.  
  82. #ifdef _OPTINLINE
  83. inline
  84. #endif
  85. istream& WS(istream& i )
  86.     _INLINE_FUNC({ return i >> ws; })
  87.  
  88. #ifdef _OPTINLINE
  89. inline
  90. #endif
  91. void eatwhite( istream& i ) 
  92.     _INLINE_FUNC({ i >> ws; })
  93.  
  94. static const int input = (ios::in) ;
  95. static const int output = (ios::out) ;
  96. static const int append = (ios::app) ;
  97. static const int atend = (ios::ate) ;
  98. static const int _good = (ios::goodbit) ;
  99. static const int _bad = (ios::badbit) ;
  100. static const int _fail = (ios::failbit) ;
  101. static const int _eof = (ios::eofbit) ;
  102.  
  103. typedef ios::io_state state_value ;
  104.  
  105. #endif /* __STREAM_H */
  106.  
  107.  
  108.