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