nsIOutputStream.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /*
  2. * DO NOT EDIT. THIS FILE IS GENERATED FROM c:/mozilla/xpcom/io/nsIOutputStream.idl
  3. */
  4. #ifndef __gen_nsIOutputStream_h__
  5. #define __gen_nsIOutputStream_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 nsIOutputStream; /* forward declaration */
  14. class nsIInputStream; /* forward declaration */
  15. /**
  16. * The signature for the reader function passed to WriteSegments. This
  17. * is the "provider" of data that gets written into the stream's buffer.
  18. *
  19. * @param aOutStream stream being written to
  20. * @param aClosure opaque parameter passed to WriteSegments
  21. * @param aToSegment pointer to memory owned by the output stream
  22. * @param aFromOffset amount already written (since WriteSegments was called)
  23. * @param aCount length of toSegment
  24. * @param aReadCount number of bytes written
  25. *
  26. * Implementers should return the following:
  27. *
  28. * @return NS_OK and (*aReadCount > 0) if successfully provided some data
  29. * @return NS_OK and (*aReadCount = 0) or
  30. * @return <any-error> if not interested in providing any data
  31. *
  32. * Errors are never passed to the caller of WriteSegments.
  33. *
  34. * @status FROZEN
  35. */
  36. typedef NS_CALLBACK(nsReadSegmentFun)(nsIOutputStream *aOutStream,
  37. void *aClosure,
  38. char *aToSegment,
  39. PRUint32 aFromOffset,
  40. PRUint32 aCount,
  41. PRUint32 *aReadCount);
  42. /* starting interface: nsIOutputStream */
  43. #define NS_IOUTPUTSTREAM_IID_STR "0d0acd2a-61b4-11d4-9877-00c04fa0cf4a"
  44. #define NS_IOUTPUTSTREAM_IID \
  45. {0x0d0acd2a, 0x61b4, 0x11d4, \
  46. { 0x98, 0x77, 0x00, 0xc0, 0x4f, 0xa0, 0xcf, 0x4a }}
  47. class NS_NO_VTABLE nsIOutputStream : public nsISupports {
  48. public:
  49. NS_DEFINE_STATIC_IID_ACCESSOR(NS_IOUTPUTSTREAM_IID)
  50. /**
  51. * nsIOutputStream
  52. *
  53. * @status FROZEN
  54. */
  55. /**
  56. * Close the stream. Forces the output stream to flush any buffered data.
  57. *
  58. * @throws NS_BASE_STREAM_WOULD_BLOCK if unable to flush without blocking
  59. * the calling thread (non-blocking mode only)
  60. */
  61. /* void close (); */
  62. NS_IMETHOD Close(void) = 0;
  63. /**
  64. * Flush the stream.
  65. *
  66. * @throws NS_BASE_STREAM_WOULD_BLOCK if unable to flush without blocking
  67. * the calling thread (non-blocking mode only)
  68. */
  69. /* void flush (); */
  70. NS_IMETHOD Flush(void) = 0;
  71. /**
  72. * Write data into the stream.
  73. *
  74. * @param aBuf the buffer containing the data to be written
  75. * @param aCount the maximum number of bytes to be written
  76. *
  77. * @return number of bytes written (may be less than aCount)
  78. *
  79. * @throws NS_BASE_STREAM_WOULD_BLOCK if writing to the output stream would
  80. * block the calling thread (non-blocking mode only)
  81. * @throws <other-error> on failure
  82. */
  83. /* unsigned long write (in string aBuf, in unsigned long aCount); */
  84. NS_IMETHOD Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval) = 0;
  85. /**
  86. * Writes data into the stream from an input stream.
  87. *
  88. * @param aFromStream the stream containing the data to be written
  89. * @param aCount the maximum number of bytes to be written
  90. *
  91. * @return number of bytes written (may be less than aCount)
  92. *
  93. * @throws NS_BASE_STREAM_WOULD_BLOCK if writing to the output stream would
  94. * block the calling thread (non-blocking mode only)
  95. * @throws <other-error> on failure
  96. *
  97. * NOTE: This method is defined by this interface in order to allow the
  98. * output stream to efficiently copy the data from the input stream into
  99. * its internal buffer (if any). If this method was provided as an external
  100. * facility, a separate char* buffer would need to be used in order to call
  101. * the output stream's other Write method.
  102. */
  103. /* unsigned long writeFrom (in nsIInputStream aFromStream, in unsigned long aCount); */
  104. NS_IMETHOD WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval) = 0;
  105. /**
  106. * Low-level write method that has access to the stream's underlying buffer.
  107. * The reader function may be called multiple times for segmented buffers.
  108. * WriteSegments is expected to keep calling the reader until either there
  109. * is nothing left to write or the reader returns an error. WriteSegments
  110. * should not call the reader with zero bytes to provide.
  111. *
  112. * @param aReader the "provider" of the data to be written
  113. * @param aClosure opaque parameter passed to reader
  114. * @param aCount the maximum number of bytes to be written
  115. *
  116. * @return number of bytes written (may be less than aCount)
  117. *
  118. * @throws NS_BASE_STREAM_WOULD_BLOCK if writing to the output stream would
  119. * block the calling thread (non-blocking mode only)
  120. * @throws <other-error> on failure
  121. *
  122. * NOTE: this function may be unimplemented if a stream has no underlying
  123. * buffer (e.g., socket output stream).
  124. */
  125. /* [noscript] unsigned long writeSegments (in nsReadSegmentFun aReader, in voidPtr aClosure, in unsigned long aCount); */
  126. NS_IMETHOD WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval) = 0;
  127. /**
  128. * @return true if stream is non-blocking
  129. *
  130. * NOTE: writing to a blocking output stream will block the calling thread
  131. * until all given data can be consumed by the stream.
  132. */
  133. /* boolean isNonBlocking (); */
  134. NS_IMETHOD IsNonBlocking(PRBool *_retval) = 0;
  135. };
  136. /* Use this macro when declaring classes that implement this interface. */
  137. #define NS_DECL_NSIOUTPUTSTREAM \
  138. NS_IMETHOD Close(void); \
  139. NS_IMETHOD Flush(void); \
  140. NS_IMETHOD Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval); \
  141. NS_IMETHOD WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval); \
  142. NS_IMETHOD WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval); \
  143. NS_IMETHOD IsNonBlocking(PRBool *_retval);
  144. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  145. #define NS_FORWARD_NSIOUTPUTSTREAM(_to) \
  146. NS_IMETHOD Close(void) { return _to Close(); } \
  147. NS_IMETHOD Flush(void) { return _to Flush(); } \
  148. NS_IMETHOD Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval) { return _to Write(aBuf, aCount, _retval); } \
  149. NS_IMETHOD WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval) { return _to WriteFrom(aFromStream, aCount, _retval); } \
  150. NS_IMETHOD WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval) { return _to WriteSegments(aReader, aClosure, aCount, _retval); } \
  151. NS_IMETHOD IsNonBlocking(PRBool *_retval) { return _to IsNonBlocking(_retval); }
  152. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  153. #define NS_FORWARD_SAFE_NSIOUTPUTSTREAM(_to) \
  154. NS_IMETHOD Close(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Close(); } \
  155. NS_IMETHOD Flush(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Flush(); } \
  156. NS_IMETHOD Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Write(aBuf, aCount, _retval); } \
  157. NS_IMETHOD WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteFrom(aFromStream, aCount, _retval); } \
  158. NS_IMETHOD WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteSegments(aReader, aClosure, aCount, _retval); } \
  159. NS_IMETHOD IsNonBlocking(PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->IsNonBlocking(_retval); }
  160. #if 0
  161. /* Use the code below as a template for the implementation class for this interface. */
  162. /* Header file */
  163. class nsOutputStream : public nsIOutputStream
  164. {
  165. public:
  166. NS_DECL_ISUPPORTS
  167. NS_DECL_NSIOUTPUTSTREAM
  168. nsOutputStream();
  169. private:
  170. ~nsOutputStream();
  171. protected:
  172. /* additional members */
  173. };
  174. /* Implementation file */
  175. NS_IMPL_ISUPPORTS1(nsOutputStream, nsIOutputStream)
  176. nsOutputStream::nsOutputStream()
  177. {
  178. /* member initializers and constructor code */
  179. }
  180. nsOutputStream::~nsOutputStream()
  181. {
  182. /* destructor code */
  183. }
  184. /* void close (); */
  185. NS_IMETHODIMP nsOutputStream::Close()
  186. {
  187. return NS_ERROR_NOT_IMPLEMENTED;
  188. }
  189. /* void flush (); */
  190. NS_IMETHODIMP nsOutputStream::Flush()
  191. {
  192. return NS_ERROR_NOT_IMPLEMENTED;
  193. }
  194. /* unsigned long write (in string aBuf, in unsigned long aCount); */
  195. NS_IMETHODIMP nsOutputStream::Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval)
  196. {
  197. return NS_ERROR_NOT_IMPLEMENTED;
  198. }
  199. /* unsigned long writeFrom (in nsIInputStream aFromStream, in unsigned long aCount); */
  200. NS_IMETHODIMP nsOutputStream::WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval)
  201. {
  202. return NS_ERROR_NOT_IMPLEMENTED;
  203. }
  204. /* [noscript] unsigned long writeSegments (in nsReadSegmentFun aReader, in voidPtr aClosure, in unsigned long aCount); */
  205. NS_IMETHODIMP nsOutputStream::WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval)
  206. {
  207. return NS_ERROR_NOT_IMPLEMENTED;
  208. }
  209. /* boolean isNonBlocking (); */
  210. NS_IMETHODIMP nsOutputStream::IsNonBlocking(PRBool *_retval)
  211. {
  212. return NS_ERROR_NOT_IMPLEMENTED;
  213. }
  214. /* End of implementation class template. */
  215. #endif
  216. #endif /* __gen_nsIOutputStream_h__ */