ADTStream
Stream classes which implements concrete streams according to the interface defined in Type.
- The following classes are implemented
NullStream - Swallow any write operation and return 0 on read operations.
MemoryStream - Allocate dynamic memory as needed for operations.
Some methods are inherited from abstract Stream in Type. Formatting methods are implemented in this module due to the need to avoid circular import in Type.
Const
SeekSet* = Const.SeekSet;
SeekCur* = Const.SeekCur;
SeekEnd* = Const.SeekEnd;
OK* = Const.OK;
Types
ADTStream* = RECORD (Type.Stream) END;
NullStream* = RECORD (ADTStream) END;
MemoryStream* = RECORD (ADTStream)
storage : MemoryStorage;
pos : LENGTH;
last : LENGTH;
END;
Procedures
ADTStream.FormatString
PROCEDURE (VAR s : ADTStream) FormatString*(str- : ARRAY OF CHAR; width, prec: INTEGER; flags: SET);
ADTStream.FormatInteger
Format HUGEINT.
width : Total field with. Can overflow if number is bigger.
The alignment formatting flags are Left, Right & Center . The Zero flag fills with 0 of the formatting is right aligned. The Spc flag fills in a blank character for + if the number is positive. The Sign flag fills in a + character if the number is positive. If both Spc and Sign are given then Sign precedes.
PROCEDURE (VAR s : ADTStream) FormatInteger*(value : HUGEINT; width: LENGTH; flags: SET);
ADTStream.FormatReal
Format REAL.
prec : Precision or zero for default value.
width : Total field with. Can overflow if number is bigger.
flags : Exp or Fix formatting supported.
The alignment formatting flags are Left, Right & Center . The Spc flag fills in a blank character for + if the number is positive. The Sign flag fills in a + character if the number is positive. If both Spc and Sign are given then Sign precedes.
PROCEDURE (VAR s : ADTStream) FormatReal*(value : REAL; prec : INTEGER; width: LENGTH; flags: SET);
ADTStream.FormatCardinal
Format HUGECARD.
base : Number base.
width : Total field with. Can overflow if number is bigger.
The alignment formatting flags are Left, Right & Center . The Zero flag fills with 0 of the formatting is right aligned. The Upper flag the hex decimal letters are upper case.
The Alt flags prefix binary (base 2) numbers with 0b, octal numbers (base 8) with 0o and hex decimal numbers with either 0x or 0X depending on the Upper flag.
PROCEDURE (VAR s : ADTStream) FormatCardinal*(value : HUGECARD; base, width: INTEGER; flags: SET);
ADTStream.FormatDateTime
Format DATETIME according to format string arguments:
%a : Weekday abbreviated name : Mon .. Sun
%A : Weekday full name : Monday .. Sunday
%w : Weekday as number : 0 .. 6
%b : Month abbreviated name : Jan .. Des
%B : Month full name : Januar .. Desember
%Y : Year without century : 00 - 99
%y : Year with century : 0000 - 9999
%m : Month zero-padded : 00 - 12
%d : Day of the month zero-padded : 01 - XX
%W : Week of the year zero-padded : 01 - 53
%H : Hour (24-hour clock) zero-padded : 00 - 23
%I : Hour (12-hour clock) zero-padded : 1 - 12
%p : AM or PM
%M : Minute zero-padded : 00 - 59
%S : Second zero-padded : 00 - 59
%f : Milliseconds zero-padded : 000 - 999
%Z : Timezone : UTC+/-
%% : Literal % char
Other characters are copied to output.
PROCEDURE (VAR s : ADTStream) FormatDateTime*(value : DateTime.DATETIME; fmt- : ARRAY OF CHAR);
NullStream.ReadBytes
Read bytes into buffer with optional start and length.
PROCEDURE (VAR s : NullStream) ReadBytes*(VAR buffer : ARRAY OF BYTE; start, length : LENGTH): LENGTH;
NullStream.WriteBytes
Write bytes from buffer with optional start and length.
PROCEDURE (VAR s : NullStream) WriteBytes*(VAR buffer : ARRAY OF BYTE; start, length : LENGTH): LENGTH;
NullStream.Readable
Return TRUE if Stream is readable
PROCEDURE (VAR s : NullStream) Readable*(): BOOLEAN;
NullStream.Writeable
Return TRUE if Stream is writeable
PROCEDURE (VAR s : NullStream) Writeable*(): BOOLEAN;
NullStream.Seekable
Return TRUE if Stream is seekable
PROCEDURE (VAR s : NullStream) Seekable*(): BOOLEAN;
MemoryStream.Open
Open MemoryStream with optional size (minimum size is 64).
Return TRUE if success.
PROCEDURE (VAR s : MemoryStream) Open*(size: LENGTH): BOOLEAN;
MemoryStream.ToString
Copy Stream content to string. The string is possible resized and is NUL terminated.
PROCEDURE (VAR s : MemoryStream) ToString*(VAR str : Type.STRING);
MemoryStream.ReadBytes
Read bytes into buffer with optional start and length.
PROCEDURE (VAR s : MemoryStream) ReadBytes*(VAR buffer : ARRAY OF BYTE; start, length: LENGTH): LENGTH;
MemoryStream.Reserve
Resize storage to accomodate capacity
PROCEDURE (VAR s : MemoryStream) Reserve*(capacity : LENGTH);
MemoryStream.Shrink
Shrink storage if possible
PROCEDURE (VAR s : MemoryStream) Shrink*();
MemoryStream.WriteBytes
Write bytes from buffer with optional start and length.
PROCEDURE (VAR s : MemoryStream) WriteBytes*(VAR buffer : ARRAY OF BYTE; start, length : LENGTH): LENGTH;
MemoryStream.Seek
Offsets or set the current location depending on the mode argument:
SeekSet : sets position relative to start of stream.
SeekCur : sets position relative to current position of stream.
SeekEnd : sets position relative to end position of stream (only negative offset values makes sense).
Return new position or -1 in case of failure.
PROCEDURE (VAR s : MemoryStream) Seek*(offset : LENGTH; mode : INTEGER): LENGTH;
MemoryStream.Tell
Return current position or -1 on failure.
PROCEDURE (VAR s : MemoryStream) Tell*(): LENGTH;
MemoryStream.Truncate
Truncates or extends stream to new size. Return new size or -1 in case of failure.
PROCEDURE (VAR s : MemoryStream) Truncate*(size : LENGTH): LENGTH;
MemoryStream.Close
Close Stream
PROCEDURE (VAR s : MemoryStream) Close*();
MemoryStream.Closed
Return TRUE if Stream is closed
PROCEDURE (VAR s : MemoryStream) Closed*(): BOOLEAN;
MemoryStream.Readable
Return TRUE if Stream is readable
PROCEDURE (VAR s : MemoryStream) Readable*(): BOOLEAN;
MemoryStream.Writeable
Return TRUE if Stream is writeable
PROCEDURE (VAR s : MemoryStream) Writeable*(): BOOLEAN;
MemoryStream.Seekable
Return TRUE if Stream is seekable
PROCEDURE (VAR s : MemoryStream) Seekable*(): BOOLEAN;