home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / Languages / python / PyObjC-0.47-MIHS / pyobjc-0.47-src / Include / OC_Stream.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-23  |  2.8 KB  |  132 lines

  1. /* Copyright (c) 1996 by Lele Gaifax.  All Rights Reserved
  2.  *
  3.  * This software may be used and distributed freely for any purpose
  4.  * provided that this notice is included unchanged on any and all
  5.  * copies. The author does not warrant or guarantee this software in
  6.  * any way.
  7.  *
  8.  * This file is part of the PyObjC package.
  9.  *
  10.  * $RCSfile: OC_Stream.h,v $
  11.  * $Revision: 1.1.1.3 $
  12.  * $Date: 1996/10/23 17:19:35 $
  13.  *
  14.  * Created Fri Oct  4 12:28:57 1996.
  15.  */
  16.  
  17. #ifndef _OC_Stream_H
  18. #define _OC_Stream_H
  19.  
  20. #ifndef GNU_RUNTIME
  21.  
  22. @protocol Streaming
  23.  
  24. - (int) readByte:(char *) cp;
  25. - (int) readBytes:(void *) buf length:(unsigned int) len;
  26.  
  27. - (int) writeByte:(char) c;
  28. - (int) writeBytes:(void *) buf length:(unsigned int) len;
  29.  
  30. - (void) setStreamPosition:(long) pos seekMode:(int) mode;
  31. - (long) streamPosition;
  32.  
  33. - (BOOL) isAtEof;
  34.  
  35. - (void) flushStream;
  36.  
  37. - (void) close;
  38. - (BOOL) isClosed;
  39.  
  40. - (BOOL) isWritable;
  41.  
  42. @end
  43.  
  44. #else
  45.  
  46. #include <gnustep/base/Streaming.h>
  47.  
  48. #endif
  49.  
  50. #ifndef WITH_FOUNDATION 
  51.  
  52. #include <objc/Object.h>
  53. #include <streams/streams.h>
  54.  
  55. #define OCS_READONLY NX_READONLY
  56. #define OCS_WRITEONLY NX_WRITEONLY
  57. #define OCS_READWRITE NX_READWRITE
  58. #define OCS_APPEND (OCS_READWRITE << 1)
  59.  
  60. #define OCS_FROMSTART NX_FROMSTART
  61. #define OCS_FROMCURRENT NX_FROMCURRENT
  62. #define OCS_FROMEND NX_FROMEND
  63.  
  64. /*#C This class wraps the NeXTSTEP stream functions into an object
  65.   similar to the GNUstep Stream. */
  66. @interface OC_Stream : Object <Streaming>
  67. {
  68.   NXStream *stream;
  69.   BOOL freeWhenDone;
  70. }
  71.  
  72. //#M Initialize the version number of this class.
  73. + (void) initialize;
  74.  
  75. + newFromFilename:(const char *) name;
  76. + newFromFilename:(const char *) name withMode:(int) m;
  77.  
  78. + newFromMemory:(void *) mem length:(unsigned int) len;
  79. + newFromMemory:(void *) mem length:(unsigned int) len withMode:(int) m;
  80.  
  81. + newFromStream:(NXStream *) s;
  82.  
  83. - initFromStream:(NXStream *) s;
  84.  
  85. - (void) freeWhenDone:(BOOL) yn;
  86.  
  87. - (BOOL) saveToFilename:(const char *) name;
  88.  
  89. - (NXStream *) stream;
  90.  
  91. @end /* OC_Stream class interface */
  92.  
  93. #else /* WITH_FOUNDATION */
  94.  
  95. #include <Foundation/NSData.h>
  96.  
  97. #define OCS_READONLY 0
  98. #define OCS_WRITEONLY 1
  99. #define OCS_READWRITE 2
  100. #define OCS_APPEND 3
  101.  
  102. #define OCS_FROMSTART STREAM_SEEK_FROM_START
  103. #define OCS_FROMCURRENT STREAM_SEEK_FROM_CURRENT
  104. #define OCS_FROMEND STREAM_SEEK_FROM_END
  105.  
  106. /*#C This class wraps OpenStep NSData into an object similar to
  107.   a stream. */
  108. @interface OC_Stream : NSData <Streaming>
  109. {
  110.   unsigned long offset;
  111. }
  112.  
  113. + newFromFilename:(const char *) name;
  114. + newFromFilename:(const char *) name withMode:(int) m;
  115.  
  116. + newFromMemory:(void *) mem length:(unsigned int) len;
  117. + newFromMemory:(void *) mem length:(unsigned int) len withMode:(int) m;
  118.  
  119. - (BOOL) saveToFilename:(const char *) name;
  120.  
  121. @end /* OC_Stream class interface */
  122.  
  123. #endif /* WITH_FOUNDATION */
  124.  
  125. #endif /* _OC_Stream_H */
  126.  
  127. /*
  128. ** Local Variables:
  129. ** change-log-default-name:"../ChangeLog.PyObjC"
  130. ** End:
  131. */
  132.