Topic Path: Symbol Reference > Classes > TIdDecoder Class > TIdDecoder Methods > DecodeBegin Method
ContentsIndexHome
PreviousUpNext
TIdDecoder.DecodeBegin Method

Prepares the decoder for storing decoded values to a stream.

procedure DecodeBegin(
    ADestStream: TIdStream
); virtual;
Parameters 
Description 
ADestStream 
Stream containing encoded values. 

DecodeBegin is a procedure used to initialize the decoder for reading encoded values and storing the decoded results in the TIdStream instance speficified in ADestStream. 

DecodeBegin is normally called prior to calling the Decode method with arguments representing the encoded values to write to the stream in ADestStream. DecodeBegin assigns the TIdStream instance specified in ADestStream to the internal member variable allocated for the decoder. 

DecodeEnd is normally called after all required calls to the Decode method to signal that the decoding operation is complete. 

DecodeBegin, Decode, and DecodeEnd are all used in the implementation of the DecodeString method.

function TIdDecoder.DecodeString(const aIn: string): string;
var
  LStream: TIdMemoryStream;
begin
  LStream := TIdMemoryStream.Create;
  try
    DecodeBegin(LStream);
    try
      Decode(AIn);
      LStream.Position := 0;Result := ReadStringFromStream(LStream);
    finally
      DecodeEnd;
    end;
  finally
    Sys.FreeAndNil(LStream);
  end;
end;
Copyright © 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.