// $Revision: 1.3 $ // Copyright (C)1995 Taligent,Inc. All rights reserved. #ifndef TaligentSamples_MIMEDATASTREAM #include "MIMEDataStream.h" #endif #ifndef Taligent_UTFTRANSCODER #include #endif MCollectibleDefinitionsMacro(TMIMEDataStream, kOriginalVersion); TMIMEDataStream::TMIMEDataStream() : TForeignData(), fDataStream(NIL), fDataType() { } TMIMEDataStream::TMIMEDataStream(const TMIMEDataStream& source) : TForeignData(source), fDataStream(NIL), fDataType(source.fDataType) { fDataStream = ::CopyPointer(source.fDataStream); } TMIMEDataStream::TMIMEDataStream(TChunkyStream* adoptStream, const TMIMEForeignDataType& type) : TForeignData(), fDataStream(adoptStream), fDataType(type) { } TMIMEDataStream::~TMIMEDataStream() { delete fDataStream; } TMIMEDataStream& TMIMEDataStream::operator=(const TMIMEDataStream& source) { if (&source != this) { TForeignData::operator=(source); fDataType = source.fDataType; delete fDataStream; fDataStream = ::CopyPointer(source.fDataStream); } return *this; } TStream& TMIMEDataStream::operator>>=(TStream& toStream) const { ::WriteVersion(toStream); TForeignData::operator>>=(toStream); fDataType >>= toStream; ::Flatten(fDataStream, toStream); return toStream; } TStream& TMIMEDataStream::operator<<=(TStream& fromStream) { ::ReadVersion(fromStream, kOriginalVersion, kOriginalVersion); TForeignData::operator<<=(fromStream); fDataType <<= fromStream; delete fDataStream; fDataStream = 0; ::Resurrect(fDataStream, fromStream); return fromStream; } const TForeignDataType* TMIMEDataStream::GetDataType() const { return &fDataType; } TRandomAccessStream* TMIMEDataStream::CreateStreamForReading(TMemoryHeap* heap) const { return ::CopyPointer(fDataStream, TAllocationHeap(heap)); } TRandomAccessStream* TMIMEDataStream::CreateStreamForWriting(unsigned long initialSize, TMemoryHeap* heap) { return ::CopyPointer(fDataStream, TAllocationHeap(heap)); } TTranscoder* TMIMEDataStream::CreateDefaultTranscoder(TMemoryHeap* heap) const { return new (TAllocationHeap(heap)) TUTF8Transcoder; }