Skip to content

TBase64EncodingStream

Base64 encoding stream.

Declaration

Source position: base64.pp line 41

type

  TBase64EncodingStream = class(TOwnerStream)
  public
    constructor Create(ASource: TStream); overload;
    constructor Create(ASource: TStream; ACharsPerLine: Integer; 
                  ALineSeparator: RawByteString; APadEnd: Boolean); overload;
    constructor Create(ASource: TStream; ACharsPerLine: Integer; 
                  ALineSeparator: UnicodeString; APadEnd: Boolean); overload;
    destructor Destroy;
    function Flush : Boolean;
    function Write : LongInt;
    function Seek : LongInt;
  end;

Description

TBase64EncodingStream can be used to encode data using the base64 algorithm. At creation time, a destination stream is specified. Any data written to the TBase64EncodingStream instance will be base64 encoded, and subsequently written to the destination stream.

The TBase64EncodingStream stream is a write-only stream. Obviously it is also not seekable. It is meant to be included in a chain of streams.

By the nature of base64 encoding, when a buffer is written to the stream, the output stream does not yet contain all output: input must be a multiple of 3. In order to be sure that the output contains all encoded bytes, the Flush method can be used. The destructor will automatically call Flush, so all data is written to the destination stream when the decodes is destroyed.

Methods

Member Visibility Description
Create public
Destroy public Remove a TBase64EncodingStream instance from memory.
Flush public Flush the remaining bytes to the output stream.
Seek public Position the stream.
Write public Write data to the stream.
See all Methods

See also

Name Description
TBase64DecodingStream Base64 Decoding stream.