nsIInputStream.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. * DO NOT EDIT. THIS FILE IS GENERATED FROM c:/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
  21. * @param aToOffset amount already read (since ReadSegments was called)
  22. * @param aCount length of fromSegment
  23. * @param aWriteCount number of bytes read
  24. *
  25. * Implementers should return the following:
  26. *
  27. * @return NS_OK and (*aWriteCount > 0) if consumed some data
  28. * @return <any-error> if not interested in consuming any data
  29. *
  30. * Errors are never passed to the caller of ReadSegments.
  31. *
  32. * NOTE: returning NS_OK and (*aWriteCount = 0) has undefined behavior.
  33. *
  34. * @status FROZEN
  35. */
  36. typedef NS_CALLBACK(nsWriteSegmentFun)(nsIInputStream *aInStream,
  37. void *aClosure,
  38. const char *aFromSegment,
  39. PRUint32 aToOffset,
  40. PRUint32 aCount,
  41. PRUint32 *aWriteCount);
  42. /* starting interface: nsIInputStream */
  43. #define NS_IINPUTSTREAM_IID_STR "fa9c7f6c-61b3-11d4-9877-00c04fa0cf4a"
  44. #define NS_IINPUTSTREAM_IID \
  45. {0xfa9c7f6c, 0x61b3, 0x11d4, \
  46. { 0x98, 0x77, 0x00, 0xc0, 0x4f, 0xa0, 0xcf, 0x4a }}
  47. class NS_NO_VTABLE nsIInputStream : public nsISupports {
  48. public:
  49. NS_DEFINE_STATIC_IID_ACCESSOR(NS_IINPUTSTREAM_IID)
  50. /**
  51. * nsIInputStream
  52. *
  53. * @status FROZEN
  54. */
  55. /**
  56. * Close the stream.
  57. */
  58. /* void close (); */
  59. NS_IMETHOD Close(void) = 0;
  60. /**
  61. * @return number of bytes currently available in the stream
  62. */
  63. /* unsigned long available (); */
  64. NS_IMETHOD Available(PRUint32 *_retval) = 0;
  65. /**
  66. * Read data from the stream.
  67. *
  68. * @param aBuf the buffer into which the data is to be read
  69. * @param aCount the maximum number of bytes to be read
  70. *
  71. * @return number of bytes read (may be less than aCount).
  72. * @return 0 if reached end of file
  73. *
  74. * @throws NS_BASE_STREAM_WOULD_BLOCK if reading from the input stream would
  75. * block the calling thread (non-blocking mode only)
  76. * @throws <other-error> on failure
  77. */
  78. /* [noscript] unsigned long read (in charPtr aBuf, in unsigned long aCount); */
  79. NS_IMETHOD Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval) = 0;
  80. /**
  81. * Low-level read method that has access to the stream's underlying buffer.
  82. * The writer function may be called multiple times for segmented buffers.
  83. * ReadSegments is expected to keep calling the writer until either there is
  84. * nothing left to read or the writer returns an error. ReadSegments should
  85. * not call the writer with zero bytes to consume.
  86. *
  87. * @param aWriter the "consumer" of the data to be read
  88. * @param aClosure opaque parameter passed to writer
  89. * @param aCount the maximum number of bytes to be read
  90. *
  91. * @return number of bytes read (may be less than aCount)
  92. * @return 0 if reached end of file (or if aWriter refused to consume data)
  93. *
  94. * @throws NS_BASE_STREAM_WOULD_BLOCK if reading from the input stream would
  95. * block the calling thread (non-blocking mode only)
  96. * @throws <other-error> on failure
  97. *
  98. * NOTE: this function may be unimplemented if a stream has no underlying
  99. * buffer (e.g., socket input stream).
  100. */
  101. /* [noscript] unsigned long readSegments (in nsWriteSegmentFun aWriter, in voidPtr aClosure, in unsigned long aCount); */
  102. NS_IMETHOD ReadSegments(nsWriteSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval) = 0;
  103. /**
  104. * @return true if stream is non-blocking
  105. */
  106. /* boolean isNonBlocking (); */
  107. NS_IMETHOD IsNonBlocking(PRBool *_retval) = 0;
  108. };
  109. /* Use this macro when declaring classes that implement this interface. */
  110. #define NS_DECL_NSIINPUTSTREAM \
  111. NS_IMETHOD Close(void); \
  112. NS_IMETHOD Available(PRUint32 *_retval); \
  113. NS_IMETHOD Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval); \
  114. NS_IMETHOD ReadSegments(nsWriteSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval); \
  115. NS_IMETHOD IsNonBlocking(PRBool *_retval);
  116. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  117. #define NS_FORWARD_NSIINPUTSTREAM(_to) \
  118. NS_IMETHOD Close(void) { return _to Close(); } \
  119. NS_IMETHOD Available(PRUint32 *_retval) { return _to Available(_retval); } \
  120. NS_IMETHOD Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval) { return _to Read(aBuf, aCount, _retval); } \
  121. NS_IMETHOD ReadSegments(nsWriteSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval) { return _to ReadSegments(aWriter, aClosure, aCount, _retval); } \
  122. NS_IMETHOD IsNonBlocking(PRBool *_retval) { return _to IsNonBlocking(_retval); }
  123. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  124. #define NS_FORWARD_SAFE_NSIINPUTSTREAM(_to) \
  125. NS_IMETHOD Close(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Close(); } \
  126. NS_IMETHOD Available(PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Available(_retval); } \
  127. NS_IMETHOD Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Read(aBuf, aCount, _retval); } \
  128. NS_IMETHOD ReadSegments(nsWriteSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->ReadSegments(aWriter, aClosure, aCount, _retval); } \
  129. NS_IMETHOD IsNonBlocking(PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->IsNonBlocking(_retval); }
  130. #if 0
  131. /* Use the code below as a template for the implementation class for this interface. */
  132. /* Header file */
  133. class nsInputStream : public nsIInputStream
  134. {
  135. public:
  136. NS_DECL_ISUPPORTS
  137. NS_DECL_NSIINPUTSTREAM
  138. nsInputStream();
  139. private:
  140. ~nsInputStream();
  141. protected:
  142. /* additional members */
  143. };
  144. /* Implementation file */
  145. NS_IMPL_ISUPPORTS1(nsInputStream, nsIInputStream)
  146. nsInputStream::nsInputStream()
  147. {
  148. /* member initializers and constructor code */
  149. }
  150. nsInputStream::~nsInputStream()
  151. {
  152. /* destructor code */
  153. }
  154. /* void close (); */
  155. NS_IMETHODIMP nsInputStream::Close()
  156. {
  157. return NS_ERROR_NOT_IMPLEMENTED;
  158. }
  159. /* unsigned long available (); */
  160. NS_IMETHODIMP nsInputStream::Available(PRUint32 *_retval)
  161. {
  162. return NS_ERROR_NOT_IMPLEMENTED;
  163. }
  164. /* [noscript] unsigned long read (in charPtr aBuf, in unsigned long aCount); */
  165. NS_IMETHODIMP nsInputStream::Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval)
  166. {
  167. return NS_ERROR_NOT_IMPLEMENTED;
  168. }
  169. /* [noscript] unsigned long readSegments (in nsWriteSegmentFun aWriter, in voidPtr aClosure, in unsigned long aCount); */
  170. NS_IMETHODIMP nsInputStream::ReadSegments(nsWriteSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval)
  171. {
  172. return NS_ERROR_NOT_IMPLEMENTED;
  173. }
  174. /* boolean isNonBlocking (); */
  175. NS_IMETHODIMP nsInputStream::IsNonBlocking(PRBool *_retval)
  176. {
  177. return NS_ERROR_NOT_IMPLEMENTED;
  178. }
  179. /* End of implementation class template. */
  180. #endif
  181. #endif /* __gen_nsIInputStream_h__ */