Class ACommandLineIntegerRange

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type ACommandLineIntegerRange = class(ACommandLineNumber)

Description

This class represents an option that expects an integer 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: int64;
Protected myMaximumValue: int64;

Methods

Public constructor named(const thisName: string; const isRequired: boolean; const isRest: boolean; const thisDefaultValue: Variant; const thisMinimumValue, thisMaximumValue: int64; const thisDescription: string; const thisValueDescription: string = ''); 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: int64; virtual;
Public function setMinimum(const newMinimum: int64): int64; virtual;
Public function maximum: int64; virtual;
Public function setMaximum(const newMaximum: int64): int64; virtual;

Description

Fields

Protected myMinimumValue: int64;

Stores the minimum acceptable value

Protected myMaximumValue: int64;

Stores the maximum acceptable value

Methods

Public constructor named(const thisName: string; const isRequired: boolean; const isRest: boolean; const thisDefaultValue: Variant; const thisMinimumValue, thisMaximumValue: int64; const thisDescription: string; const thisValueDescription: string = ''); 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 clirAcceptedValuesDescription.

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 ACommandLineIntegerRange. If so, it copies the values of ACommandLineIntegerRange.minimum and ACommandLineIntegerRange.maximum from Other to Self, overwriting the corresponding values in Self.

This method is also compatible with instances of ACommandLineFloatRange. If Other is an instance of ACommandLineFloatRange, this method will copy the values of ACommandLineFloatRange.minimum and ACommandLineFloatRange.maximum from Other to Self, overwriting the corresponding values in Self. The values copied will be truncated to integer values.

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 ACommandLineIntegerRange.minimum and ACommandLineIntegerRange.maximum, inclusive. If it does, the new value is set; otherwise it is ignored and an exception is thrown.

Returns

The previous value of ACommandLineIntegerRange.value.

Exceptions raised
AnOptionValueError
in the event that the attempt to cast newValue to an integer value fails, or if newValue does not fall between ACommandLineIntegerRange.minimum and ACommandLineIntegerRange.maximum.
Public function minimum: int64; virtual;

Retrieve the minimum acceptable value allowed for the range.

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

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

Set the minimum acceptable value allowed for the range.

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

Returns

The previous value of ACommandLineIntegerRange.minimum.

Public function maximum: int64; virtual;

Retrieve the maximum acceptable value allowed for the range.

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

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

Set the maximum acceptable value allowed for the range.

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

Returns

The previous value of ACommandLineIntegerRange.maximum.


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