#include <validate.h>
Inheritance diagram for TPXPictureValidator::
Public Methods | |
TPXPictureValidator (const char *aPic, Boolean autoFill) | |
~TPXPictureValidator () | |
virtual void | error () |
virtual Boolean | isValidInput (char *s, Boolean suppressFill) |
virtual Boolean | isValid (const char *s) |
virtual TPicResult | picture (char *input, Boolean autoFill) |
Static Public Methods | |
TStreamable* | build () |
Static Public Attributes | |
const char* const | name |
Protected Methods | |
TPXPictureValidator (StreamableInit) | |
virtual void | write (opstream &os) |
virtual void* | read (ipstream &is) |
Protected Attributes | |
char* | pic |
For a complete description of picture specifiers see method TPXPictureValidator::picture()
Definition at line 254 of file validate.h.
|
Constructs a picture validator object by first calling the constructor inherited from TValidator, then allocating a copy of `aPic' on the heap and setting pic data member to point to it, then setting the voFill bit in TValidator::options data member if `autoFill' is True. |
|
Disposes of the string pointed to by pic data member, then disposes of the picture validator object by calling the destructor inherited from TValidator. |
|
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 from TValidator. |
|
Displays a message box indicating an error in the picture format, displaying the string pointed to by pic data member. Reimplemented from TValidator. |
|
Compares the string passed in `s' with the format picture specified in pic data member and returns True if pic is null or if picture() returns prComplete for `s', indicating that `s' needs no further input to meet the specified format. Reimplemented from TValidator. |
|
Checks the string passed in `s' against the format picture specified in pic data member and returns True if pic is null or picture() does not return prError for `s'; otherwise returns False. The `suppressFill' parameter overrides the value in voFill for the duration of the call to isValidInput(). `s' is a pointer to string, so isValidInput() can modify its value. For example, if `suppressFill' is False and voFill is set, the call to picture() returns a filled string based on `s', so the image in the input line automatically reflects the format specified in pic. Reimplemented from TValidator. |
|
Formats the string passed in `input' according to the format specified by the picture string pointed to by pic data member. Returns prError if there is an error in the picture string or if `input' contains data that cannot fit the specified picture. Returns prComplete if `input' can fully satisfy the specifed picture. Returns prIncomplete if `input' contains data that fits the specified picture but not completely. The following table shows the characters used in creating format pictures.
Type of character Character Description Special # Accept only a digit ? Accept only a letter (case-insensitive) & Accept only a letter, force to uppercase @ Accept any character ! Accept any character, force to uppercase Match ; Take next character literally * Repetition count [] Option {} Grouping operators , Set of alternatives All others Taken literally Here are some advanced pictures, which show the power of TPXPictureValidator; these examples come from an old Pascal FAQ written by Berend de Boer, <berend@beard.nest.nl>.
Name Value Description UnsignedPic1 #[#][#]*{[;,]###} unsigned int with optional commas UnsignedPic2 #[#][#]*{;,###} unsigned int with commas SignedPic1 [-]#[#][#]*{[;,]###} signed int with optional commas SignedPic2 [-]#[#][#]*{;,###} signed int with commas MoneyPic1 [$]*#.{##,00} dollars, with comma and optinal dollar sign MoneyPic2 $*#{.##,.00} dollars, with comma and dollar sign DatePic1 #[#]/#[#]/## date with 2 digit year (dd/mm/yy or mm/dd/yy) DatePic2 #[#]/#[#]/##[##] date with 2 or 4 digit year (mm/dd/yy or mm/dd/yyyy) DatePic3 #[#]/#[#]/#### date with 4 digit year (mm/dd/yyyy) TimePic1 {##}:{##}[:{##}] HH:MM:SS with optional seconds TimePic2 {##}:{##}:{##} HH:MM:SS PhonePic1 [(###) ]###-#### phone number with optional area code PhonePic2 (###) ###-#### phone number with area code SSNPic ###-##-#### FirstCharUpPic *{&*? } uppercase the first char of every word FilenamePic {&*7[&]}.{*3[&]} filename (no path) with extension Note the *7 and *3 in this last example. A number after a `*' says how many times the next sequence should be repeated; uncovered in the manuals. But this example is not completely correct (is this a bug?), because the `*' is interpreted as that there should be exactly 8 characters! No more, no less. Correct is:
FilenamePic {&[&][&][&][&][&][&][&]}.{[&][&][&]} The following examples were given by Sean Wenzel in the Borland Turbo Vision forum on CompuServe:
[-]#[*#][[.]#[*#]][E[-]#[#]] |
|
Reads from the input stream `is'. Reimplemented from TValidator. |
|
Writes to the output stream `os'. Reimplemented from TValidator. |
|
Undocumented. Reimplemented from TValidator. Definition at line 459 of file validate.h. |
|
Points to a string containing the picture that specifies the format for data in the associated input line. The constructor sets pic to the string passed as one of its parameters. Definition at line 401 of file validate.h. |