HAL
hal::StackedValidator Class Reference

Combines different validators into one. More...

#include <stacked_validator.h>

Inheritance diagram for hal::StackedValidator:
Inheritance graph
Collaboration diagram for hal::StackedValidator:
Collaboration graph

Public Member Functions

 StackedValidator ()
 
void addValidator (Validator *v)
 
void removeValidator (Validator *v)
 
void clearValidators ()
 
bool validate (const QString &input)
 
- Public Member Functions inherited from hal::Validator
void setFailText (const QString &text)
 
QString failText () const
 

Additional Inherited Members

- Protected Attributes inherited from hal::Validator
QString mFailText = "Chosen input is not allowed."
 

Detailed Description

Combines different validators into one.

The StackedValidator is a Validator that combines multiple other Validators. Its validate function returns true if all added Validators accept the string.
The fail text will be chosen from the firstly added validator which validation fails.

Definition at line 42 of file stacked_validator.h.

Constructor & Destructor Documentation

◆ StackedValidator()

hal::StackedValidator::StackedValidator ( )

Constructor. At this point the StackedValidator will accept any string. Therefore one should add validators by calling addValidator.

Definition at line 4 of file stacked_validator.cpp.

Member Function Documentation

◆ addValidator()

void hal::StackedValidator::addValidator ( Validator v)

Adds a Validator to the StackedValidator.

Parameters
v- The Validator to add

Definition at line 9 of file stacked_validator.cpp.

Referenced by hal::InputDialog::addValidator().

◆ clearValidators()

void hal::StackedValidator::clearValidators ( )

Removes all Validators from the StackedValidator.

Definition at line 19 of file stacked_validator.cpp.

Referenced by hal::InputDialog::clearValidators().

◆ removeValidator()

void hal::StackedValidator::removeValidator ( Validator v)

Removes a Validator from the StackedValidator.

Parameters
v- The Validator to remove

Definition at line 14 of file stacked_validator.cpp.

Referenced by hal::InputDialog::removeValidator().

◆ validate()

bool hal::StackedValidator::validate ( const QString input)
virtual

Given any string this function returns true iff the string is accepted by all registered Validators (added by StackedValidator:addValidator).

If no Validator is registered this function always returns true. If one or more Validators reject the string, the fail text of the failing Validator that was added the earliest will be chosen.

Parameters
input- The input string
Returns
true iff the string is considered valid (accepted by all validators)

Implements hal::Validator.

Definition at line 24 of file stacked_validator.cpp.

References hal::input, and hal::Validator::setFailText().


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