00001 /* 00002 * ReadAppendStream.cc 00003 * 00004 * Smalltalk like class library for C++ 00005 * Internal read and append stream. 00006 * 00007 * Copyright (c) 2006 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 #include "stlib/ReadAppendStream.h" 00025 00026 #include "stlib/Character.h" 00027 #include "stlib/String.h" 00028 #include "stlib/WriteStream.h" 00029 00030 namespace Core { 00031 00032 ReadAppendStream::ReadAppendStream(SequenceableCollection *collection) 00033 : ReadStream(collection) 00034 { 00035 writeStream = new WriteStream(collection); 00036 } 00037 00038 /* Class-accessing protocol */ 00039 String *ReadAppendStream::className(void) const 00040 { 00041 return new String("ReadAppendStream"); 00042 } 00043 00044 /* Accessing protocol */ 00045 void ReadAppendStream::commit(void) 00046 { 00047 writeStream->commit(); 00048 } 00049 00050 void ReadAppendStream::flush(void) 00051 { 00052 writeStream->flush(); 00053 } 00054 00055 void ReadAppendStream::nextPut(Object *object) 00056 { 00057 writeStream->nextPut(object); 00058 read_limit = writeStream->position(); 00059 } 00060 00061 void ReadAppendStream::nextPut(const char object) 00062 { 00063 nextPut(Character::value(object)); 00064 } 00065 00066 void ReadAppendStream::nextPutAll(const Collection *collection) 00067 { 00068 writeStream->nextPutAll(collection); 00069 read_limit = writeStream->position(); 00070 } 00071 00072 void ReadAppendStream::nextPutAll(const char *string) 00073 { 00074 nextPutAll(new String(string)); 00075 } 00076 00077 void ReadAppendStream::nextPutAll(const SequenceableCollection *collection, 00078 long size, long startIndex) 00079 { 00080 writeStream->nextPutAll(collection, size, startIndex); 00081 read_limit = writeStream->position(); 00082 } 00083 00084 /* Positioning protocol */ 00085 void ReadAppendStream::position(long position) 00086 { 00087 writeStream->position(position); 00088 ReadStream::position(position); 00089 } 00090 00091 long ReadAppendStream::writePosition(void) 00092 { 00093 return writeStream->position(); 00094 } 00095 00096 /* Status protocol */ 00097 void ReadAppendStream::close(void) 00098 { 00099 writeStream->close(); 00100 ReadStream::close(); 00101 } 00102 00103 /* Testing protocol */ 00104 bool ReadAppendStream::isWritable(void) 00105 { 00106 return true; 00107 } 00108 00109 }; /* namespace Core */