00001 /* 00002 * IOAccessor.h 00003 * 00004 * Smalltalk like class library for C++ 00005 * Abstract accessor to I/O resource. Header. 00006 * 00007 * Copyright (c) 2003 Milan Cermak 00008 */ 00009 /* 00010 * This library is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU Lesser General Public 00012 * License as published by the Free Software Foundation; either 00013 * version 2.1 of the License, or (at your option) any later version. 00014 * 00015 * This library is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public 00021 * License along with this library; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 */ 00024 #ifndef __IOACCESSOR_H 00025 #define __IOACCESSOR_H 00026 00027 #include <stlib/Object.h> 00028 #include <stlib/LineEndConvention.h> 00029 00030 namespace Core { 00031 00032 class ByteArray; 00033 class ExternalEncodedStreamFactory; 00034 class ExternalReadStream; 00035 class ExternalReadAppendStream; 00036 class ExternalWriteStream; 00037 class String; 00038 00039 class IOAccessor : public Object 00040 { 00041 public: 00042 /* Class-accessing protocol */ 00043 virtual String *className(void) const; 00044 00045 /* Initialize-release protocol */ 00046 virtual void close(void) abstract; 00047 00048 /* Accessing protocol */ 00049 virtual long bufferSize(void); 00050 virtual void commit(void); 00051 virtual long dataSize(void); 00052 virtual LineEndConvention lineEndConvention(void); 00053 00054 /* Data transfer protocol */ 00055 virtual int readInto(ByteArray *buffer); 00056 virtual int readInto(ByteArray *buffer, long startIndex, long count) abstract; 00057 00058 virtual int writeFrom(ByteArray *buffer); 00059 virtual int writeFrom(ByteArray *buffer, long startIndex, long count) abstract; 00060 00061 virtual int writeForSureFrom(ByteArray *buffer, long startIndex, long count); 00062 00063 /* Positioning protocol */ 00064 virtual void seekTo(long position) abstract; 00065 00066 /* Synchronization protocol */ 00067 virtual void readWait(void); 00068 virtual void writeWait(void); 00069 00070 /* Stream creation protocol */ 00071 virtual ExternalReadStream *readStream(void); 00072 virtual ExternalReadAppendStream *readAppendStream(void); 00073 virtual ExternalWriteStream *writeStream(void); 00074 virtual ExternalEncodedStreamFactory *withEncoding(String *encoding); 00075 virtual ExternalEncodedStreamFactory *withEncoding(const char *encoding); 00076 00077 /* Stream redirection protocol */ 00082 virtual void changeDescriptorTo(int fd); 00083 00084 /* Testing protocol */ 00085 virtual bool isSeekable(void); 00086 }; 00087 00088 }; 00089 00090 #endif /* __IOACCESSOR_H */