Class TStreamHelper

DescriptionHierarchyInternal TypesFieldsMethodsProperties

Unit

Declaration

type TStreamHelper = class helper(TObject) for TStream

Description

Extensions to TStream class for reading and writing different values depending on platform. Although TStream in recent versions of FPC and Delphi introduced similar functions, this extension class provides a more comprehensive and unified set of functions that work across all platforms.

Hierarchy

  • TObject
  • TStreamHelper

Overview

Internal Types

Public TStreamByte = SizeUInt;
Public TStreamByteBool = Boolean;
Public TStreamByteIndex = SizeInt;
Public TStreamDouble = Double;
Public TStreamInt64 = Int64;
Public TStreamLongInt = SizeInt ;
Public TStreamLongWord = SizeUInt ;
Public TStreamShortInt = SizeInt;
Public TStreamSingle = Single;
Public TStreamSmallInt = SizeInt;
Public TStreamUInt64 = UInt64;
Public TStreamWord = SizeUInt;
Public TStreamWordIndex = SizeInt ;

Methods

Public function GetByte: TStreamByte; inline;
Public function GetByteBool: TStreamByteBool; inline;
Public function GetByteIndex: TStreamByteIndex; inline;
Public function GetBytePoint2px: TPoint2i;
Public function GetDouble: TStreamDouble; inline;
Public function GetFloat34: Single;
Public function GetFloat43: Single;
Public function GetInt64: TStreamInt64; inline;
Public function GetLongInt: TStreamLongInt; inline;
Public function GetLongPoint2px: TPoint2i;
Public function GetLongString: UniString;
Public function GetLongWord: TStreamLongWord; inline;
Public function GetMediumString: UniString;
Public function GetShortInt: TStreamShortInt; inline;
Public function GetShortString: UniString;
Public function GetSingle: TStreamSingle; inline;
Public function GetSmallInt: TStreamSmallInt; inline;
Public function GetUInt64: TStreamUInt64; inline;
Public function GetWord: TStreamWord; inline;
Public function GetWordIndex: TStreamWordIndex; inline;
Public function GetWordPoint2px: TPoint2i;
Public procedure GetFloats3311(out Value1, Value2: Single);
Public procedure GetFloats44(out Value1, Value2: Single);
Public procedure PutByte(const Value: TStreamByte); inline;
Public procedure PutByteBool(const Value: TStreamByteBool); inline;
Public procedure PutByteIndex(const Value: TStreamByteIndex); inline;
Public procedure PutBytePoint2px(const Value: TPoint2i);
Public procedure PutDouble(const Value: TStreamDouble); inline;
Public procedure PutFloat34(const Value: Single);
Public procedure PutFloat43(const Value: Single);
Public procedure PutFloats3311(const Value1, Value2: Single);
Public procedure PutFloats44(const Value1, Value2: Single);
Public procedure PutInt64(const Value: TStreamInt64); inline;
Public procedure PutLongInt(const Value: TStreamLongInt); inline;
Public procedure PutLongPoint2px(const Value: TPoint2i);
Public procedure PutLongString(const Text: UniString);
Public procedure PutLongWord(const Value: TStreamLongWord); inline;
Public procedure PutMediumString(const Text: UniString; const MaxCount: Integer = 0);
Public procedure PutShortInt(const Value: TStreamShortInt); inline;
Public procedure PutShortString(const Text: UniString; const MaxCount: Integer = 0);
Public procedure PutSingle(const Value: TStreamSingle); inline;
Public procedure PutSmallInt(const Value: TStreamSmallInt); inline;
Public procedure PutUInt64(const Value: TStreamUInt64); inline;
Public procedure PutWord(const Value: TStreamWord); inline;
Public procedure PutWordIndex(const Value: TStreamWordIndex); inline;
Public procedure PutWordPoint2px(const Value: TPoint2i);

Description

Internal Types

Public TStreamByte = SizeUInt;

Value stored as unsigned 8-bit integer, but represented as unsigned 32-bit or 64-bit value depending on platform.

Public TStreamByteBool = Boolean;

Value stored as 8-bit unsigned integer, but represented as Boolean.

Public TStreamByteIndex = SizeInt;

Value stored as unsigned 8-bit integer, but represented as signed 32-bit or 64-bit index depending on platform.

Public TStreamDouble = Double;

Value stored and represented as 64-bit (double-precision) floating-point.

Public TStreamInt64 = Int64;

Value stored and represented as signed 64-bit integer.

Public TStreamLongInt = SizeInt ;

Value stored as 32-bit signed integer, but represented as signed 32-bit or 64-bit value depending on platform.

Public TStreamLongWord = SizeUInt ;

Value stored as unsigned 32-bit integer, but represented as unsigned 32-bit or 64-bit value depending on platform.

Public TStreamShortInt = SizeInt;

Value stored as 8-bit signed integer, but represented as signed 32-bit or 64-bit value depending on platform.

Public TStreamSingle = Single;

Value stored and represented as 32-bit (single-precision) floating-point.

Public TStreamSmallInt = SizeInt;

Value stored as 16-bit signed integer, but represented as signed 32-bit or 64-bit value depending on platform.

Public TStreamUInt64 = UInt64;

Value stored and represented as unsigned 64-bit integer.

Public TStreamWord = SizeUInt;

Value stored as unsigned 16-bit integer, but represented as unsigned 32-bit or 64-bit value depending on platform.

Public TStreamWordIndex = SizeInt ;

Value stored as unsigned 16-bit integer, but represented as signed 32-bit or 64-bit index depending on platform.

Methods

Public function GetByte: TStreamByte; inline;

Loads 8-bit unsigned integer from the stream.

Public function GetByteBool: TStreamByteBool; inline;

Loads Boolean value from the stream previously saved by PutByteBool. The resulting value is treated as 8-bit unsigned integer with values of [0..127] considered as True and values of [128..255] considered as False.

Public function GetByteIndex: TStreamByteIndex; inline;

Loads 8-bit unsigned index from the stream. The range of returned values is [0..254], the value of 255 is returned as -1.

Public function GetBytePoint2px: TPoint2i;

Loads 2D integer point from the stream. Each coordinate is loaded as 8-bit unsigned integer.

Public function GetDouble: TStreamDouble; inline;

Loads 64-bit floating-point value (double-precision) from the stream.

Public function GetFloat34: Single;

Loads floating-point value as 8-bit signed byte from the stream using 1:3:4 fixed-point format. The possible values are in [-8..7.9375] range.

Public function GetFloat43: Single;

Loads floating-point value as 8-bit signed byte from the stream using 1:4:3 fixed-point format. The possible values are in [-16..15.875] range.

Public function GetInt64: TStreamInt64; inline;

Loads 64-bit signed integer from the stream.

Public function GetLongInt: TStreamLongInt; inline;

Loads 32-bit signed integer from the stream.

Public function GetLongPoint2px: TPoint2i;

Loads 2D integer point from the stream. Each coordinate is loaded as 32-bit signed integer.

Public function GetLongString: UniString;

Loads Unicode string from the stream in UTF-8 encoding previously saved by PutLongString.

Public function GetLongWord: TStreamLongWord; inline;

Loads 32-bit unsigned integer from the stream.

Public function GetMediumString: UniString;

Loads Unicode string from the stream in UTF-8 encoding previously saved by PutMediumString.

Public function GetShortInt: TStreamShortInt; inline;

Loads 8-bit signed integer from the stream.

Public function GetShortString: UniString;

Loads Unicode string from the stream in UTF-8 encoding previously saved by PutShortString.

Public function GetSingle: TStreamSingle; inline;

Loads 32-bit floating-point value (single-precision) from the stream.

Public function GetSmallInt: TStreamSmallInt; inline;

Loads 16-bit signed integer from the stream.

Public function GetUInt64: TStreamUInt64; inline;

Loads 64-bit unsigned integer from the stream.

Public function GetWord: TStreamWord; inline;

Loads 16-bit unsigned integer value from the stream.

Public function GetWordIndex: TStreamWordIndex; inline;

Loads 16-bit unsigned index from the stream. The range of returned values is [0..65534], the value of 65535 is returned as -1.

Public function GetWordPoint2px: TPoint2i;

Loads 2D integer point from the stream. Each coordinate is loaded as 16-bit unsigned integer.

Public procedure GetFloats3311(out Value1, Value2: Single);

Loads two floating-point values as a single 8-bit unsigned byte from the stream with each value stored in fixed-point 1:2:1 format. The possible values are in [-4..3.5] range.

Public procedure GetFloats44(out Value1, Value2: Single);

Loads two floating-point values as a single 8-bit unsigned byte from the stream with each value having 4-bits. The possible values are in [-8..7] range.

Public procedure PutByte(const Value: TStreamByte); inline;

Saves 8-bit unsigned integer to the stream. If the value is outside of [0..255] range, it will be clamped.

Public procedure PutByteBool(const Value: TStreamByteBool); inline;

Saves Boolean value to the stream as 8-bit unsigned integer. A value of False is saved as 255, while True is saved as 0.

Public procedure PutByteIndex(const Value: TStreamByteIndex); inline;

Saves 8-bit unsigned index to the stream. A value of -1 (and other negative values) is stored as 255. Positive numbers that are outside of [0..254] range will be clamped.

Public procedure PutBytePoint2px(const Value: TPoint2i);

Saves 2D integer point to the stream. Each coordinate is saved as 8-bit unsigned integer.

Public procedure PutDouble(const Value: TStreamDouble); inline;

Saves 64-bit floating-point value (double-precision) to the stream.

Public procedure PutFloat34(const Value: Single);

Saves floating-point value as 8-bit signed byte to the stream using 1:3:4 fixed-point format with values outside of [-8..7.9375] range will be clamped.

Public procedure PutFloat43(const Value: Single);

Saves floating-point value as 8-bit signed byte to the stream using 1:4:3 fixed-point format with values outside of [-16..15.875] range will be clamped.

Public procedure PutFloats3311(const Value1, Value2: Single);

Saves two floating-point values as a single 8-bit unsigned byte to the stream with each value stored in fixed-point 1:2:1 format. Values outside of [-4..3.5] range will be clamped.

Public procedure PutFloats44(const Value1, Value2: Single);

Saves two floating-point values as a single 8-bit unsigned byte to the stream with each value having 4-bits. Values outside of [-8..7] range will be clamped.

Public procedure PutInt64(const Value: TStreamInt64); inline;

Saves 64-bit signed integer to the stream.

Public procedure PutLongInt(const Value: TStreamLongInt); inline;

Saves 32-bit signed integer to the stream.

Public procedure PutLongPoint2px(const Value: TPoint2i);

Saves 2D integer point to the stream. Each coordinate is saved as 32-bit signed integer.

Public procedure PutLongString(const Text: UniString);

Stores Unicode string to the stream in UTF-8 encoding.

Public procedure PutLongWord(const Value: TStreamLongWord); inline;

Saves 32-bit unsigned integer to the stream.

Public procedure PutMediumString(const Text: UniString; const MaxCount: Integer = 0);

Saves Unicode string to the stream in UTF-8 encoding. The resulting UTF-8 string is limited to a maximum of 65535 characters; therefore, for certain charsets the actual string is limited to either 32767 or even 21845 characters in worst case. If MaxCount is not zero, the input string will be limited to the given number of characters.

Public procedure PutShortInt(const Value: TStreamShortInt); inline;

Saves 8-bit signed integer to the stream. If the value is outside of [-128..127] range, it will be clamped.

Public procedure PutShortString(const Text: UniString; const MaxCount: Integer = 0);

Saves Unicode string to the stream in UTF-8 encoding. The resulting UTF-8 string is limited to a maximum of 255 characters; therefore, for certain charsets the actual string is limited to either 127 or even 85 characters in worst case. If MaxCount is not zero, the input string will be limited to the given number of characters.

Public procedure PutSingle(const Value: TStreamSingle); inline;

Saves 32-bit floating-point value (single-precision) to the stream.

Public procedure PutSmallInt(const Value: TStreamSmallInt); inline;

Saves 16-bit signed integer to the stream. If the value is outside of [-32768..32767] range, it will be clamped.

Public procedure PutUInt64(const Value: TStreamUInt64); inline;

Saves 64-bit unsigned integer to the stream.

Public procedure PutWord(const Value: TStreamWord); inline;

Saves 16-bit unsigned integer to the stream. If the value is outside of [0..65535] range, it will be clamped.

Public procedure PutWordIndex(const Value: TStreamWordIndex); inline;

Saves 16-bit unsigned index to the stream. A value of -1 (and other negative values) is stored as 65535. Positive numbers that are outside of [0..65534] range will be clamped.

Public procedure PutWordPoint2px(const Value: TPoint2i);

Saves 2D integer point to the stream. Each coordinate is saved as 16-bit unsigned integer.


Copyright © 2000 - 2017 Yuriy Kotsarenko. Help files generated by PasDoc.