PageRenderTime 45ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/gecko_api/include/nsIOutputStream.h

http://firefox-mac-pdf.googlecode.com/
C Header | 271 lines | 96 code | 38 blank | 137 comment | 0 complexity | b9bcdb4aacdedb54dee026e73f28d9b9 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/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 NS_SCRIPTABLE nsIOutputStream : public nsISupports {
  48. public:
  49. NS_DECLARE_STATIC_IID_ACCESSOR(NS_IOUTPUTSTREAM_IID)
  50. /**
  51. * nsIOutputStream
  52. *
  53. * An interface describing a writable stream of data. An output stream may be
  54. * "blocking" or "non-blocking" (see the IsNonBlocking method). A blocking
  55. * output stream may suspend the calling thread in order to satisfy a call to
  56. * Close, Flush, Write, WriteFrom, or WriteSegments. A non-blocking output
  57. * stream, on the other hand, must not block the calling thread of execution.
  58. *
  59. * NOTE: blocking output streams are often written to on a background thread to
  60. * avoid locking up the main application thread. For this reason, it is
  61. * generally the case that a blocking output stream should be implemented using
  62. * thread- safe AddRef and Release.
  63. *
  64. * @status FROZEN
  65. */
  66. /**
  67. * Close the stream. Forces the output stream to flush any buffered data.
  68. *
  69. * @throws NS_BASE_STREAM_WOULD_BLOCK if unable to flush without blocking
  70. * the calling thread (non-blocking mode only)
  71. */
  72. /* void close (); */
  73. NS_SCRIPTABLE NS_IMETHOD Close(void) = 0;
  74. /**
  75. * Flush the stream.
  76. *
  77. * @throws NS_BASE_STREAM_WOULD_BLOCK if unable to flush without blocking
  78. * the calling thread (non-blocking mode only)
  79. */
  80. /* void flush (); */
  81. NS_SCRIPTABLE NS_IMETHOD Flush(void) = 0;
  82. /**
  83. * Write data into the stream.
  84. *
  85. * @param aBuf the buffer containing the data to be written
  86. * @param aCount the maximum number of bytes to be written
  87. *
  88. * @return number of bytes written (may be less than aCount)
  89. *
  90. * @throws NS_BASE_STREAM_WOULD_BLOCK if writing to the output stream would
  91. * block the calling thread (non-blocking mode only)
  92. * @throws <other-error> on failure
  93. */
  94. /* unsigned long write (in string aBuf, in unsigned long aCount); */
  95. NS_SCRIPTABLE NS_IMETHOD Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval) = 0;
  96. /**
  97. * Writes data into the stream from an input stream.
  98. *
  99. * @param aFromStream the stream containing the data to be written
  100. * @param aCount the maximum number of bytes to be written
  101. *
  102. * @return number of bytes written (may be less than aCount)
  103. *
  104. * @throws NS_BASE_STREAM_WOULD_BLOCK if writing to the output stream would
  105. * block the calling thread (non-blocking mode only)
  106. * @throws <other-error> on failure
  107. *
  108. * NOTE: This method is defined by this interface in order to allow the
  109. * output stream to efficiently copy the data from the input stream into
  110. * its internal buffer (if any). If this method was provided as an external
  111. * facility, a separate char* buffer would need to be used in order to call
  112. * the output stream's other Write method.
  113. */
  114. /* unsigned long writeFrom (in nsIInputStream aFromStream, in unsigned long aCount); */
  115. NS_SCRIPTABLE NS_IMETHOD WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval) = 0;
  116. /**
  117. * Low-level write method that has access to the stream's underlying buffer.
  118. * The reader function may be called multiple times for segmented buffers.
  119. * WriteSegments is expected to keep calling the reader until either there
  120. * is nothing left to write or the reader returns an error. WriteSegments
  121. * should not call the reader with zero bytes to provide.
  122. *
  123. * @param aReader the "provider" of the data to be written
  124. * @param aClosure opaque parameter passed to reader
  125. * @param aCount the maximum number of bytes to be written
  126. *
  127. * @return number of bytes written (may be less than aCount)
  128. *
  129. * @throws NS_BASE_STREAM_WOULD_BLOCK if writing to the output stream would
  130. * block the calling thread (non-blocking mode only)
  131. * @throws NS_ERROR_NOT_IMPLEMENTED if the stream has no underlying buffer
  132. * @throws <other-error> on failure
  133. *
  134. * NOTE: this function may be unimplemented if a stream has no underlying
  135. * buffer (e.g., socket output stream).
  136. */
  137. /* [noscript] unsigned long writeSegments (in nsReadSegmentFun aReader, in voidPtr aClosure, in unsigned long aCount); */
  138. NS_IMETHOD WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval) = 0;
  139. /**
  140. * @return true if stream is non-blocking
  141. *
  142. * NOTE: writing to a blocking output stream will block the calling thread
  143. * until all given data can be consumed by the stream.
  144. *
  145. * NOTE: a non-blocking output stream may implement nsIAsyncOutputStream to
  146. * provide consumers with a way to wait for the stream to accept more data
  147. * once its write method is unable to accept any data without blocking.
  148. */
  149. /* boolean isNonBlocking (); */
  150. NS_SCRIPTABLE NS_IMETHOD IsNonBlocking(PRBool *_retval) = 0;
  151. };
  152. NS_DEFINE_STATIC_IID_ACCESSOR(nsIOutputStream, NS_IOUTPUTSTREAM_IID)
  153. /* Use this macro when declaring classes that implement this interface. */
  154. #define NS_DECL_NSIOUTPUTSTREAM \
  155. NS_SCRIPTABLE NS_IMETHOD Close(void); \
  156. NS_SCRIPTABLE NS_IMETHOD Flush(void); \
  157. NS_SCRIPTABLE NS_IMETHOD Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval); \
  158. NS_SCRIPTABLE NS_IMETHOD WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval); \
  159. NS_IMETHOD WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval); \
  160. NS_SCRIPTABLE NS_IMETHOD IsNonBlocking(PRBool *_retval);
  161. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  162. #define NS_FORWARD_NSIOUTPUTSTREAM(_to) \
  163. NS_SCRIPTABLE NS_IMETHOD Close(void) { return _to Close(); } \
  164. NS_SCRIPTABLE NS_IMETHOD Flush(void) { return _to Flush(); } \
  165. NS_SCRIPTABLE NS_IMETHOD Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval) { return _to Write(aBuf, aCount, _retval); } \
  166. NS_SCRIPTABLE NS_IMETHOD WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval) { return _to WriteFrom(aFromStream, aCount, _retval); } \
  167. NS_IMETHOD WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval) { return _to WriteSegments(aReader, aClosure, aCount, _retval); } \
  168. NS_SCRIPTABLE NS_IMETHOD IsNonBlocking(PRBool *_retval) { return _to IsNonBlocking(_retval); }
  169. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  170. #define NS_FORWARD_SAFE_NSIOUTPUTSTREAM(_to) \
  171. NS_SCRIPTABLE NS_IMETHOD Close(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Close(); } \
  172. NS_SCRIPTABLE NS_IMETHOD Flush(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Flush(); } \
  173. NS_SCRIPTABLE NS_IMETHOD Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Write(aBuf, aCount, _retval); } \
  174. NS_SCRIPTABLE NS_IMETHOD WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteFrom(aFromStream, aCount, _retval); } \
  175. NS_IMETHOD WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteSegments(aReader, aClosure, aCount, _retval); } \
  176. NS_SCRIPTABLE NS_IMETHOD IsNonBlocking(PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->IsNonBlocking(_retval); }
  177. #if 0
  178. /* Use the code below as a template for the implementation class for this interface. */
  179. /* Header file */
  180. class nsOutputStream : public nsIOutputStream
  181. {
  182. public:
  183. NS_DECL_ISUPPORTS
  184. NS_DECL_NSIOUTPUTSTREAM
  185. nsOutputStream();
  186. private:
  187. ~nsOutputStream();
  188. protected:
  189. /* additional members */
  190. };
  191. /* Implementation file */
  192. NS_IMPL_ISUPPORTS1(nsOutputStream, nsIOutputStream)
  193. nsOutputStream::nsOutputStream()
  194. {
  195. /* member initializers and constructor code */
  196. }
  197. nsOutputStream::~nsOutputStream()
  198. {
  199. /* destructor code */
  200. }
  201. /* void close (); */
  202. NS_IMETHODIMP nsOutputStream::Close()
  203. {
  204. return NS_ERROR_NOT_IMPLEMENTED;
  205. }
  206. /* void flush (); */
  207. NS_IMETHODIMP nsOutputStream::Flush()
  208. {
  209. return NS_ERROR_NOT_IMPLEMENTED;
  210. }
  211. /* unsigned long write (in string aBuf, in unsigned long aCount); */
  212. NS_IMETHODIMP nsOutputStream::Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval)
  213. {
  214. return NS_ERROR_NOT_IMPLEMENTED;
  215. }
  216. /* unsigned long writeFrom (in nsIInputStream aFromStream, in unsigned long aCount); */
  217. NS_IMETHODIMP nsOutputStream::WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval)
  218. {
  219. return NS_ERROR_NOT_IMPLEMENTED;
  220. }
  221. /* [noscript] unsigned long writeSegments (in nsReadSegmentFun aReader, in voidPtr aClosure, in unsigned long aCount); */
  222. NS_IMETHODIMP nsOutputStream::WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval)
  223. {
  224. return NS_ERROR_NOT_IMPLEMENTED;
  225. }
  226. /* boolean isNonBlocking (); */
  227. NS_IMETHODIMP nsOutputStream::IsNonBlocking(PRBool *_retval)
  228. {
  229. return NS_ERROR_NOT_IMPLEMENTED;
  230. }
  231. /* End of implementation class template. */
  232. #endif
  233. #endif /* __gen_nsIOutputStream_h__ */