#include <validate.h>
Inheritance diagram for TValidator::
Public Methods | |
TValidator () | |
virtual void | error () |
virtual Boolean | isValidInput (char *s, Boolean suppressFill) |
virtual Boolean | isValid (const char *s) |
virtual ushort | transfer (char *s, void *buffer, TVTransfer flag) |
Boolean | validate (const char *s) |
Static Public Methods | |
TStreamable* | build () |
Public Attributes | |
ushort | status |
ushort | options |
Static Public Attributes | |
const char* const | name |
Protected Methods | |
TValidator (StreamableInit) | |
virtual void | write (opstream &os) |
virtual void* | read (ipstream &is) |
Definition at line 45 of file validate.h.
|
Undocumented. |
|
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. |
|
Called to create an object in certain stream-reading situations. Reimplemented in TPXPictureValidator, TFilterValidator, TRangeValidator, TLookupValidator, and TStringLookupValidator. |
|
This is an abstract method called by validate() when it detects that the user has entered invalid information. By default, error() does nothing, but descendant types can override it to provide feedback to the user. Reimplemented in TPXPictureValidator, TFilterValidator, TRangeValidator, and TStringLookupValidator. |
|
By default, isValid() returns True. Descendant validator types can override isValid() to validate data for a completed input line. If an input line has an associated validator object, its TInputLine::valid() method calls the validator object's validate() method, which in turn calls isValid() to determine whether the contents of the input line are valid. Reimplemented in TPXPictureValidator, TFilterValidator, TRangeValidator, and TLookupValidator. |
|
If an input line has an associated validator object, it calls isValidInput() after processing each keyboard event. This gives validators such as filter validators an opportunity to catch errors before the user fills the entire item or screen. By default, isValidInput() returns True. Descendant data validators can override isValidInput() to validate data as the user types it, returning True if `s' holds valid data and False otherwise. `s' is the current input string. `suppressFill' determines whether the validator should automatically format the string before validating it. If `suppressFill' is True, validation takes place on the unmodified string `s'. If `suppressFill' is False, the validator should apply any filling or padding before validating data. Of the standard validator objects, only TPXPictureValidator checks `suppressFill'. Because `s' is passed by pointer, isValidInput() can modify the contents of the input string, such as forcing characters to uppercase or inserting literal characters from a format picture. isValidInput() should not, however, delete invalid characters from the string. By returning False, isValidInput() indicates that the input line should erase the offending characters. Reimplemented in TPXPictureValidator, and TFilterValidator. |
|
Reads from the input stream `is'. Reimplemented from TStreamable. Reimplemented in TPXPictureValidator, TFilterValidator, TRangeValidator, and TStringLookupValidator. |
|
transfer() allows a validator to take over setting and reading the values of its associated input line, which is mostly useful for validators that check non-string data, such as numeric values. For example, TRangeValidator uses transfer() to read and write long int type values to a data record, rather than transferring an entire string. By default, input lines with validators give the validator the first chance to respond to TInputLine::dataSize(), TInputLine::getData(), and @TInputLine::setData() by calling the validator's transfer() method. If transfer() returns anything other than 0, it indicates to the input line that it has handled the appropriate transfer. The default action of transfer() is to return 0 always. If you want the validator to transfer data, you need to override its transfer() method. transfer()'s first two parameters are the associated input line's text string and the getData() or setData() data record. Depending on the value of `flag', transfer() can set `s' from `buffer' or read the data from `s' into `buffer'. The return value is always the number of bytes transferred. If `flag' is vtDataSize, transfer() doesn't change either `s' or `buffer', but just returns the data size. If `flag' is vtSetData, Transfer reads the appropriate number of bytes from `buffer', converts them into the proper string form, and sets them into `s', returning the number of bytes read. If `flag' is vtGetData, transfer() converts `s' into the appropriate data type and writes the value into `buffer', returning the number of bytes written.
enum TVTransfer {vtDataSize, vtSetData, vtGetData}; Validator objects use parameters of type TVTransfer in their transfer() methods to control data transfer when setting or reading the value of the associated input line. Reimplemented in TRangeValidator. |
|
Returns True if isValid(s) returns True. Otherwise calls error() and returns False. A validator's validate() method is called by the TInputLine::valid() method of its associated input line. Input lines with associated validator objects call the validator's validate() method under two conditions: either the input line has its ofValidate option set, in which case it calls validate() when it loses focus, or the dialog box that contains the input line calls validate() for all its controls, usually because the user requested to close the dialog box or accept an entry screen. |
|
Writes to the output stream `os'. Reimplemented from TStreamable. Reimplemented in TPXPictureValidator, TFilterValidator, TRangeValidator, and TStringLookupValidator. |
|
Undocumented. Reimplemented in TPXPictureValidator, TFilterValidator, TRangeValidator, TLookupValidator, and TStringLookupValidator. Definition at line 227 of file validate.h. |
|
This is a bitmapped field used to control options for various descendants of TValidator. By default, TValidator constructor clears all the bits in options. Constants voXXXX represent the bits in the bitmapped options word in validator objects.
Constant Value Meaning voFill 0x0001 Used by picture validators to indicate whether to fill in literal characters as the user types voTransfer 0x0002 The validator handles data transfer for the input line; currently only used by range validators voReserved 0x00fc The bits in this mask are reserved by Borland Definition at line 200 of file validate.h. |
|
Indicates the status of the validator object. If status is vsOK, the validator object constructed correctly. Any value other than vsOK indicates that an error occurred. Input line objects use vsOK to check that their associated validator objects were constructed properly. When called with a command parameter of cmValid, an input line object's TInputLine::valid() method checks its validator's status field. If status data member is vsOK, the input line's valid() returns True, indicating that the validator object is ready to use. The only value defined for status other than vsOK is vsSyntax, used by TPXPictureValidator to indicate that it could not interpret the picture string passed to it. If you create your own validator objects, you can define error codes and pass them in the status field.
Constant Value Meaning vsOK 0 Validator constructed properly vsSyntax 1 Error in the syntax of a picture validator's picture Definition at line 179 of file validate.h. |