Class AStringListItem

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type AStringListItem = class(ANode)

Description

This class represents a single entry in AStringList. It extends ANode to allow each one to hold a string value. The list item also supports streaming and sorting.

Hierarchy

Overview

Fields

Protected myText: string;

Methods

Public constructor withText(const thisText: string); virtual;
Public function init: boolean; override;
Public function find(const thisValue: string): AStringListItem; virtual;
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 text: string; virtual;
Public function setText(const newValue: string): string; virtual;

Description

Fields

Protected myText: string;

Stores the value of the list item.

Methods

Public constructor withText(const thisText: string); virtual;

Construct a new list item that has the specified value.

Public function init: boolean; override;

Initializer

Public function find(const thisValue: string): AStringListItem; virtual;

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 AStringList, it will result in the entire list being searched.

Returns

A reference to the first node that contains the specified string 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 AStringListItem. If so, it copies the value of AStringListItem.text 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 calculates the number of bytes required to stream its text and adds that to the result, which is returned to the caller.

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 writes the value of its string by calling AStream.writeString on Dest, then calls the inherited routine.

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 the value of its string by calling AStream.readString on Source, 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 returns the value of AStringListItem.text.

Public function text: string; virtual;

Retrieve the string value associated with the node.

Public function setText(const newValue: string): string; virtual;

Set the string value associated with the node.

Returns

The old string value associated with the node.


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