#include <Stream.h>
Inheritance diagram for Core::Stream:
Public Member Functions | |
virtual Stream * | basicStream (void) |
virtual SequenceableCollection * | contents (void) abstract |
Answer content of the receiver. | |
virtual void | flush (void) abstract |
virtual Object * | next (void) abstract |
virtual SequenceableCollection * | next (long items) |
virtual SequenceableCollection * | next (long items, SequenceableCollection *newColl, long index) |
virtual SequenceableCollection * | nextLine (void) |
virtual Integer * | nextBigEndianLong (void) |
virtual Integer * | nextBigEndianShort (void) |
virtual Integer * | nextLittleEndianLong (void) |
virtual Integer * | nextLittleEndianShort (void) |
virtual void | nextPut (Object *object) abstract |
virtual void | nextPut (const char object) |
virtual void | nextPutAll (const Collection *collection) |
virtual void | nextPutAll (const char *string) |
virtual void | nextPutAll (const SequenceableCollection *collection, long size, long startIndex) |
virtual void | nextPutBigEndianLong (Integer *number) |
virtual void | nextPutBigEndianLong (unsigned long int number) |
virtual void | nextPutBigEndianShort (Integer *number) |
virtual void | nextPutBigEndianShort (unsigned short int number) |
virtual void | nextPutLittleEndianLong (Integer *number) |
virtual void | nextPutLittleEndianLong (unsigned long int number) |
virtual void | nextPutLittleEndianShort (Integer *number) |
virtual void | nextPutLittleEndianShort (unsigned short int number) |
virtual SequenceableCollection * | upTo (Object *object) |
virtual SequenceableCollection * | upToAll (SequenceableCollection *sequence) |
virtual SequenceableCollection * | upToAny (Collection *collection) |
virtual SequenceableCollection * | upToEnd (void) |
Answer collection of all data on the stream from actual position. | |
virtual SequenceableCollection * | upToSeparator (void) |
virtual Object * | peek (void) |
virtual void | skipSeparators (void) |
virtual void | cr (void) |
virtual void | lf (void) |
virtual void | space (void) |
virtual void | tab (void) |
virtual void | positionOutOfBoundsError (String *selector, int position) |
virtual long | position (void) abstract |
virtual void | position (long position) abstract |
virtual void | reset (void) abstract |
virtual void | skip (long length) abstract |
virtual void | print (Object *object) |
virtual void | print (long number) |
virtual void | print (double number) |
virtual void | close (void) |
virtual void | commit (void) |
virtual bool | atEnd (void) abstract |
virtual bool | basicAtEnd (void) abstract |
virtual bool | isEmpty (void) abstract |
virtual bool | notEmpty (void) abstract |
virtual bool | isBinary (void) abstract |
virtual bool | isExternalStream (void) |
virtual bool | isReadable (void) abstract |
virtual bool | isWritable (void) abstract |
Protected Member Functions | |
virtual SequenceableCollection * | contentSpeciesFor (long items) |
|
Reimplemented in Core::ExternalStream, Core::ExternalWriteStream, Core::PositionableStream, and Core::StreamDecorator. Referenced by Core::StreamDecorator::atEnd(), Core::ByteCharacterEncoder::loadFrom(), peek(), Tools::ConfigurationReader::read(), skipSeparators(), upTo(), upToAll(), upToAny(), upToEnd(), and upToSeparator(). |
|
Reimplemented in Core::PositionableStream, and Core::StreamDecorator. Referenced by Core::StreamDecorator::basicAtEnd(). |
|
Reimplemented in Core::StreamDecorator. Definition at line 40 of file Stream.cc. Referenced by Core::StreamDecorator::basicStream(). 00041 { 00042 return this; 00043 }
|
|
Reimplemented in Core::ExternalReadAppendStream, Core::ExternalStream, Core::ReadAppendStream, Core::StreamDecorator, and Tools::LogWriter. Definition at line 348 of file Stream.cc. Referenced by Core::StreamDecorator::close(), Core::ReadAppendStream::close(), Tools::LogWriter::close(), Tools::Filename::contentOfEntireFile(), Core::ByteCharacterEncoder::loadFrom(), Tools::Daemon::loadProcessId(), Tools::ConfigurationReader::readConfiguration(), and Tools::Daemon::saveProcessId(). 00349 {
00350 /* Does nothing */
00351 }
|
|
Reimplemented in Core::ExternalReadAppendStream, Core::ExternalStream, Core::ReadAppendStream, Core::StreamDecorator, and Tools::LogWriter. Definition at line 353 of file Stream.cc. Referenced by Core::StreamDecorator::commit(), Core::ReadAppendStream::commit(), and Tools::LogWriter::commit(). 00354 {
00355 /* Does nothing */
00356 }
|
|
Answer content of the receiver. In many cases it doesn't matter if it is ReadStream or WriteStream because they don't do any conversion. I does matter on streams like EncodedStream where some conversion takes place. In that case contents() always answer collection of encoded data (for ex. as it would be written to the disk). To get all data decoded you can use upToEnd() method. Reimplemented in Core::ExternalStream, Core::InternalStream, Core::PositionableStream, Core::StreamDecorator, and Core::WriteStream. Referenced by Core::String::asCString(), Net::URL::asString(), Tools::CommandLineParser::collectShortOptions(), Tools::Filename::constructString(), Tools::Filename::contentOfEntireFile(), Core::StreamDecorator::contents(), Core::ExternalStream::contents(), Core::String::demangleMethodName(), Core::EncodedStreamFactory::normalizedEncoding(), Net::URL::pathString(), Core::Collection::printSeparatedBy(), upTo(), upToAll(), upToAny(), upToEnd(), and upToSeparator(). |
|
Reimplemented in Core::EncodedStream, Core::LineEndConvertor, Core::PositionableStream, Core::StreamDecorator, and Tools::LogWriter. Definition at line 365 of file Stream.cc. Referenced by next(), upTo(), upToAll(), upToAny(), upToEnd(), and upToSeparator(). 00366 { 00367 return new Array(items); 00368 }
|
|
Definition at line 301 of file Stream.cc. References Core::Character::cr(), and nextPut(). 00302 { 00303 nextPut(Character::cr()); 00304 }
|
|
|
Reimplemented in Core::EncodedStream, Core::ExternalStream, Core::LineEndConvertor, Core::PositionableStream, and Tools::LogWriter. |
|
Reimplemented in Core::PositionableStream, and Core::StreamDecorator. Referenced by Core::StreamDecorator::isEmpty(). |
|
Reimplemented in Core::ExternalStream, and Core::StreamDecorator. Definition at line 359 of file Stream.cc. Referenced by Core::StreamDecorator::isExternalStream(). 00360 { 00361 return false; 00362 }
|
|
Reimplemented in Core::ExternalReadStream, Core::ExternalWriteStream, Core::ReadStream, Core::StreamDecorator, and Core::WriteStream. Referenced by Core::StreamDecorator::isReadable(). |
|
Reimplemented in Core::ExternalReadAppendStream, Core::ExternalReadStream, Core::ExternalWriteStream, Core::ReadAppendStream, Core::ReadStream, Core::StreamDecorator, and Core::WriteStream. Referenced by Core::StreamDecorator::isWritable(). |
|
Definition at line 306 of file Stream.cc. References Core::Character::lf(), and nextPut(). Referenced by Core::GenericException::printStackOn(), Tools::Daemon::saveProcessId(), and Tools::LogWriter::writeLog(). 00307 { 00308 nextPut(Character::lf()); 00309 }
|
|
Reimplemented in Core::EncodedStream, Core::LineEndConvertor, and Core::PositionableStream. Definition at line 52 of file Stream.cc. References next(), and Core::SequenceableCollection::put(). 00053 { 00054 long stopIndex = index + items; 00055 00056 while (index < stopIndex) { 00057 newColl->put(index, next()); 00058 index++; 00059 } 00060 return newColl; 00061 }
|
|
Reimplemented in Core::EncodedStream, Core::ExternalReadStream, Core::LineEndConvertor, and Core::PositionableStream. Definition at line 45 of file Stream.cc. References contentSpeciesFor(), and next(). 00046 { 00047 SequenceableCollection *newCollection; 00048 newCollection = contentSpeciesFor(items); 00049 return next(items, newCollection, 0); 00050 }
|
|
|
Definition at line 68 of file Stream.cc. References Core::ByteArray::at(), next(), and Core::Integer::value(). 00069 { 00070 unsigned long number = 0; 00071 ByteArray *array = dynamic_cast<ByteArray *>(next(4)); 00072 00073 for (int i = 0; i < 4; i++) { 00074 number = (number << 8) + dynamic_cast<Integer *>(array->at(i))->asLong(); 00075 } 00076 00077 return Integer::value(number); 00078 }
|
|
Definition at line 80 of file Stream.cc. References Core::ByteArray::at(), next(), and Core::Integer::value(). 00081 { 00082 unsigned long number = 0; 00083 ByteArray *array = dynamic_cast<ByteArray *>(next(2)); 00084 00085 for (int i = 0; i < 2; i++) { 00086 number = (number << 8) + dynamic_cast<Integer *>(array->at(i))->asLong(); 00087 } 00088 00089 return Integer::value(number); 00090 }
|
|
Definition at line 63 of file Stream.cc. References Core::Character::lf(), and upTo(). Referenced by Core::ByteCharacterEncoder::loadFrom(), Tools::Daemon::loadProcessId(), Tools::HierarchicalConfigurationReader::parseLine(), and Tools::ConfigurationReader::readLine(). 00064 { 00065 return upTo(Character::lf()); 00066 }
|
|
Definition at line 92 of file Stream.cc. References Core::ByteArray::at(), next(), and Core::Integer::value(). 00093 { 00094 unsigned long number = 0; 00095 ByteArray *array = dynamic_cast<ByteArray *>(next(4)); 00096 00097 for (int i = 3; i >= 0; i--) { 00098 number = (number << 8) + dynamic_cast<Integer *>(array->at(i))->asLong(); 00099 } 00100 00101 return Integer::value(number); 00102 }
|
|
Definition at line 104 of file Stream.cc. References Core::ByteArray::at(), next(), and Core::Integer::value(). 00105 { 00106 unsigned long number = 0; 00107 ByteArray *array = dynamic_cast<ByteArray *>(next(2)); 00108 00109 for (int i = 1; i >= 0; i--) { 00110 number = (number << 8) + dynamic_cast<Integer *>(array->at(i))->asLong(); 00111 } 00112 00113 return Integer::value(number); 00114 }
|
|
Reimplemented in Core::EncodedStream, Core::ExternalReadAppendStream, Core::ExternalReadStream, Core::ExternalWriteStream, Core::LineEndConvertor, Core::ReadAppendStream, Tools::LogWriter, and Core::WriteStream. Definition at line 116 of file Stream.cc. References nextPut(), and Core::Character::value(). 00117 { 00118 nextPut(Character::value((unsigned char) object)); 00119 }
|
|
|
Reimplemented in Core::ExternalReadAppendStream, Core::InternalStream, and Core::ReadAppendStream. Definition at line 140 of file Stream.cc. References Core::SequenceableCollection::at(), and nextPut(). 00142 { 00143 for (long i = startIndex; i < startIndex + size; i++) { 00144 nextPut(collection->at(i)); 00145 } 00146 }
|
|
Reimplemented in Core::ExternalReadAppendStream, Core::InternalStream, and Core::ReadAppendStream. Definition at line 133 of file Stream.cc. References nextPut(). 00134 { 00135 for (const char *pstr = string; *pstr != 0; pstr++) { 00136 nextPut(*pstr); 00137 } 00138 }
|
|
|
Definition at line 153 of file Stream.cc. References nextPutAll(), Core::ByteArray::put(), and Core::Integer::value(). 00154 { 00155 unsigned long particle = number; 00156 ByteArray *ba = new ByteArray(4); 00157 for (int i = 3; i >= 0; i--) { 00158 ba->put(i, Integer::value(particle & 0xff)); 00159 particle = particle >> 8; 00160 } 00161 nextPutAll(ba); 00162 }
|
|
Definition at line 148 of file Stream.cc. 00149 { 00150 nextPutBigEndianLong(number->asUnsignedLong()); 00151 }
|
|
Definition at line 169 of file Stream.cc. References nextPutAll(), Core::ByteArray::put(), and Core::Integer::value(). 00170 { 00171 unsigned short particle = number; 00172 ByteArray *ba = new ByteArray(2); 00173 for (int i = 1; i >= 0; i--) { 00174 ba->put(i, Integer::value(particle & 0xff)); 00175 particle = particle >> 8; 00176 } 00177 nextPutAll(ba); 00178 }
|
|
Definition at line 164 of file Stream.cc. References Core::Number::asUnsignedLong(). 00165 { 00166 nextPutBigEndianShort((unsigned short) number->asUnsignedLong()); 00167 }
|
|
Definition at line 185 of file Stream.cc. References nextPutAll(), Core::ByteArray::put(), and Core::Integer::value(). 00186 { 00187 unsigned long particle = number; 00188 ByteArray *ba = new ByteArray(4); 00189 for (int i = 0; i < 4; i++) { 00190 ba->put(i, Integer::value(particle & 0xff)); 00191 particle = particle >> 8; 00192 } 00193 nextPutAll(ba); 00194 }
|
|
Definition at line 180 of file Stream.cc. References Core::Number::asUnsignedLong(). 00181 { 00182 nextPutLittleEndianLong(number->asUnsignedLong()); 00183 }
|
|
Definition at line 201 of file Stream.cc. References nextPutAll(), Core::ByteArray::put(), and Core::Integer::value(). 00202 { 00203 unsigned short particle = number; 00204 ByteArray *ba = new ByteArray(2); 00205 for (int i = 0; i < 2; i++) { 00206 ba->put(i, Integer::value(particle & 0xff)); 00207 particle = particle >> 8; 00208 } 00209 nextPutAll(ba); 00210 }
|
|
Definition at line 196 of file Stream.cc. References Core::Number::asUnsignedLong(). 00197 { 00198 nextPutLittleEndianShort((unsigned short) number->asUnsignedLong()); 00199 }
|
|
Reimplemented in Core::PositionableStream, and Core::StreamDecorator. Referenced by Core::StreamDecorator::notEmpty(). |
|
Definition at line 278 of file Stream.cc. References atEnd(), next(), nil, and skip(). 00279 { 00280 if (atEnd()) return nil; 00281 Object *element = next(); 00282 skip(-1); 00283 return element; 00284 }
|
|
Reimplemented in Core::ExternalReadAppendStream, Core::ExternalWriteStream, Core::PositionableStream, Core::ReadAppendStream, and Core::StreamDecorator. |
|
Reimplemented in Core::ExternalWriteStream, Core::PositionableStream, and Core::StreamDecorator. Referenced by Core::StreamDecorator::position(). |
|
Definition at line 322 of file Stream.cc. Referenced by Core::PositionableStream::position(). 00323 { 00324 (new PositionOutOfBoundsError(selector, position))->raiseFrom(this); 00325 }
|
|
Definition at line 342 of file Stream.cc. References Core::String::format(), and nextPutAll(). 00343 { 00344 nextPutAll(String::format("%g", number)); 00345 }
|
|
Definition at line 337 of file Stream.cc. References Core::String::format(), and nextPutAll(). 00338 { 00339 nextPutAll(String::format("%d", number)); 00340 }
|
|
Definition at line 328 of file Stream.cc. References nextPutAll(), and nil. Referenced by Tools::Application::initialize(), Net::URL::printContentOn(), Net::IPSocketAddress::printOn(), Tools::Filename::printOn(), Tools::Configuration::printOn(), Core::Association::printOn(), Tools::Daemon::saveProcessId(), and Tools::LogWriter::writeLog(). 00329 { 00330 if (object == nil) { 00331 nextPutAll("<nil>"); 00332 return; 00333 } 00334 object->printOn(this); 00335 }
|
|
Reimplemented in Core::PositionableStream, and Core::StreamDecorator. Referenced by Core::StreamDecorator::reset(). |
|
Reimplemented in Core::ExternalReadStream, Core::PositionableStream, and Core::StreamDecorator. Referenced by Core::LineEndConvertor::next(), peek(), Core::StreamDecorator::skip(), and skipSeparators(). |
|
Definition at line 287 of file Stream.cc. References atEnd(), Core::Object::isCharacter(), next(), and skip(). Referenced by Tools::ConfigurationReader::read(). 00288 { 00289 Object *element; 00290 bool atEndFlag; 00291 00292 while (!(atEndFlag = atEnd()) && 00293 (element = next())->isCharacter() && 00294 ((Character *) element)->isSeparator()); 00295 /* Cannot use atEnd() here because of ExternalReadStream 00296 buffer swap side effect */ 00297 if (!atEndFlag) skip(-1); 00298 }
|
|
Definition at line 311 of file Stream.cc. References nextPut(), and Core::Character::space(). Referenced by Core::Timestamp::printOn(), and Core::Collection::printOn(). 00312 { 00313 nextPut(Character::space()); 00314 }
|
|
Definition at line 316 of file Stream.cc. References nextPut(), and Core::Character::tab(). 00317 { 00318 nextPut(Character::tab()); 00319 }
|
|
Definition at line 212 of file Stream.cc. References atEnd(), contents(), contentSpeciesFor(), Core::Object::isEqual(), next(), and nextPut(). Referenced by Tools::Filename::components(), and nextLine(). 00213 { 00214 Stream *newStream = contentSpeciesFor(64)->writeStream(); 00215 while (!atEnd()) { 00216 Object *element = next(); 00217 if (element->isEqual(object)) 00218 break; 00219 newStream->nextPut(element); 00220 } 00221 return newStream->contents(); 00222 }
|
|
Definition at line 224 of file Stream.cc. References atEnd(), contents(), contentSpeciesFor(), Core::Object::isEqual(), next(), nextPut(), and nextPutAll(). 00225 { 00226 int matchCount = 0; 00227 Stream *writeStream = contentSpeciesFor(64)->writeStream(); 00228 while (!atEnd()) { 00229 Object *element = next(); 00230 if (element->isEqual(sequence->at(matchCount))) { 00231 matchCount++; 00232 if (matchCount == sequence->size()) break; 00233 } else { 00234 if (matchCount > 0) { 00235 writeStream->nextPutAll(dynamic_cast<SequenceableCollection *>(sequence->copy(0, matchCount))); 00236 matchCount = 0; 00237 } 00238 writeStream->nextPut(element); 00239 } 00240 } 00241 return writeStream->contents(); 00242 }
|
|
Definition at line 244 of file Stream.cc. References atEnd(), contents(), contentSpeciesFor(), next(), and nextPut(). 00245 { 00246 Stream *newStream = contentSpeciesFor(64)->writeStream(); 00247 while (!atEnd()) { 00248 Object *element = next(); 00249 if (collection->includes(element)) 00250 break; 00251 newStream->nextPut(element); 00252 } 00253 return newStream->contents(); 00254 }
|
|
Answer collection of all data on the stream from actual position. In many cases this is just the same thing as contents(). But in cases of EncodedStream or so you'll get decoded data. Reimplemented in Core::InternalStream. Definition at line 256 of file Stream.cc. References atEnd(), contents(), contentSpeciesFor(), next(), and nextPut(). 00257 { 00258 Stream *newCollectionStream = contentSpeciesFor(256)->writeStream(); 00259 while (!atEnd()) { 00260 newCollectionStream->nextPut(next()); 00261 } 00262 return newCollectionStream->contents(); 00263 }
|
|
Definition at line 265 of file Stream.cc. References atEnd(), contents(), contentSpeciesFor(), Core::Object::isCharacter(), next(), and nextPut(). 00266 { 00267 Stream *newStream = contentSpeciesFor(64)->writeStream(); 00268 while (!atEnd()) { 00269 Object *element = next(); 00270 if (element->isCharacter() && 00271 ((Character *) element)->isSeparator()) 00272 break; 00273 newStream->nextPut(element); 00274 } 00275 return newStream->contents(); 00276 }
|