PageRenderTime 70ms CodeModel.GetById 53ms RepoModel.GetById 1ms app.codeStats 0ms

/gecko_api/include/nsIInputStream.h

http://firefox-mac-pdf.googlecode.com/
C Header | 264 lines | 87 code | 35 blank | 142 comment | 0 complexity | 15769b190efdbf3b12e04793a7e53b8f MD5 | raw file
  1. /*
  2. * DO NOT EDIT. THIS FILE IS GENERATED FROM /builds/tinderbox/XR-Trunk/Darwin_8.8.4_Depend/mozilla/xpcom/io/nsIInputStream.idl
  3. */
  4. #ifndef __gen_nsIInputStream_h__
  5. #define __gen_nsIInputStream_h__
  6. #ifndef __gen_nsISupports_h__
  7. #include "nsISupports.h"
  8. #endif
  9. /* For IDL files that don't want to include root IDL files. */
  10. #ifndef NS_NO_VTABLE
  11. #define NS_NO_VTABLE
  12. #endif
  13. class nsIInputStream; /* forward declaration */
  14. /**
  15. * The signature of the writer function passed to ReadSegments. This
  16. * is the "consumer" of data that gets read from the stream's buffer.
  17. *
  18. * @param aInStream stream being read
  19. * @param aClosure opaque parameter passed to ReadSegments
  20. * @param aFromSegment pointer to memory owned by the input stream. This is
  21. * where the writer function should start consuming data.
  22. * @param aToOffset amount of data already consumed by this writer during this
  23. * ReadSegments call. This is also the sum of the aWriteCount
  24. * returns from this writer over the previous invocations of
  25. * the writer by this ReadSegments call.
  26. * @param aCount Number of bytes available to be read starting at aFromSegment
  27. * @param [out] aWriteCount number of bytes read by this writer function call
  28. *
  29. * Implementers should return the following:
  30. *
  31. * @return NS_OK and (*aWriteCount > 0) if consumed some data
  32. * @return <any-error> if not interested in consuming any data
  33. *
  34. * Errors are never passed to the caller of ReadSegments.
  35. *
  36. * NOTE: returning NS_OK and (*aWriteCount = 0) has undefined behavior.
  37. *
  38. * @status FROZEN
  39. */
  40. typedef NS_CALLBACK(nsWriteSegmentFun)(nsIInputStream *aInStream,
  41. void *aClosure,
  42. const char *aFromSegment,
  43. PRUint32 aToOffset,
  44. PRUint32 aCount,
  45. PRUint32 *aWriteCount);
  46. /* starting interface: nsIInputStream */
  47. #define NS_IINPUTSTREAM_IID_STR "fa9c7f6c-61b3-11d4-9877-00c04fa0cf4a"
  48. #define NS_IINPUTSTREAM_IID \
  49. {0xfa9c7f6c, 0x61b3, 0x11d4, \
  50. { 0x98, 0x77, 0x00, 0xc0, 0x4f, 0xa0, 0xcf, 0x4a }}
  51. class NS_NO_VTABLE NS_SCRIPTABLE nsIInputStream : public nsISupports {
  52. public:
  53. NS_DECLARE_STATIC_IID_ACCESSOR(NS_IINPUTSTREAM_IID)
  54. /**
  55. * nsIInputStream
  56. *
  57. * An interface describing a readable stream of data. An input stream may be
  58. * "blocking" or "non-blocking" (see the IsNonBlocking method). A blocking
  59. * input stream may suspend the calling thread in order to satisfy a call to
  60. * Close, Available, Read, or ReadSegments. A non-blocking input stream, on
  61. * the other hand, must not block the calling thread of execution.
  62. *
  63. * NOTE: blocking input streams are often read on a background thread to avoid
  64. * locking up the main application thread. For this reason, it is generally
  65. * the case that a blocking input stream should be implemented using thread-
  66. * safe AddRef and Release.
  67. *
  68. * @status FROZEN
  69. */
  70. /**
  71. * Close the stream. This method causes subsequent calls to Read and
  72. * ReadSegments to return 0 bytes read to indicate end-of-file. Any
  73. * subsequent calls to Available should throw NS_BASE_STREAM_CLOSED.
  74. */
  75. /* void close (); */
  76. NS_SCRIPTABLE NS_IMETHOD Close(void) = 0;
  77. /**
  78. * Determine number of bytes available in the stream. A non-blocking
  79. * stream that does not yet have any data to read should return 0 bytes
  80. * from this method (i.e., it must not throw the NS_BASE_STREAM_WOULD_BLOCK
  81. * exception).
  82. *
  83. * In addition to the number of bytes available in the stream, this method
  84. * also informs the caller of the current status of the stream. A stream
  85. * that is closed will throw an exception when this method is called. That
  86. * enables the caller to know the condition of the stream before attempting
  87. * to read from it. If a stream is at end-of-file, but not closed, then
  88. * this method should return 0 bytes available.
  89. *
  90. * @return number of bytes currently available in the stream, or
  91. * PR_UINT32_MAX if the size of the stream exceeds PR_UINT32_MAX.
  92. *
  93. * @throws NS_BASE_STREAM_CLOSED if the stream is closed normally or at
  94. * end-of-file
  95. * @throws <other-error> if the stream is closed due to some error
  96. * condition
  97. */
  98. /* unsigned long available (); */
  99. NS_SCRIPTABLE NS_IMETHOD Available(PRUint32 *_retval) = 0;
  100. /**
  101. * Read data from the stream.
  102. *
  103. * @param aBuf the buffer into which the data is to be read
  104. * @param aCount the maximum number of bytes to be read
  105. *
  106. * @return number of bytes read (may be less than aCount).
  107. * @return 0 if reached end-of-file
  108. *
  109. * @throws NS_BASE_STREAM_WOULD_BLOCK if reading from the input stream would
  110. * block the calling thread (non-blocking mode only)
  111. * @throws <other-error> on failure
  112. *
  113. * NOTE: this method should not throw NS_BASE_STREAM_CLOSED.
  114. */
  115. /* [noscript] unsigned long read (in charPtr aBuf, in unsigned long aCount); */
  116. NS_IMETHOD Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval) = 0;
  117. /**
  118. * Low-level read method that provides access to the stream's underlying
  119. * buffer. The writer function may be called multiple times for segmented
  120. * buffers. ReadSegments is expected to keep calling the writer until
  121. * either there is nothing left to read or the writer returns an error.
  122. * ReadSegments should not call the writer with zero bytes to consume.
  123. *
  124. * @param aWriter the "consumer" of the data to be read
  125. * @param aClosure opaque parameter passed to writer
  126. * @param aCount the maximum number of bytes to be read
  127. *
  128. * @return number of bytes read (may be less than aCount)
  129. * @return 0 if reached end-of-file (or if aWriter refused to consume data)
  130. *
  131. * @throws NS_BASE_STREAM_WOULD_BLOCK if reading from the input stream would
  132. * block the calling thread (non-blocking mode only)
  133. * @throws NS_ERROR_NOT_IMPLEMENTED if the stream has no underlying buffer
  134. * @throws <other-error> on failure
  135. *
  136. * NOTE: this function may be unimplemented if a stream has no underlying
  137. * buffer (e.g., socket input stream).
  138. *
  139. * NOTE: this method should not throw NS_BASE_STREAM_CLOSED.
  140. */
  141. /* [noscript] unsigned long readSegments (in nsWriteSegmentFun aWriter, in voidPtr aClosure, in unsigned long aCount); */
  142. NS_IMETHOD ReadSegments(nsWriteSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval) = 0;
  143. /**
  144. * @return true if stream is non-blocking
  145. *
  146. * NOTE: reading from a blocking input stream will block the calling thread
  147. * until at least one byte of data can be extracted from the stream.
  148. *
  149. * NOTE: a non-blocking input stream may implement nsIAsyncInputStream to
  150. * provide consumers with a way to wait for the stream to have more data
  151. * once its read method is unable to return any data without blocking.
  152. */
  153. /* boolean isNonBlocking (); */
  154. NS_SCRIPTABLE NS_IMETHOD IsNonBlocking(PRBool *_retval) = 0;
  155. };
  156. NS_DEFINE_STATIC_IID_ACCESSOR(nsIInputStream, NS_IINPUTSTREAM_IID)
  157. /* Use this macro when declaring classes that implement this interface. */
  158. #define NS_DECL_NSIINPUTSTREAM \
  159. NS_SCRIPTABLE NS_IMETHOD Close(void); \
  160. NS_SCRIPTABLE NS_IMETHOD Available(PRUint32 *_retval); \
  161. NS_IMETHOD Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval); \
  162. NS_IMETHOD ReadSegments(nsWriteSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval); \
  163. NS_SCRIPTABLE NS_IMETHOD IsNonBlocking(PRBool *_retval);
  164. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  165. #define NS_FORWARD_NSIINPUTSTREAM(_to) \
  166. NS_SCRIPTABLE NS_IMETHOD Close(void) { return _to Close(); } \
  167. NS_SCRIPTABLE NS_IMETHOD Available(PRUint32 *_retval) { return _to Available(_retval); } \
  168. NS_IMETHOD Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval) { return _to Read(aBuf, aCount, _retval); } \
  169. NS_IMETHOD ReadSegments(nsWriteSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval) { return _to ReadSegments(aWriter, aClosure, aCount, _retval); } \
  170. NS_SCRIPTABLE NS_IMETHOD IsNonBlocking(PRBool *_retval) { return _to IsNonBlocking(_retval); }
  171. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  172. #define NS_FORWARD_SAFE_NSIINPUTSTREAM(_to) \
  173. NS_SCRIPTABLE NS_IMETHOD Close(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Close(); } \
  174. NS_SCRIPTABLE NS_IMETHOD Available(PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Available(_retval); } \
  175. NS_IMETHOD Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Read(aBuf, aCount, _retval); } \
  176. NS_IMETHOD ReadSegments(nsWriteSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->ReadSegments(aWriter, aClosure, aCount, _retval); } \
  177. NS_SCRIPTABLE NS_IMETHOD IsNonBlocking(PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->IsNonBlocking(_retval); }
  178. #if 0
  179. /* Use the code below as a template for the implementation class for this interface. */
  180. /* Header file */
  181. class nsInputStream : public nsIInputStream
  182. {
  183. public:
  184. NS_DECL_ISUPPORTS
  185. NS_DECL_NSIINPUTSTREAM
  186. nsInputStream();
  187. private:
  188. ~nsInputStream();
  189. protected:
  190. /* additional members */
  191. };
  192. /* Implementation file */
  193. NS_IMPL_ISUPPORTS1(nsInputStream, nsIInputStream)
  194. nsInputStream::nsInputStream()
  195. {
  196. /* member initializers and constructor code */
  197. }
  198. nsInputStream::~nsInputStream()
  199. {
  200. /* destructor code */
  201. }
  202. /* void close (); */
  203. NS_IMETHODIMP nsInputStream::Close()
  204. {
  205. return NS_ERROR_NOT_IMPLEMENTED;
  206. }
  207. /* unsigned long available (); */
  208. NS_IMETHODIMP nsInputStream::Available(PRUint32 *_retval)
  209. {
  210. return NS_ERROR_NOT_IMPLEMENTED;
  211. }
  212. /* [noscript] unsigned long read (in charPtr aBuf, in unsigned long aCount); */
  213. NS_IMETHODIMP nsInputStream::Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval)
  214. {
  215. return NS_ERROR_NOT_IMPLEMENTED;
  216. }
  217. /* [noscript] unsigned long readSegments (in nsWriteSegmentFun aWriter, in voidPtr aClosure, in unsigned long aCount); */
  218. NS_IMETHODIMP nsInputStream::ReadSegments(nsWriteSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval)
  219. {
  220. return NS_ERROR_NOT_IMPLEMENTED;
  221. }
  222. /* boolean isNonBlocking (); */
  223. NS_IMETHODIMP nsInputStream::IsNonBlocking(PRBool *_retval)
  224. {
  225. return NS_ERROR_NOT_IMPLEMENTED;
  226. }
  227. /* End of implementation class template. */
  228. #endif
  229. #endif /* __gen_nsIInputStream_h__ */