TIdEncoder
Abstract ancestor for Indy encoder classes.
Unit
Description
TIdEncoder is a
TIdBaseComponent descendant that is the abstract ancestor for all Indy classes that perform encoding operations on String- or Stream-based origins and return the encoded value as a String value. Descendants of TIdEncoder include
TIdEncoder3to4 and
TIdEncoderQuotedPrintable.
Applications do not normally create instances of TIdEncoder, and instead use one of the descendant classes that implements a specific encoding algorithm. TIdEncoder can be used an as ancestor for classes that utilize a unique encoding algorithm and also adhere to the Indy coder framework.
Provides encoding for String- or Stream-based input values.
function Encode(const ASrc: string): string; overload;
function Encode(ASrcStream: TStream; const ABytes: integer = MaxInt): string; virtual; abstract; overload;
Parameters
const ASrc: string
String value to be encoded.
ASrcStream: TStream
Stream-based values to be encoded.
const ABytes: integer = MaxInt
Number of bytes in the input stream to be encoded. Default value is MaxInt.
Return Value
String - Encoded value for the input parameter(s).
Description
Encode is an overloaded String function in
TIdEncoder that allows String- or Stream-based input values to be encoded. The encoded value of the input parameter is the return value for the function.
ASrc contains the un-encoded valued to be used by the function. In the Stream-based variant, ASrcStream contains the un-encoded input values. ABytes represents the number of bytes in ASrcStream to be affected by the encoding operation. When ommitted, ABytes defaults to the constant value MaxInt, and allows the function to read up to MaxInt byte values or until the end of the Stream is reached.
The Stream-based variant of Encode is a virtual function in TIdEncoder, and allows descendant classes to reimplement the function using specific encoding algorithms.
Encode is called by the class function EncodeString, when no application instance of TIdEncoder is required or available.
Provides encoding for String- or Stream-based input values.
function Encode(const ASrc: string): string; overload;
function Encode(ASrcStream: TStream; const ABytes: integer = MaxInt): string; virtual; abstract; overload;
Parameters
const ASrc: string
String value to be encoded.
ASrcStream: TStream
Stream-based values to be encoded.
const ABytes: integer = MaxInt
Number of bytes in the input stream to be encoded. Default value is MaxInt.
Return Value
String - Encoded value for the input parameter(s).
Description
Encode is an overloaded String function in
TIdEncoder that allows String- or Stream-based input values to be encoded. The encoded value of the input parameter is the return value for the function.
ASrc contains the un-encoded valued to be used by the function. In the Stream-based variant, ASrcStream contains the un-encoded input values. ABytes represents the number of bytes in ASrcStream to be affected by the encoding operation. When ommitted, ABytes defaults to the constant value MaxInt, and allows the function to read up to MaxInt byte values or until the end of the Stream is reached.
The Stream-based variant of Encode is a virtual function in TIdEncoder, and allows descendant classes to reimplement the function using specific encoding algorithms.
Encode is called by the class function EncodeString, when no application instance of TIdEncoder is required or available.
Class function for encoding a String value.
class function EncodeString(const AIn: string): string;
Parameters
const AIn: string
Input value to be encoded.
Return Value
String - Encoded value of the input parameter.
Description
EncodeString is a Class function in
TIdEncoder that provides encoding of the value in AIn using a temporary instance of
TIdEncoder. EncodeString calls
Encode using the transient instance to get the return value. The temporary
TIdEncoder instance is freed before exiting from the EncodeString method.
Applications can use EncodeString when an instance of TIdEncoder is neither needed nor available in the application.