00001 /*
00002 *
00003 * NOTE: "zlib/libpng" style License
00004 *
00005 * ----=== s t d n e t ===----
00006 *
00007 * Copyright (c) 2002 Warwick Molloy w-molloy@users.sf.net
00008 *
00009 * Copyright (c) 2002 Stdnet Community
00010 * HTTP://Sourceforge.net/projects/stdnet
00011 *
00012 * All references to "software" refer to the stdnet.
00013 *
00014 * This software is provided 'as-is', without any express or
00015 * implied warranty. In no event will the authors be held liable
00016 * for any damages arising from the use of this software.
00017 *
00018 * Permission is granted to anyone to use this software for any
00019 * purpose, including commercial applications, and to alter it
00020 * and redistribute it freely, subject to the following
00021 * restrictions:
00022 *
00023 * 1. The origin of this software must not be misrepresented;
00024 * you must not claim that you wrote the original software.
00025 * If you use this software in a product, an acknowledgment
00026 * in the product documentation would be appreciated but
00027 * is not required.
00028 *
00029 * 2. Altered source versions must be plainly marked as such,
00030 * and must not be misrepresented as being the original
00031 * software.
00032 *
00033 * 3. This notice may not be removed or altered from any source
00034 * distribution.
00035 */
00036
00037 #include <stdnet/config.h>
00038 #include <stdnet/io/FilterInputStream>
00039
00040 namespace stdbase {
00041 namespace io {
00042
00043 /*
00044 * Get the number of bytes that can be read or skipped before
00045 * the next read would block.
00046 */
00047 int FilterInputStream::
00048 available() throw (IOException)
00049 {
00050 return input_stream->available();
00051 }
00052
00053 /*
00054 * Closes the stream and releases any resources.
00055 */
00056 void FilterInputStream::
00057 close() throw (IOException)
00058 {
00059 input_stream->close();
00060 }
00061
00062 /*
00063 * Marks the current position in the input stream incase
00064 * the caller need return to this point - done by calling
00065 * reset().
00066 *
00067 * @param readlimit the maximum limit of bytes before the
00068 * marked position becomes invalid.
00069 */
00070 void FilterInputStream::
00071 mark( int readlimit)
00072 {
00073 input_stream-> mark( readlimit );
00074 }
00075
00076 /*
00077 * Returns the caller to a previously marked position in
00078 * the input stream (if supported).
00079 *
00080 * @throws IOException if mark/reset not supported or if the
00081 * number of bytes read exceeds the mark readlimit when mark()
00082 * was called.
00083 */
00084 void FilterInputStream::
00085 reset() throw (IOException)
00086 {
00087 input_stream->reset();
00088 }
00089
00090 /*
00091 * Test to see whether the FilterInputStream implementation supports
00092 * the mark()/reset() methods.
00093 */
00094 bool FilterInputStream::
00095 markSupported()
00096 {
00097 return input_stream->markSupported();
00098 }
00099
00100 /*
00101 * Read a buffer of bytes - NEEDS Array.
00102 */
00103 int FilterInputStream::
00104 read( byte buffer[], int len) throw (IOException)
00105 {
00106 return input_stream->read( buffer, len);
00107 }
00108
00109 /*
00110 * Read a single byte from the stream and return it as an
00111 * integer.
00112 *
00113 * @return the number of bytes read.
00114 */
00115 int FilterInputStream::
00116 read() throw (IOException)
00117 {
00118 return input_stream->read();
00119 }
00120
00121 /*
00122 * Skip the next n bytes from the input stream.
00123 *
00124 * @return the number of bytes skipped.
00125 */
00126 long FilterInputStream::
00127 skip( long n ) throw (IOException)
00128 {
00129 return input_stream->skip( n );
00130 }
00131
00135
00136 FilterInputStreamRef FilterInputStream::
00137 create( InputStreamRef r)
00138 {
00139 return FilterInputStreamRef( new FilterInputStream( r ) );
00140 }
00141
00145
00146 FilterInputStream::
00147 FilterInputStream( InputStreamRef input)
00148 : InputStream(),
00149 input_stream( input )
00150 {
00151 }
00152
00153
00154 FilterInputStream::
00155 ~FilterInputStream()
00156 { }
00157
00158 } // -- end io --
00159 } // -- end stdbase --
00160
1.2.9.1 written by Dimitri van Heesch,
© 1997-2001