activemq-cpp-3.3.0

src/main/decaf/io/Reader.h

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef _DECAF_IO_READER_H
00018 #define _DECAF_IO_READER_H
00019 
00020 #include <string>
00021 #include <decaf/lang/Readable.h>
00022 #include <decaf/io/Closeable.h>
00023 #include <decaf/io/IOException.h>
00024 #include <decaf/io/InputStream.h>
00025 
00026 #include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
00027 #include <decaf/lang/exceptions/NullPointerException.h>
00028 
00029 namespace decaf{
00030 namespace io{
00031 
00032     /*
00033      * Abstract class for reading character streams. The only methods that a subclass
00034      * must implement are read( char*, size_t, size_t ) and close(). Most subclasses,
00035      * however, will override some of the methods defined here in order to provide
00036      * higher efficiency, additional functionality, or both.
00037      *
00038      * @since 1.0
00039      */
00040     class DECAF_API Reader : public virtual decaf::io::Closeable,
00041                              public virtual decaf::lang::Readable {
00042     private:
00043 
00044         Reader( const Reader& );
00045         Reader& operator= ( const Reader& );
00046 
00047     protected:
00048 
00049         Reader();
00050 
00051     public:
00052 
00053         virtual ~Reader();
00054 
00066         virtual void mark( int readAheadLimit );
00067 
00074         virtual bool markSupported() const {
00075             return false;
00076         }
00077 
00086         virtual bool ready() const;
00087 
00097         virtual void reset();
00098 
00110         virtual long long skip( long long count );
00111 
00123         virtual int read( std::vector<char>& buffer );
00124 
00140         virtual int read( char* buffer, int size );
00141 
00161         virtual int read( char* buffer, int size, int offset, int length );
00162 
00175         virtual int read();
00176 
00177         virtual int read( decaf::nio::CharBuffer* charBuffer );
00178 
00179     protected:
00180 
00188         virtual int doReadArrayBounded( char* buffer, int size, int offset, int length ) = 0;
00189 
00190     protected:
00191 
00196         virtual int doReadVector( std::vector<char>& buffer );
00197 
00202         virtual int doReadArray( char* buffer, int length );
00203 
00208         virtual int doReadChar();
00209 
00214         virtual int doReadCharBuffer( decaf::nio::CharBuffer* charBuffer );
00215 
00216     };
00217 
00218 }}
00219 
00220 #endif /*_DECAF_IO_READER_H*/