Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

WriteStream.cc

Go to the documentation of this file.
00001 /*
00002  * WriteStream.cc
00003  *
00004  * Smalltalk like class library for C++
00005  * Internal write stream.
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 #include <stlib/WriteStream.h>
00025 #include <stlib/SequenceableCollection.h>
00026 #include <stlib/String.h>
00027 
00028 WriteStream::WriteStream(SequenceableCollection *collection)
00029   : InternalStream(collection)
00030 {
00031     /* Does nothing */
00032 }
00033 
00034 /* Class-accessing protocol */
00035 String *WriteStream::className(void) const
00036 {
00037     return new String("WriteStream");
00038 }
00039 
00040 /* Accessing protocol */
00041 SequenceableCollection *WriteStream::contents(void)
00042 {
00043     read_limit = (read_limit < _position) ? _position : read_limit;
00044     return dynamic_cast<SequenceableCollection *>(collection->copy(0, _position));
00045 }
00046 
00047 void WriteStream::flush(void)
00048 {
00049     /* Does nothing */
00050 }
00051 
00052 Object *WriteStream::next(void)
00053 {
00054     shouldNotImplement(new String(__PRETTY_FUNCTION__));
00055     return nil;
00056 }
00057 
00058 void WriteStream::nextPut(Object *object)
00059 {
00060     if (_position == write_limit)
00061         pastEndPut(object);
00062     else
00063         collection->put(_position++, object);
00064 }
00065 
00066 /* Testing protocol */
00067 bool WriteStream::isReadable(void)
00068 {
00069     return false;
00070 }
00071 
00072 bool WriteStream::isWritable(void)
00073 {
00074     return true;
00075 }

Generated on Mon Nov 27 09:47:56 2006 for Smalltalk like C++ Class Library by  doxygen 1.4.2