Class AMappingEntry

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type AMappingEntry = class(AStringLeaf)

Description

This class represents a mapping entry, which is an item that is indexed by a string key and which maps that key to a value. The base class places no restrictions on the type of value that can be represented by the entry; it stipulates only that descendant classes must provide a way to represent that value as a string, and to accept the value from a string.

Hierarchy

Overview

Methods

Public constructor fromDelimitedString(item: AnsiString; delimiter: string = ''); virtual;
Public function implode(delimiter: string = ''): AnsiString; virtual;
Public function toString: AnsiString; override;
Public function valueAsString: string; virtual; abstract;
Public function setValueFromString(const newValue: string): string; virtual; abstract;

Description

Methods

Public constructor fromDelimitedString(item: AnsiString; delimiter: string = ''); virtual;

Explode the entry from a string which contains a key/value pair, where the key and value are separated from each other by delimiter.

This method attempts to break item into two strings by searching for delimiter. If successful, the method will call the inherited constructor to set the name and sort key of the entry, after which it will call Self.setValueFromString to set the value of the entry.

If delimiter is not found, then this method constructs an empty mapping entry.

If delimiter is not specified by the caller, of it is an empty string, then the value of mapDefaultDelimiter is used.

Public function implode(delimiter: string = ''): AnsiString; virtual;

Implode the entry into a string that contains a key/value pair, where the key and value are separated by delimiter.

This method calls Self.name to obtain the value of the entry's string key and AMappingEntry.valueAsString to obtain the entry's present value.

If delimiter is not specified by the caller, or if it is an empty string, then the value of mapDefaultDelimiter is used.

Public function toString: AnsiString; override;

Construct and return a string representation of the entry, suitable for printing to a text-based device, such as a console.

In accordance with the criteria described by APrintingObject.toString, the string representation returned by this method will include the name of the entry (returned by a call to ADictionaryEntry.name) and a string representation of its value (returned by a call to Variants.varToStr), separated by the delimiter specified in mapDefaultDelimiter. This string is obtained by calling AMappingEntry.implode.

Public function valueAsString: string; virtual; abstract;

Return the value of the mapping entry as a string. This method must be implemented by descendant classes.

Public function setValueFromString(const newValue: string): string; virtual; abstract;

Set the value of the mapping entry from a string. This method must be implemented by descendant classes.

The method should return the previous value of the entry as a string.


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