1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements.  See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership.  The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License.  You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied.  See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23#ifndef __com_sun_star_io_XInputStream_idl__
24#define __com_sun_star_io_XInputStream_idl__
25
26#ifndef __com_sun_star_uno_XInterface_idl__
27#include <com/sun/star/uno/XInterface.idl>
28#endif
29
30#ifndef __com_sun_star_io_NotConnectedException_idl__
31#include <com/sun/star/io/NotConnectedException.idl>
32#endif
33
34#ifndef __com_sun_star_io_BufferSizeExceededException_idl__
35#include <com/sun/star/io/BufferSizeExceededException.idl>
36#endif
37
38
39//=============================================================================
40
41module com {  module sun {  module star {  module io {
42
43//=============================================================================
44
45// DocMerge from xml: interface com::sun::star::io::XInputStream
46/** This is the basic interface to read data from a stream.
47    <p>
48    See the <a href="http://udk.openoffice.org/common/man/concept/streams.html">
49    streaming document</a> for further information on chaining and piping streams.
50 */
51published interface XInputStream: com::sun::star::uno::XInterface
52{
53	//-------------------------------------------------------------------------
54
55	// DocMerge from xml: method com::sun::star::io::XInputStream::readBytes
56	/** reads the specified number of bytes in the given sequence.
57
58		<p>The return value specifies the number of bytes which have been
59		put into the sequence. A difference between <var>nBytesToRead</var>
60		and the return value indicates that EOF has been reached. This means
61		that the method blocks until the specified number of bytes are
62		available or the EOF is reached.  </p>
63	   @param aData
64	         after the call, the byte sequence contains the requested number
65			 of bytes (or less as a sign of EOF).
66
67			 <p>
68			 C++ only : Note that for unbridged (e.g., in-process)
69			 calls, using the same sequence for repetive readBytes()-calls
70			 can bear a performance advantage. The callee can put the data
71			 directly into the sequence so that no buffer reallocation is
72			 necessary.
73			 But this holds only when
74			 <ol>
75			  <li> neither caller nor callee keep a second reference to the same
76			       sequence.
77			  <li> the sequence is pre-allocated with the requested number of bytes.
78			  <li> the same sequence is reused ( simply preallocationg a new
79			       sequence for every call bears no advantage ).
80			  <li> the call is not bridged (e.g., betweeen different compilers
81			       or different processes ).
82			 </ol>
83
84			 If the same 'optimized' code runs against an interface in a different process,
85			 there is an unnecessary memory allocation/deallocation (the out parameter
86			 is of course NOT transported over the connection), but this should
87			 be negligible compared to a synchron call.
88	     @param nBytesToRead
89		the total number of bytes to read
90	 */
91	long readBytes( [out] sequence<byte> aData,
92			 [in] long nBytesToRead )
93			raises( com::sun::star::io::NotConnectedException,
94					com::sun::star::io::BufferSizeExceededException,
95					com::sun::star::io::IOException);
96
97	//-------------------------------------------------------------------------
98
99	// DocMerge from xml: method com::sun::star::io::XInputStream::readSomeBytes
100	/** reads the available number of bytes, at maximum
101		<var>nMaxBytesToRead</var>.
102
103		<p>This method is very similar to the readBytes method, except that
104           it has different blocking behaviour.
105           The method blocks as long as at least 1 byte is available or
106           EOF has been reached. EOF has only been reached, when the method
107           returns 0 and the corresponding byte sequence is empty.
108           Otherwise, after the call, aData contains the available,
109           but no more than nMaxBytesToRead, bytes.
110        @param aData contains the data read from the stream.
111        @param nMaxBytesToRead The maximum number of bytes to be read from this
112                               stream during the call.
113        @see com::sun::star::io::XInputStream::readBytes
114	 */
115	long readSomeBytes( [out] sequence<byte> aData,
116			 [in] long nMaxBytesToRead )
117			raises( com::sun::star::io::NotConnectedException,
118					com::sun::star::io::BufferSizeExceededException,
119					com::sun::star::io::IOException );
120
121	//-------------------------------------------------------------------------
122
123	// DocMerge from xml: method com::sun::star::io::XInputStream::skipBytes
124	/** skips the next <var>nBytesToSkip</var> bytes (must be positive).
125
126		<p>It is up to the implementation whether this method is
127		blocking the thread or not.  </p>
128	  @param nBytesToSkip
129		number of bytes to skip
130	 */
131	void skipBytes( [in] long nBytesToSkip )
132			raises( com::sun::star::io::NotConnectedException,
133					com::sun::star::io::BufferSizeExceededException,
134					com::sun::star::io::IOException );
135
136	//-------------------------------------------------------------------------
137
138	// DocMerge from xml: method com::sun::star::io::XInputStream::available
139	/** states how many bytes can be read or skipped without blocking.
140
141		<p>Note: This method offers no information on whether the EOF
142		has been reached.  </p>
143	 */
144	long available()
145			raises( com::sun::star::io::NotConnectedException,
146					com::sun::star::io::IOException
147					);
148
149	//-------------------------------------------------------------------------
150
151	// DocMerge from xml: method com::sun::star::io::XInputStream::closeInput
152	/** closes the stream.
153
154		<p>Users must close the stream explicitly when no further
155		reading should be done. (There may exist ring references to
156		chained objects that can only be released during this call.
157		Thus not calling this method would result in a leak of memory or
158		external resources.) </p>
159	 */
160	void closeInput()
161			raises( com::sun::star::io::NotConnectedException,
162					com::sun::star::io::IOException);
163
164};
165
166//=============================================================================
167
168}; }; }; };
169
170/*=============================================================================
171
172=============================================================================*/
173#endif
174