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

Core::LineEndConvertor Class Reference

#include <LineEndConvertor.h>

Inheritance diagram for Core::LineEndConvertor:

Inheritance graph
[legend]
Collaboration diagram for Core::LineEndConvertor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 LineEndConvertor (LineEndConvention convention, Stream *stream)
virtual Objectnext (void)
virtual SequenceableCollectionnext (long items)
virtual SequenceableCollectionnext (long items, SequenceableCollection *newColl, long index)
virtual void nextPut (Object *object)
virtual void nextPut (const char object)
virtual bool isBinary (void)
virtual void setLineEndCharacter (void)

Static Public Member Functions

static LineEndConvertorlineEndCROn (Stream *stream)
static LineEndConvertorlineEndLFOn (Stream *stream)
static LineEndConvertorlineEndCRLFOn (Stream *stream)

Protected Member Functions

virtual SequenceableCollectioncontentSpeciesFor (long items)

Protected Attributes

Characterline_end_character
LineEndConvention line_end_convention

Constructor & Destructor Documentation

Core::LineEndConvertor::LineEndConvertor LineEndConvention  convention,
Stream stream
 

Definition at line 8 of file LineEndConvertor.cc.

References line_end_convention, and setLineEndCharacter().

Referenced by lineEndCRLFOn(), lineEndCROn(), and lineEndLFOn().

00009   : StreamDecorator(stream)
00010 {
00011     line_end_convention = convention;
00012     setLineEndCharacter();
00013 }


Member Function Documentation

SequenceableCollection * Core::LineEndConvertor::contentSpeciesFor long  items  )  [protected, virtual]
 

Reimplemented from Core::StreamDecorator.

Definition at line 81 of file LineEndConvertor.cc.

00082 {
00083     return new String(items);
00084 }

bool Core::LineEndConvertor::isBinary void   )  [virtual]
 

Reimplemented from Core::Stream.

Definition at line 67 of file LineEndConvertor.cc.

00068 {
00069     return false;
00070 }

LineEndConvertor * Core::LineEndConvertor::lineEndCRLFOn Stream stream  )  [static]
 

Definition at line 26 of file LineEndConvertor.cc.

References LineEndConvertor(), and Core::LineEndCRLF.

00027 {
00028     return new LineEndConvertor(LineEndCRLF, stream);
00029 }

LineEndConvertor * Core::LineEndConvertor::lineEndCROn Stream stream  )  [static]
 

Definition at line 16 of file LineEndConvertor.cc.

References LineEndConvertor(), and Core::LineEndCR.

00017 {
00018     return new LineEndConvertor(LineEndCR, stream);
00019 }

LineEndConvertor * Core::LineEndConvertor::lineEndLFOn Stream stream  )  [static]
 

Definition at line 21 of file LineEndConvertor.cc.

References LineEndConvertor(), and Core::LineEndLF.

00022 {
00023     return new LineEndConvertor(LineEndLF, stream);
00024 }

virtual SequenceableCollection* Core::LineEndConvertor::next long  items,
SequenceableCollection newColl,
long  index
[inline, virtual]
 

Reimplemented from Core::Stream.

Definition at line 30 of file LineEndConvertor.h.

References Core::Stream::next().

00031       { return StreamDecorator::next(items, newColl, index); }

virtual SequenceableCollection* Core::LineEndConvertor::next long  items  )  [inline, virtual]
 

Reimplemented from Core::Stream.

Definition at line 28 of file LineEndConvertor.h.

References Core::Stream::next().

00029       { return StreamDecorator::next(items); }

Object * Core::LineEndConvertor::next void   )  [virtual]
 

Reimplemented from Core::Stream.

Definition at line 32 of file LineEndConvertor.cc.

References Core::Character::isEqual(), Core::Character::lf(), line_end_character, line_end_convention, Core::LineEndCR, Core::LineEndCRLF, Core::Stream::next(), nil, Core::Stream::skip(), and Core::StreamDecorator::underlying_stream.

00033 {
00034     Character *ch = dynamic_cast<Character *>(underlying_stream->next());
00035     if (line_end_character == nil || !line_end_character->isEqual(ch))
00036         return ch;
00037     if (line_end_convention == LineEndCR) return Character::lf();
00038     if (line_end_convention == LineEndCRLF) {
00039         ch = dynamic_cast<Character *>(underlying_stream->next());
00040         if (ch == nil) return Character::lf();
00041         if (!ch->isEqual(Character::lf())) underlying_stream->skip(-1);
00042     }
00043     return Character::lf();
00044 }

virtual void Core::LineEndConvertor::nextPut const char  object  )  [inline, virtual]
 

Reimplemented from Core::Stream.

Definition at line 33 of file LineEndConvertor.h.

References Core::Stream::nextPut().

00034       { StreamDecorator::nextPut(object); }

void Core::LineEndConvertor::nextPut Object object  )  [virtual]
 

Reimplemented from Core::Stream.

Definition at line 46 of file LineEndConvertor.cc.

References Core::Character::cr(), Core::Object::isEqual(), Core::Character::lf(), line_end_convention, Core::LineEndCR, Core::LineEndCRLF, Core::LineEndLF, Core::LineEndTransparent, Core::Stream::nextPut(), and Core::StreamDecorator::underlying_stream.

00047 {
00048     if (object->isEqual(Character::lf())) {
00049         switch (line_end_convention) {
00050         case LineEndCR :
00051             underlying_stream->nextPut(Character::cr());
00052             break;
00053         case LineEndCRLF :
00054             underlying_stream->nextPut(Character::cr());
00055             underlying_stream->nextPut(object);
00056             break;
00057         case LineEndLF :
00058         case LineEndTransparent :
00059             underlying_stream->nextPut(object);
00060             break;
00061         }
00062     } else
00063         underlying_stream->nextPut(object);
00064 }

void Core::LineEndConvertor::setLineEndCharacter void   )  [virtual]
 

Definition at line 73 of file LineEndConvertor.cc.

References Core::Character::cr(), line_end_character, line_end_convention, Core::LineEndCR, Core::LineEndCRLF, and nil.

Referenced by LineEndConvertor().


Member Data Documentation

Character* Core::LineEndConvertor::line_end_character [protected]
 

Definition at line 15 of file LineEndConvertor.h.

Referenced by next(), and setLineEndCharacter().

LineEndConvention Core::LineEndConvertor::line_end_convention [protected]
 

Definition at line 16 of file LineEndConvertor.h.

Referenced by LineEndConvertor(), next(), nextPut(), and setLineEndCharacter().


The documentation for this class was generated from the following files:
Generated on Mon Nov 27 09:51:42 2006 for Smalltalk like C++ Class Library by  doxygen 1.4.2