PageRenderTime 164ms CodeModel.GetById 81ms app.highlight 6ms RepoModel.GetById 74ms 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
  5#ifndef __gen_nsIOutputStream_h__
  6#define __gen_nsIOutputStream_h__
  7
  8
  9#ifndef __gen_nsISupports_h__
 10#include "nsISupports.h"
 11#endif
 12
 13/* For IDL files that don't want to include root IDL files. */
 14#ifndef NS_NO_VTABLE
 15#define NS_NO_VTABLE
 16#endif
 17class nsIOutputStream; /* forward declaration */
 18
 19class nsIInputStream; /* forward declaration */
 20
 21/**
 22 * The signature for the reader function passed to WriteSegments. This 
 23 * is the "provider" of data that gets written into the stream's buffer.
 24 *
 25 * @param aOutStream stream being written to
 26 * @param aClosure opaque parameter passed to WriteSegments
 27 * @param aToSegment pointer to memory owned by the output stream
 28 * @param aFromOffset amount already written (since WriteSegments was called)
 29 * @param aCount length of toSegment
 30 * @param aReadCount number of bytes written
 31 *
 32 * Implementers should return the following:
 33 *
 34 * @return NS_OK and (*aReadCount > 0) if successfully provided some data
 35 * @return NS_OK and (*aReadCount = 0) or
 36 * @return <any-error> if not interested in providing any data
 37 *
 38 * Errors are never passed to the caller of WriteSegments.
 39 *
 40 * @status FROZEN
 41 */
 42typedef NS_CALLBACK(nsReadSegmentFun)(nsIOutputStream *aOutStream,
 43                                      void *aClosure,
 44                                      char *aToSegment,
 45                                      PRUint32 aFromOffset,
 46                                      PRUint32 aCount,
 47                                      PRUint32 *aReadCount);
 48
 49/* starting interface:    nsIOutputStream */
 50#define NS_IOUTPUTSTREAM_IID_STR "0d0acd2a-61b4-11d4-9877-00c04fa0cf4a"
 51
 52#define NS_IOUTPUTSTREAM_IID \
 53  {0x0d0acd2a, 0x61b4, 0x11d4, \
 54    { 0x98, 0x77, 0x00, 0xc0, 0x4f, 0xa0, 0xcf, 0x4a }}
 55
 56class NS_NO_VTABLE NS_SCRIPTABLE nsIOutputStream : public nsISupports {
 57 public: 
 58
 59  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IOUTPUTSTREAM_IID)
 60
 61  /**
 62 * nsIOutputStream
 63 *
 64 * An interface describing a writable stream of data.  An output stream may be
 65 * "blocking" or "non-blocking" (see the IsNonBlocking method).  A blocking
 66 * output stream may suspend the calling thread in order to satisfy a call to
 67 * Close, Flush, Write, WriteFrom, or WriteSegments.  A non-blocking output
 68 * stream, on the other hand, must not block the calling thread of execution.
 69 *
 70 * NOTE: blocking output streams are often written to on a background thread to
 71 * avoid locking up the main application thread.  For this reason, it is
 72 * generally the case that a blocking output stream should be implemented using
 73 * thread- safe AddRef and Release.
 74 *
 75 * @status FROZEN
 76 */
 77/** 
 78     * Close the stream. Forces the output stream to flush any buffered data.
 79     *
 80     * @throws NS_BASE_STREAM_WOULD_BLOCK if unable to flush without blocking 
 81     *   the calling thread (non-blocking mode only)
 82     */
 83  /* void close (); */
 84  NS_SCRIPTABLE NS_IMETHOD Close(void) = 0;
 85
 86  /**
 87     * Flush the stream.
 88     *
 89     * @throws NS_BASE_STREAM_WOULD_BLOCK if unable to flush without blocking 
 90     *   the calling thread (non-blocking mode only)
 91     */
 92  /* void flush (); */
 93  NS_SCRIPTABLE NS_IMETHOD Flush(void) = 0;
 94
 95  /**
 96     * Write data into the stream.
 97     *
 98     * @param aBuf the buffer containing the data to be written
 99     * @param aCount the maximum number of bytes to be written
100     *
101     * @return number of bytes written (may be less than aCount)
102     *
103     * @throws NS_BASE_STREAM_WOULD_BLOCK if writing to the output stream would
104     *   block the calling thread (non-blocking mode only)
105     * @throws <other-error> on failure
106     */
107  /* unsigned long write (in string aBuf, in unsigned long aCount); */
108  NS_SCRIPTABLE NS_IMETHOD Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval) = 0;
109
110  /**
111     * Writes data into the stream from an input stream.
112     *
113     * @param aFromStream the stream containing the data to be written
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 method is defined by this interface in order to allow the
123     * output stream to efficiently copy the data from the input stream into
124     * its internal buffer (if any). If this method was provided as an external
125     * facility, a separate char* buffer would need to be used in order to call
126     * the output stream's other Write method.
127     */
128  /* unsigned long writeFrom (in nsIInputStream aFromStream, in unsigned long aCount); */
129  NS_SCRIPTABLE NS_IMETHOD WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval) = 0;
130
131  /**
132     * Low-level write method that has access to the stream's underlying buffer.
133     * The reader function may be called multiple times for segmented buffers.
134     * WriteSegments is expected to keep calling the reader until either there
135     * is nothing left to write or the reader returns an error.  WriteSegments
136     * should not call the reader with zero bytes to provide.
137     *
138     * @param aReader the "provider" of the data to be written
139     * @param aClosure opaque parameter passed to reader
140     * @param aCount the maximum number of bytes to be written
141     *
142     * @return number of bytes written (may be less than aCount)
143     *
144     * @throws NS_BASE_STREAM_WOULD_BLOCK if writing to the output stream would
145     *    block the calling thread (non-blocking mode only)
146     * @throws NS_ERROR_NOT_IMPLEMENTED if the stream has no underlying buffer
147     * @throws <other-error> on failure
148     *
149     * NOTE: this function may be unimplemented if a stream has no underlying
150     * buffer (e.g., socket output stream).
151     */
152  /* [noscript] unsigned long writeSegments (in nsReadSegmentFun aReader, in voidPtr aClosure, in unsigned long aCount); */
153  NS_IMETHOD WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval) = 0;
154
155  /**
156     * @return true if stream is non-blocking
157     *
158     * NOTE: writing to a blocking output stream will block the calling thread
159     * until all given data can be consumed by the stream.
160     *
161     * NOTE: a non-blocking output stream may implement nsIAsyncOutputStream to
162     * provide consumers with a way to wait for the stream to accept more data
163     * once its write method is unable to accept any data without blocking.
164     */
165  /* boolean isNonBlocking (); */
166  NS_SCRIPTABLE NS_IMETHOD IsNonBlocking(PRBool *_retval) = 0;
167
168};
169
170  NS_DEFINE_STATIC_IID_ACCESSOR(nsIOutputStream, NS_IOUTPUTSTREAM_IID)
171
172/* Use this macro when declaring classes that implement this interface. */
173#define NS_DECL_NSIOUTPUTSTREAM \
174  NS_SCRIPTABLE NS_IMETHOD Close(void); \
175  NS_SCRIPTABLE NS_IMETHOD Flush(void); \
176  NS_SCRIPTABLE NS_IMETHOD Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval); \
177  NS_SCRIPTABLE NS_IMETHOD WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval); \
178  NS_IMETHOD WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval); \
179  NS_SCRIPTABLE NS_IMETHOD IsNonBlocking(PRBool *_retval); 
180
181/* Use this macro to declare functions that forward the behavior of this interface to another object. */
182#define NS_FORWARD_NSIOUTPUTSTREAM(_to) \
183  NS_SCRIPTABLE NS_IMETHOD Close(void) { return _to Close(); } \
184  NS_SCRIPTABLE NS_IMETHOD Flush(void) { return _to Flush(); } \
185  NS_SCRIPTABLE NS_IMETHOD Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval) { return _to Write(aBuf, aCount, _retval); } \
186  NS_SCRIPTABLE NS_IMETHOD WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval) { return _to WriteFrom(aFromStream, aCount, _retval); } \
187  NS_IMETHOD WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval) { return _to WriteSegments(aReader, aClosure, aCount, _retval); } \
188  NS_SCRIPTABLE NS_IMETHOD IsNonBlocking(PRBool *_retval) { return _to IsNonBlocking(_retval); } 
189
190/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
191#define NS_FORWARD_SAFE_NSIOUTPUTSTREAM(_to) \
192  NS_SCRIPTABLE NS_IMETHOD Close(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Close(); } \
193  NS_SCRIPTABLE NS_IMETHOD Flush(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Flush(); } \
194  NS_SCRIPTABLE NS_IMETHOD Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Write(aBuf, aCount, _retval); } \
195  NS_SCRIPTABLE NS_IMETHOD WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteFrom(aFromStream, aCount, _retval); } \
196  NS_IMETHOD WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteSegments(aReader, aClosure, aCount, _retval); } \
197  NS_SCRIPTABLE NS_IMETHOD IsNonBlocking(PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->IsNonBlocking(_retval); } 
198
199#if 0
200/* Use the code below as a template for the implementation class for this interface. */
201
202/* Header file */
203class nsOutputStream : public nsIOutputStream
204{
205public:
206  NS_DECL_ISUPPORTS
207  NS_DECL_NSIOUTPUTSTREAM
208
209  nsOutputStream();
210
211private:
212  ~nsOutputStream();
213
214protected:
215  /* additional members */
216};
217
218/* Implementation file */
219NS_IMPL_ISUPPORTS1(nsOutputStream, nsIOutputStream)
220
221nsOutputStream::nsOutputStream()
222{
223  /* member initializers and constructor code */
224}
225
226nsOutputStream::~nsOutputStream()
227{
228  /* destructor code */
229}
230
231/* void close (); */
232NS_IMETHODIMP nsOutputStream::Close()
233{
234    return NS_ERROR_NOT_IMPLEMENTED;
235}
236
237/* void flush (); */
238NS_IMETHODIMP nsOutputStream::Flush()
239{
240    return NS_ERROR_NOT_IMPLEMENTED;
241}
242
243/* unsigned long write (in string aBuf, in unsigned long aCount); */
244NS_IMETHODIMP nsOutputStream::Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval)
245{
246    return NS_ERROR_NOT_IMPLEMENTED;
247}
248
249/* unsigned long writeFrom (in nsIInputStream aFromStream, in unsigned long aCount); */
250NS_IMETHODIMP nsOutputStream::WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval)
251{
252    return NS_ERROR_NOT_IMPLEMENTED;
253}
254
255/* [noscript] unsigned long writeSegments (in nsReadSegmentFun aReader, in voidPtr aClosure, in unsigned long aCount); */
256NS_IMETHODIMP nsOutputStream::WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval)
257{
258    return NS_ERROR_NOT_IMPLEMENTED;
259}
260
261/* boolean isNonBlocking (); */
262NS_IMETHODIMP nsOutputStream::IsNonBlocking(PRBool *_retval)
263{
264    return NS_ERROR_NOT_IMPLEMENTED;
265}
266
267/* End of implementation class template. */
268#endif
269
270
271#endif /* __gen_nsIOutputStream_h__ */