Class DimensionValidator

Class Documentation

class DimensionValidator

The interface to a class that validates dimensions.

Note that this class is only expected to be used by the ValidationContext class.

This validator can function across multiple matrices. Add matrices and expected dimensions with a dim() function. After all matrices have been loaded, call perform_validation() to validate all of the matrices.

Public Functions

DimensionValidator()
~DimensionValidator()
DimensionValidator(const DimensionValidator &other) = delete

Deleted to prevent pointer invalidation.

DimensionValidator(DimensionValidator &&other) = delete

Deleted to prevent pointer invalidation.

DimensionValidator &operator=(const DimensionValidator &other) = delete

Deleted to prevent pointer invalidation.

DimensionValidator &operator=(DimensionValidator &&other) = delete

Deleted to prevent pointer invalidation.

void dim(const std::string &name, const Matrix &matrix, Size rows, Size cols)

Provide a matrix, name, and dimensions to validate.

Validation is not done here. After all matrices are loaded, call perform_validation().

Parameters
  • name – The name of the matrix to show in errors.

  • matrix – The matrix to validate.

  • rows – The desired number of rows in the matrix.

  • cols – The desired number of columns in the matrix.

void dim(const std::string &name, const Matrix &matrix, Size rows, char cols)

Provide a matrix, name, and dimensions to validate.

Validation is not done here. After all matrices are loaded, call perform_validation().

Parameters
  • name – The name of the matrix to show in errors.

  • matrix – The matrix to validate.

  • rows – The desired number of rows in the matrix.

  • cols – Variable name for number of columns in the matrix.

void dim(const std::string &name, const Matrix &matrix, char rows, Size cols)

Provide a matrix, name, and dimensions to validate.

Validation is not done here. After all matrices are loaded, call perform_validation().

Parameters
  • name – The name of the matrix to show in errors.

  • matrix – The matrix to validate.

  • rows – Variable name for number of rows in the matrix.

  • cols – The desired number of columns in the matrix.

void dim(const std::string &name, const Matrix &matrix, char rows, char cols)

Provide a matrix, name, and dimensions to validate.

Validation is not done here. After all matrices are loaded, call perform_validation().

Parameters
  • name – The name of the matrix to show in errors.

  • matrix – The matrix to validate.

  • rows – Variable name for number of rows in the matrix.

  • cols – Variable name for number of columns in the matrix.

void perform_validation(ErrorMode mode, ValidationResult &result_out)

Check matrices against set rules and populate the given ValidationResult, optionally throwing an exception or logging an error in the case of a bad result.

Parameters
  • mode – How to behave when validation fails.

  • result_out – Reference that will be set to ValidationResult::GOOD or ValidationResult::BAD depending on the outcome of validation. This is an out parameter, rather than a return value, to ensure its value is written before any exception is thrown.

Throws

std::range_error – if dimension validation fails and mode is ErrorMode::DIE.