Class AStreamBookmarkSpan

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type AStreamBookmarkSpan = class(AStreamBookmark)

Description

This class represents a string bookmark that specifies a span: that is, a block of bytes within a stream. The bookmark tracks not only the position of the span, where it begins, but also its size in bytes.

To mark the beginning of a span, simply call AStreamBookmarkSpan.setPosition. To mark the end of a span, call AStreamBookmarkSpan.setEndPosition and the bookmark will automatically calculate the size of the span.

Hierarchy

Overview

Fields

Protected myLength: TStreamLength;

Methods

Public function init: boolean; override;
Public function selfStreamingLength: TStreamIOSize; override;
Public function writeSelfTo(const Dest: AStream): TStreamIOSize; override;
Public function readFrom(const Source: AStream): TStreamIOSize; override;
Public function toString: AnsiString; override;
Public function length: TStreamLength; virtual;
Public function endPosition: TStreamOffset; virtual;
Public function setEndPosition(const thisPosition: TStreamOffset): TStreamOffset; virtual;
Public function setEndToCurrentPositionIn(const Source: AStream): TStreamOffset; virtual;

Description

Fields

Protected myLength: TStreamLength;

Stores the size of the span, in bytes

Methods

Public function init: boolean; override;

Initializer

Public function selfStreamingLength: TStreamIOSize; override;

Calculate the number of bytes required to stream the bookmark.

This method builds upon the behavior inherited from AStreamBookmark.selfStreamingLength: it calls the inherited routine, then adds the number of bytes required to store the length of the span.

Public 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 AStreamBookmark.writeSelfTo; it first calls the inherited routine, then writes the value of AStreamBookmarkSpan.length.

Returns

The total number of bytes written to Dest.

Public function readFrom(const Source: AStream): TStreamIOSize; override;

Read the bookmark from the given stream.

This method builds upon the behavior inherited from AStreamBookmark.readFrom; it first calls the inherited routine, then reads the value of AStreamBookmarkSpan.length.

Returns

The total number of bytes read from Source.

Public 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 AStreamBookmark.toString. It returns a string that is constructed based on the format specified by either sbspStringRepresentationPlural or sbspStringRepresentationSingular, depending on the value of Self.length. In the default implementation of this method, this string will contain the name of the span as well as the positions in the stream where it begins and ends, and its length.

Public function length: TStreamLength; virtual;

Retrieve the size of the span, in bytes.

Public function endPosition: TStreamOffset; virtual;

Retrieve the position in the stream at which the span comes to an end.

This method calculates the value returned by adding the value of Self.position to the value of Self.length.

Public function setEndPosition(const thisPosition: TStreamOffset): TStreamOffset; virtual;

Set the position in the stream at which the span comes to an end.

thisPosition must be a positive value which specifies the offset, in bytes, from the beginning of the stream where the span comes to an end. The beginning of the stream is always at offset zero (0). If thisPosition is negative, this routine will do nothing.

If thisPosition represents a position in the stream that is less than the value of Self.position, this method will do nothing.

Returns

The previous value of AStreamBookmarkSpan.endPosition.

Public function setEndToCurrentPositionIn(const Source: AStream): TStreamOffset; virtual;

Use the current position in the specified stream as the point at which the span comes to an end.

If Source is valid (not Nil), then this method calls AStream.position on it and stores the result.

Returns

The previous value of AStreamBookmarkSpan.endPosition.


Generated by PasDoc 0.13.0 on 2015-06-23 19:40:11