Class AVariantListItem

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type AVariantListItem = class(ANode)

Description

This class represents a single item in a linked-list of items. Each node represents a single Variant value which, when coupled with the FreePascal runtime, can hold different types of values.

Hierarchy

Overview

Fields

Protected myValue: Variant;

Methods

Public constructor withValue(const thisValue: Variant);
Public function init: boolean; override;
Public function find(const thisValue: Variant): AVariantListItem;
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 toString: AnsiString; override;
Public function value: Variant; virtual;
Public function setValue(const newValue: Variant): Variant; virtual;

Description

Fields

Protected myValue: Variant;

Stores the value of the item

Methods

Public constructor withValue(const thisValue: Variant);

Construct a new list item that contains the specified value.

Public function init: boolean; override;

Initializer

Public function find(const thisValue: Variant): AVariantListItem;

Search the node, its children, and its older siblings for the specified value.

This method performs a sequential search through each node and so can be inefficient for large lists. It begins by recursively calling itself on any older siblings. If the value is not found, then it searches the current node and its children.

If this method is called on the last item in AVariantList, it will result in the entire list being searched.

Returns

A reference to the first node that contains the specified variant value, if found; Nil if the value was not found.

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

Construct a shallow copy of the other object.

This method overrides the behavior inherited from AnObject.shallowCopyFrom: it calls that method, then checks to see whether Other is an instance of AVariantListItem. If so, it copies the value of AVariantListItem.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. The copy will NOT be automatically placed in the list to which Other belongs, if any, but the caller is free to do so.

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 ANode.selfStreamingLength: it calls the inherited routine, 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. For more information on this method, see ANode.writeSelfTo.

This method casts AVariantListItem.value to TVarData and writes the resulting record to Dest.

Returns

The total number of bytes written to Dest.

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

Read the node from the specified stream. For more information on this method, see ANode.readFrom.

This method reads AVariantListItem.value by reading a single record of type TVarData from Source. It then calls the inherited routine.

Returns

The total number of bytes read from Source.

Public function toString: AnsiString; override;

Construct and return a string representation of the node.

In accordance with the criteria described in APrintingObject.toString, this method calls Variants.varToStr to cast Self.value to a string, then returns the resulting value.

Public function value: Variant; virtual;

Retrieve the value associated with the item.

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

Set the value associated with the node.

Returns

The previous value of the item.


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