Class AStreamBookmarkDictionary

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type AStreamBookmarkDictionary = class(AStringTree)

Description

This class represents a dictionary of stream bookmarks, which is a collection of instances of AStreamBookmark. It provides a way to retrieve the position to which a given bookmark refers and can read and write an entire list of bookmarks using an arbitrary stream.

Hierarchy

Overview

Methods

Public function init: boolean; override;
Public function positionOf(const thisBookmarkName: string): TStreamOffset; virtual;
Public function BookmarkNamed(const thisBookmarkName: string): AStreamBookmark; virtual;
Public function NewBookmarkOfType(const thisBookmarkType: TStreamBookmarkType): AStreamBookmark; virtual;
Public function readFrom(const Source: AStream): TStreamIOSize; override;

Description

Methods

Public function init: boolean; override;

Initializer

Public function positionOf(const thisBookmarkName: string): TStreamOffset; virtual;

Retrieve the position to which the named bookmark refers.

If thisBookmarkName is invalid (an empty string), or the named bookmark is not found, this method will return a negative value.

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

Retrieve a reference to the named bookmark. The reference returned by this routine should NOT be freed by the caller.

This method simply calls ABinaryTree.FetchLeaf and casts the value returned to AStreamBookmark.

If the named bookmark is not found, this method returns Nil.

Public function NewBookmarkOfType(const thisBookmarkType: TStreamBookmarkType): AStreamBookmark; virtual;

This method is responsible for constructing the appropriate instance of AStreamBookmark or one of its descendants to read the bookmark data stored in the stream. Descendant classes may override this method to add to the types of bookmarks that are recognized; the base implementation will construct instances of AStreamBookmark or AStreamBookmarkSpan.

Returns

An instance of AStreamBookmark or one of its descendants, depending on the value of thisBookmarkType. The caller is responsible for ensuring that the instance returned is freed when it is no longer needed.

If thisBookmarkType specifies a value that is not recognized by the method, the method will return Nil.

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

Read the dictionary from the given stream.

This method overrides the behavior inherited from ABinaryTree. After reading the number of entries in the dictionary the method loops, reading the type of bookmark from the stream and then calling AStreamBookmarkDictionary.NewBookmarkOfType. Once the appropriate instance has been constructed, the readFrom method is called on it to ensure that the data is read. The bookmark instance is then added to the dictionary.

.

Returns

The total number of bytes read from the stream. If Source is Nil, this routine will do nothing and will return zero (0)


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