BPS C++ API  2.24.4
BpsMaskProcessor Class Reference

This class implements the BPS mask validator for input text. More...

#include <bpsmaskprocessor.h>

Public Member Functions

 BpsMaskProcessor ()
 Default constructor.
 
 BpsMaskProcessor (const QString &aMask)
 
QString fixup (const QString &aInput) const
 Fix up the input if possible. More...
 
QString mask () const
 
int maxLength () const
 Returns the maximum input length (including fillers)
 
int minLength () const
 Returns the minimum input length (including fillers)
 
void setMask (const QString &aMask)
 Set the new mask. More...
 
bool validate (QString &aInput, int &aPos) const
 Validate input and remove invalid inputs. More...
 

Detailed Description

This class implements the BPS mask validator for input text.

A mask is a QString containing the characters defined in the following table.

  • Upper case mask chars stand for mandatory input.
  • Lower case mask chars are optional inputs which may be skipped at input.
  • Mask characters can be repeated by appending the count in curly brackets, for example x{5} is equivalent to xxxxx
Mask charAllowed input charsNotes
A,aA-Z a-zASCII alphabetic characters
B,b0 1Binary digits
C,cA-Z a-z 0-9ASCII alphabetic characters and digits
D,d0-9Decimal digits
F,fA-Z a-z 0-9 - _ $ .Filenames (words and dots)
G,gA-Z a-z 0-9 - _ $ . spaceFilenames with spaces
H,h0-9 a-f A-FHexadecimal digits
I,i0-9 - , Comma separated list of integers
J,j0-9 - . ,Comma separated list of floats
N,n0-9Formatted 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.
P,pA-Z a-z 0-9 - _ $ . /Pathnames (filenames and slashes)
Q,qA-Z a-z 0-9 - _ $ . / spacePathnames with spaces
S,s+ -Plus or minus sign
W,wA-Z a-z 0-9 - _ $Words
X,xAll printable charactersNo whitespace
Y,yAll printable charactersIncluding whitespace
> 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 charFillerInsert exactly as written in mask.
The user can omit input, it will be inserted automatically.

Examples:

MaskUser inputResult after fixup
nnnn.nnn.nnn.nn11000.000.000.00
1.1.12.50001.001.012.05
.23..60000.023.000.06
 0000.000.000.00
1234561234.056.000.00
NNnnNNNnnn10001000000
123451234000005
1234561234000056
123456781234005678
Ddd-Bnn1a1-A00
10k510-K05

Constructor & Destructor Documentation

◆ BpsMaskProcessor()

BpsMaskProcessor::BpsMaskProcessor ( const QString aMask)
Parameters
aMaskThe mask.

Member Function Documentation

◆ fixup()

QString BpsMaskProcessor::fixup ( const QString aInput) const

Fix up the input if possible.

This will remove all invalid characters and format all n/N sequences.

Parameters
aInputThe unprocessed string
Returns
The fixed up string

◆ mask()

QString BpsMaskProcessor::mask ( ) const
Returns
The current mask.

◆ setMask()

void BpsMaskProcessor::setMask ( const QString aMask)

Set the new mask.

Parameters
aMaskThe new mask to set

◆ validate()

bool BpsMaskProcessor::validate ( QString aInput,
int &  aPos 
) const

Validate input and remove invalid inputs.

Parameters
aInputThe input to validate.
aPosThe cursor position.
Returns
True when the input is acceptable.

The documentation for this class was generated from the following file: