This class implements the BPS mask validator for input text. More...
Public Member Functions | |
QString | fixup (const QString &aInput) const |
Fix up the input if possible. More... | |
Boolean | isValid (QString &aInput) const |
Check for valid input. More... | |
MaskProcessor () | |
Default constructor. More... | |
MaskProcessor (String aMask) | |
Constructor taking an initiam mask as argument. More... | |
Properties | |
String | mask |
The current mask. More... | |
Number | maxLength |
The maximum length in characters. More... | |
Number | minLength |
The minimum length in characters. More... | |
This class implements the BPS mask validator for input text.
A mask is a QString containing the characters defined in the following table.
Mask char | Allowed input chars | Notes |
---|---|---|
A,a | A-Z a-z | ASCII alphabetic characters |
C,c | A-Z a-z 0-9 | ASCII alphabetic characters and digits |
W,w | A-Z a-z 0-9 - _ $ | Words |
F,f | A-Z a-z 0-9 - _ $ . | Filenames (words and dots) |
G,g | A-Z a-z 0-9 - _ $ . space | Filenames with spaces |
P,p | A-Z a-z 0-9 - _ $ . / | Pathnames (filenames and slashes) |
Q,q | A-Z a-z 0-9 - _ $ . / space | Pathnames with spaces |
X,x | All printable characters | No whitespace |
Y,y | All printable characters | Including whitespace |
S,s | + - | Plus or minus sign |
D,d | 0-9 | Decimal digits |
B,b | 0 1 | Binary digits |
H,h | 0-9 a-f A-F | Hexadecimal digits |
N,n | 0-9 | Formatted numbers: Upper case N's are interpreted as minimum number of digits to enter during input, followed by lower case n's to complete to the maximum number of digits. So NnnNNnn will be interpreted as two numbers, where the first is 3 digits long and 1 must be entered at least, and the second is 4 digits while 2 of them must be entered at least. |
> | Convert following input to upper case. | |
< | Convert following input to lower case. | |
! | Switch off case conversion. | |
\ | Do not interpret the next char as mask, use it as filler. | |
Other char | Filler | Insert exactly as written in mask. The user can omit input, it will be inserted automatically. |
Examples:
Mask | User input | Result after fixup |
---|---|---|
nnnn.nnn.nnn.nn | 1 | 1000.000.000.00 |
1.1.12.5 | 0001.001.012.05 | |
.23..6 | 0000.023.000.06 | |
0000.000.000.00 | ||
123456 | 1234.056.000.00 | |
NNnnNNNnnn | 1 | 0001000000 |
12345 | 1234000005 | |
123456 | 1234000056 | |
12345678 | 1234005678 | |
Ddd-Bnn | 1a | 1-A00 |
10k5 | 10-K05 |
bps::MaskProcessor::MaskProcessor | ( | ) |
Default constructor.
The initial mask is empty.
bps::MaskProcessor::MaskProcessor | ( | String | aMask | ) |
Constructor taking an initiam mask as argument.
aMask | The initial mask to use. |
QString bps::MaskProcessor::fixup | ( | const QString & | aInput | ) | const |
Fix up the input if possible.
This will remove all invalid characters and format all n/N sequences.
aInput | The unprocessed string |
Boolean bps::MaskProcessor::isValid | ( | QString & | aInput | ) | const |
Check for valid input.
aInput | The input to check. |
|
readwrite |
The current mask.
|
read |
The maximum length in characters.
Gets computed when mask is set.
|
read |
The minimum length in characters.
Gets computed when mask is set.