Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

TRangeValidator Class Reference

Determines whether the data typed by a user falls within a designated range of integers. More...

#include <validate.h>

Inheritance diagram for TRangeValidator::

TFilterValidator TValidator TObject TStreamable List of all members.

Public Methods

 TRangeValidator (long aMin, long aMax)
virtual void error ()
virtual Boolean isValid (const char *s)
virtual ushort transfer (char *s, void *buffer, TVTransfer flag)

Static Public Methods

TStreamablebuild ()

Static Public Attributes

const char* const name

Protected Methods

 TRangeValidator (StreamableInit)
virtual void write (opstream &os)
virtual void* read (ipstream &is)

Protected Attributes

long min
long max

Detailed Description

A range validator object determines whether the data typed by a user falls within a designated range of integers.

Definition at line 606 of file validate.h.


Constructor & Destructor Documentation

TRangeValidator::TRangeValidator ( long aMin,
long aMax )
 

Constructs a range validator object by first calling the constructor inherited from TFilterValidator, passing a set of characters containing the digits '0'..'9' and the characters '+' and '-'.

Sets min to `aMin' and max to `aMax', establishing the range of acceptable long integer values.

TRangeValidator::TRangeValidator ( StreamableInit ) [protected]
 

Each streamable class needs a "builder" to allocate the correct memory for its objects together with the initialized virtual table pointers. This is achieved by calling this constructor with an argument of type StreamableInit.


Member Function Documentation

TStreamable * TRangeValidator::build ( ) [static]
 

Called to create an object in certain stream-reading situations.

Reimplemented from TFilterValidator.

void TRangeValidator::error ( ) [virtual]
 

Displays a message box indicating that the entered value did not fall in the specified range.

Reimplemented from TFilterValidator.

Boolean TRangeValidator::isValid ( const char * s ) [virtual]
 

Converts the string `s' into an integer number and returns True if the result meets all three of these conditions:

  1. it is a valid integer number
  2. it value is greater than or equal to min
  3. it value is less than or equal to max
If any of those tests fails, isValid() returns False.

Reimplemented from TFilterValidator.

void * TRangeValidator::read ( ipstream & is ) [protected, virtual]
 

Reads from the input stream `is'.

Reimplemented from TFilterValidator.

ushort TRangeValidator::transfer ( char * s,
void * buffer,
TVTransfer flag ) [virtual]
 

Incorporates the three functions TInputLine::dataSize(), TInputLine::getData(), and TInputLine::setData() that a range validator can handle for its associated input line.

Instead of setting and reading the value of the numeric input line by passing a string representation of the number, transfer() can use a long int as its data record, which keeps your application from having to handle the conversion.

`s' is the input line's string value, and `buffer' is the data record passed to the input line.

Depending on the value of `flag', transfer either sets `s' from the number in `buffer' or sets the number at `buffer' to the value of the string `s'. If `flag' is vtSetData, transfer() sets `s' from `buffer'.

If `flag' is vtGetData, transfer() sets `buffer' from `s'. If `flag' is vtDataSize, transfer() neither sets nor reads data.

transfer() always returns the size of the data transferred, in this case the size of a long int.

See also:
TValidator::transfer

Reimplemented from TValidator.

void TRangeValidator::write ( opstream & os ) [protected, virtual]
 

Writes to the output stream `os'.

Reimplemented from TFilterValidator.


Member Data Documentation

long TRangeValidator::max [protected]
 

max is the highest valid long integer value for the input line.

Definition at line 679 of file validate.h.

long TRangeValidator::min [protected]
 

min is the lowest valid long integer value for the input line.

Definition at line 675 of file validate.h.

const char *const TRangeValidator::name [static]
 

Undocumented.

Reimplemented from TFilterValidator.

Definition at line 708 of file validate.h.


The documentation for this class was generated from the following file:
Generated at Sat Sep 22 20:19:32 2001 for TVision by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001