Class ABookmarkedOutputStream

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type ABookmarkedOutputStream = class(ABookmarkedStream)

Description

This class represents a stream that is capable of recording bookmarks to a dictionary of bookmarks and then writing that dictionary to itself at a given position.

Instances of ABookmarkedOutputStream are not able to read their dictionary of bookmarks, but they can write it. The idea is that, as the stream is written, various bookmarks are recorded which are then also written to the stream before it is closed.

Hierarchy

Overview

Methods

Public function init: boolean; override;
Public function write(const count: TStreamIOSize; const source): TStreamIOSize; override;
Public function MarkPosition(const thisBookmarkName: string): AStreamBookmark; virtual;
Public function BeginSpan(const thisSpanName: string): AStreamBookmarkSpan; virtual;
Public function EndSpan(const thisSpanName: string): AStreamBookmarkSpan; virtual;
Public function writeBookmarksAt(const thisPosition: TStreamOffset = -1): TStreamOffset; virtual;
Public function writeBookmarks: TStreamOffset; virtual;

Description

Methods

Public function init: boolean; override;

Initializer

Public function write(const count: TStreamIOSize; const source): TStreamIOSize; override;

Write count bytes from source to the stream.

This method overrides the behavior inherited from AStreamWrapper (which does nothing); it passes the call through to ABookmarkedOutputStream.Target and returns the result.

Returns

The total number of bytes written to the stream.

Public function MarkPosition(const thisBookmarkName: string): AStreamBookmark; virtual;

Record the current stream position using a bookmark with the given name.

If a bookmark with thisBookmarkName already exists in the dictionary of bookmarks maintained by the stream, then the value of that bookmark is updated. Otherwise, a new bookmark is created and entered into the dictionary.

If thisBookmarkName is an empty string, this routine does nothing.

Returns

A reference to the bookmark that was updated. This will either be a new bookmark or an existing bookmark that had thisBookmarkName. In either case, the caller should NOT free the reference returned by this routine; that will be done when the bookmarked stream is destroyed.

Public function BeginSpan(const thisSpanName: string): AStreamBookmarkSpan; virtual;

Record the current stream position as the beginning of a span with the given name.

If a bookmark with thisSpanName already exists in the dictionary of bookmarks maintained by the stream, then the position of that bookmark is updated. Otherwise, a new bookmark is created and entered into the dictionary.

If thisSpanName is an empty string, this routine does nothing.

Returns

A reference to the bookmark that was updated. This will either be a new bookmark or an existing bookmark that had thisSpanName. In either case, the caller should NOT free the reference returned by this routine; that will be done when the bookmarked stream is destroyed.

Public function EndSpan(const thisSpanName: string): AStreamBookmarkSpan; virtual;

Record the current stream position as the end of a span with the given name.

If no bookmark is found with thisSpanName then this routine does nothing. If a bookmark is found, but it is not an instance of AStreamBookmarkSpan, then this routine does nothing.

Returns

A reference to the bookmark that was updated, if found. The caller should NOT free the reference returned by this routine. If no bookmark was updated, this routine will return Nil.

Public function writeBookmarksAt(const thisPosition: TStreamOffset = -1): TStreamOffset; virtual;

Write the dictionary of bookmarks to the stream at the specified position.

This method moves the stream position pointer to the position specified and then calls AStreamBookmarkDictionary.writeTo on ABookmarkedOutputStream.Bookmarks, passing Self as the destination stream. By default, the dictionary of bookmarks is written at the end of the stream, but the caller may wish to store the dictionary at another position in the stream. If so, it may be helpful to first call AStreamBookmarkDictionary.streamingLength to determine how much space in the stream will be required by the dictionary and ensure there is enough empty space in the stream

Returns

The position in the stream (relative to the beginning of the stream) at which the bookmarks were written. This value can be used, among other things, as part of a stream header so that the bookmarks can be recalled from the stream later. If the bookmarks could not be written, this routine will return a negative value.

Public function writeBookmarks: TStreamOffset; virtual;

Write the dictionary of bookmarks at the current position in the stream.

This method simply calls Self.writeBookmarksAt, passing the value of Self.position.

Returns

The position in the stream (relative to the beginning of the stream) at which the bookmarks were written. This value can be used, among other things, as part of a stream header so that the bookmarks can be recalled from the stream later. If the bookmarks could not be written, this routine will return a negative value.


Generated by PasDoc 0.13.0 on 2015-01-10 17:13:18