Class ACommandLineFloatRange

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type ACommandLineFloatRange = class(ACommandLineNumber)

Description

This class represents an option that expects a floating-point value which falls between a predefined minimum and maximum. If the user attempts to set a value that is outside the prescribed range of values, an error is returned to them.

Hierarchy

Overview

Fields

Protected myMinimumValue: double;
Protected myMaximumValue: double;

Methods

Public constructor named(const thisName: string; const isRequired: boolean; const isRest: boolean; const thisDefaultValue: Variant; const thisMinimumValue, thisMaximumValue: double; const thisDescription: string; const thisValueDescription: string = ''; const onOptionDirtied: AnOptionDirtiedHandler = nil); reintroduce; virtual;
Public function init: boolean; override;
Public function usageString: AnsiString; override;
Public function shallowCopyFrom(const Other: AnObject): boolean; override;
Public function setValue(const newValue: Variant; const makeDirty: boolean = true): Variant; override;
Public function minimum: double; virtual;
Public function setMinimum(const newMinimum: double): double; virtual;
Public function maximum: double; virtual;
Public function setMaximum(const newMaximum: double): double; virtual;

Description

Fields

Protected myMinimumValue: double;

Stores the minimum acceptable value

Protected myMaximumValue: double;

Stores the maximum acceptable value

Methods

Public constructor named(const thisName: string; const isRequired: boolean; const isRest: boolean; const thisDefaultValue: Variant; const thisMinimumValue, thisMaximumValue: double; const thisDescription: string; const thisValueDescription: string = ''; const onOptionDirtied: AnOptionDirtiedHandler = nil); reintroduce; virtual;

Construct a new command-line option with the specified name.

This method constructs a new instance of ACommandLineOption with the specified defaultValue, minimumValue, and maximumValue. The caller can also set whether the option is required, and can provide a description of the option which will be used when the user requests help.

Public function init: boolean; override;

Initializer

Public function usageString: AnsiString; override;

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

This method builds upon the behavior inherited from ACommandLineOption.usageString: it calls that routine first, then appends a string that indicates the minimum and maximum values for the range. The format of the appended string is controlled by clfrAcceptedValuesDescription.

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

Construct a shallow copy of the other object.

This method overrides the behavior inherited from ACommandLineOption.shallowCopyFrom: it calls that routine first, then checks to see whether Other is an instance of ACommandLineFloatRange. If so, it copies the values of ACommandLineFloatRange.minimum and ACommandLineFloatRange.maximum from Other to Self, overwriting the corresponding values in Self.

This method is also compatible with instances of ACommandLineIntegerRange. If Other is an instance of ACommandLineIntegerRange, this method will copy the values of ACommandLineIntegerRange.minimum and ACommandLineIntegerRange.maximum from Other to Self, overwriting the corresponding values 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.

Public function setValue(const newValue: Variant; const makeDirty: boolean = true): Variant; override;

Set the value of the option.

This method overrides the behavior inherited from ACommandLineNumber.setValue. As with the inherited routine, this method attempts to cast newValue to a numeric value. If that succeeds, it checks to ensure that newValue falls between ACommandLineFloatRange.minimum and ACommandLineFloatRange.maximum, inclusive. If it does, the new value is set; otherwise it is ignored and an exception is thrown.

Returns

The previous value of ACommandLineFloatRange.value.

Exceptions raised
AnOptionValueError
in the event that the attempt to cast newValue to a floating-point value fails, or if newValue does not fall between ACommandLineFloatRange.minimum and ACommandLineFloatRange.maximum.
Public function minimum: double; virtual;

Retrieve the minimum acceptable value allowed for the range.

Calls to ACommandLineFloatRange.setValue must specify a value that is greater than or equal to this value and less than or equal to the value of ACommandLineFloatRange.maximum.

Public function setMinimum(const newMinimum: double): double; virtual;

Set the minimum acceptable value allowed for the range.

Calls to ACommandLineFloatRange.setValue must be greater than or equal to newMinimum and less than or equal to the value of ACommandLineFloatRange.maximum.

Returns

The previous value of ACommandLineFloatRange.minimum.

Public function maximum: double; virtual;

Retrieve the maximum acceptable value allowed for the range.

Calls to ACommandLineFloatRange.setValue must specify a value that is less than or equal to this value and greater than or equal to the value of ACommandLineFloatRange.minimum.

Public function setMaximum(const newMaximum: double): double; virtual;

Set the maximum acceptable value allowed for the range.

Calls to ACommandLineFloatRange.setValue must specify a value that is less than or equal to this value and greater than or equal to the value of ACommandLineFloatRange.minimum.

Returns

The previous value of ACommandLineFloatRange.maximum.


Generated by PasDoc 0.13.0 on 2015-06-25 11:07:51