Class AStreamBookmark
Unit
classwork
Declaration
type AStreamBookmark = class(AStringLeaf)
Description
This class represents a stream bookmark, which is a way of associating a name with a specific location in a stream. This is useful in cases where you want to open an arbitrary stream and find the position of a specific piece of data, but you don't know ahead of time where that data will be in the stream.
Stream bookmarks are managed by instances of AStreamBookmarkDictionary, which provides a way to look up a specific bookmark and which can also read and write a list of bookmarks to a given stream.
Hierarchy
Overview
Fields
Methods
Description
Fields
|
myPosition: TStreamOffset; |
Stores the position in the stream where the data referenced by the bookmark may be found.
|
Methods
|
constructor named(const thisKey: string; const thisPosition: TStreamOffset); reintroduce; virtual; |
Construct a new bookmark with the given name and given stream position.
|
|
constructor atCurrentPositionIn(const Source: AStream; const thisName: string); virtual; |
Construct a new bookmark with the given name, using the current position within the specified stream.
If Source is valid (not Nil ), this method will call AStream.position on it and use the value returned as the position to which the bookmark refers.
|
|
function init: boolean; override; |
Initializer
|
|
function selfStreamingLength: TStreamIOSize; override; |
Calculate the number of bytes required to stream the bookmark.
This method builds upon the behavior inherited from AStringLeaf.selfStreamingLength: it calls the inherited routine, then adds the number of bytes required to store the bookmark type and position reference.
|
|
function writeSelfTo(const Dest: AStream): TStreamIOSize; override; |
Write the bookmark, and just the bookmark, to the given stream.
This method builds upon the behavior inherited from AStringLeaf.writeSelfTo; it first calls the inherited routine, then writes the value of AStreamBookmark.position.
Returns
The total number of bytes written to Dest . |
|
function readFrom(const Source: AStream): TStreamIOSize; override; |
Read the bookmark from the given stream.
This method builds upon the behavior inherited from AStringLeaf.readFrom; it first calls the inherited routine, then reads the value of AStreamBookmark.position.
Returns
The total number of bytes read from Source . |
|
function toString: AnsiString; override; |
Construct a string representation of the bookmark, suitable for output to a text-based device, such as a console.
This method overrides the behavior inherited from AStringLeaf.toString. It returns a string that is constructed based on the format specified by stbmStringRepresentation. In the default implementation, this string will contain the name of the bookmark as well as the position in the stream to which it refers.
|
|
function bookmarkType: TStreamBookmarkType; virtual; |
Retrieve the type of bookmark represented by the instance.
This value is used when reading bookmarks from a stream to ensure the correct instance of AStreamBookmark or its descendants is created.
|
|
function position: TStreamOffset; virtual; |
Retrieve the position in the stream to which the bookmark refers.
|
|
function setPosition(const newPosition: TStreamOffset): TStreamOffset; virtual; |
Set the position in the stream to which the bookmark refers.
thisPosition must be a positive value which specifies the offset, in bytes, from the beginning of the stream to which the bookmark refers. The beginning of the stream is always at offset zero (0 ). If thisPosition is negative, this routine will do nothing.
Returns
The previous value of AStreamBookmark.position. |
|
function setToCurrentPositionIn(const Source: AStream): TStreamOffset; virtual; |
Set the position in the stream to which the bookmark refers by querying the specified stream.
If Source is valid (not Nil ), then this method calls AStream.position on it and stores the result.
Returns
The previous value of AStreamBookmark.position. |
Generated by PasDoc 0.13.0 on 2015-01-10 17:13:18
|