Class ADictionaryEntry

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type ADictionaryEntry = class(AMappingEntry)

Description

This class represents a dictionary entry, which is an item that is indexed by a string key. The value of the item is represented by a variant object, so as enable the dictionary element to store the widest possible array of values.

Unlike a typical dictionary, the item here is not associated with a hash lookup table; instead, it is treated as a node in a binary tree.

Hierarchy

Overview

Fields

Protected myValue: Variant;

Methods

Public constructor named(const thisName: string; const thisValue: Variant); reintroduce; virtual;
Public function init: boolean; override;
Public function shallowCopyFrom(const Other: AnObject): 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 value: Variant; virtual;
Public function setValue(const newValue: Variant): Variant; virtual;
Public function valueAsString: string; override;
Public function setValueFromString(const newValue: string): string; override;

Description

Fields

Protected myValue: Variant;

Stores the value of the entry

Methods

Public constructor named(const thisName: string; const thisValue: Variant); reintroduce; virtual;

Construct a new entry that associates the specified name with the specified variant value. The value of thisName will be hashed to determine the sort key of the dictionary entry when it is inserted into a dictionary.

Public function init: boolean; override;

Initializer

Public function shallowCopyFrom(const Other: AnObject): boolean; override;

Construct a shallow copy of the other object.

This method overrides the behavior inherited from AStringLeaf.shallowCopyFrom: it calls that routine, then checks to see whether Other is an instance of ADictionaryEntry. If so, it copies the value of ADictionaryEntry.value from Other to Self, overwriting the value in Self.

Note that this method does NOT copy any sibling or child nodes and so cannot be used to create a full copy of any descendant of ANode. Likewise, it does NOT copy the left or right subtrees and so cannot be used to create a full copy of any descendant of ABinaryLeaf. The copy will NOT be automatically placed in the binary tree to which Other belongs, if any, but the caller is free to do so, so long as the node's sort key does not match one that already exists in the tree.

Public function selfStreamingLength: TStreamIOSize; override;

Calculate the number of bytes required to stream the node, and just the node.

This method builds upon the behavior inherited from AStringLeaf.selfStreamingLength: it calls the inherited method, then adds the number of bytes required to store an instance of TVarData.

Public function writeSelfTo(const Dest: AStream): TStreamIOSize; override;

Write the node, and just the node, to the specified stream.

This method builds upon the behavior inherited from AStringLeaf.writeSelfTo: it first calls the inherited routine, then writes the value of the entry by converting it to an instance of TVarData.

Returns

The total number of bytes written to Dest.

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

Read the node from the specified stream.

This method builds upon the behavior inherited from AStringLeaf.readFrom: it calls the inherited routine first, then reads the value of the entry by treating it as an instance of TVarData when reading it from Source.

Returns

The total number of bytes read from Source.

Public function value: Variant; virtual;

Retrieve the value associated with the entry.

Public function setValue(const newValue: Variant): Variant; virtual;

Sets the value of the entry.

Returns

The previous value of the entry.

Public function valueAsString: string; override;

Retrieve the value of the entry as a string.

This method calls Variants.varToStr on Self.value and returns the result.

Public function setValueFromString(const newValue: string): string; override;

Set the value of the entry from the given string.

This method calls Self.setValue with newValue and returns the result formatted as a string.


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