Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
Mantid::Kernel::FileValidator Class Reference

FileValidator is a validator that checks that a filepath is valid. More...

#include <FileValidator.h>

Inheritance diagram for Mantid::Kernel::FileValidator:
Mantid::Kernel::DirectoryValidator

Public Member Functions

std::vector< std::string > allowedValues () const override
 Returns the set of valid values. More...
 
IValidator_sptr clone () const override
 Clone the validator. More...
 
 FileValidator (const std::vector< std::string > &extensions=std::vector< std::string >(), bool testFileExists=true)
 Constructor. More...
 

Protected Attributes

std::vector< std::string > m_extensions
 The list of permitted extensions. More...
 
bool m_testExist
 Flag indicating whether to test for existence of filename. More...
 

Private Member Functions

std::string checkValidity (const std::string &value) const override
 If m_fullTest=true if checks that the files exists, otherwise just that path syntax looks valid. More...
 
bool endswith (const std::string &value) const
 Checks the extension of a filename. More...
 

Detailed Description

FileValidator is a validator that checks that a filepath is valid.

Author
Matt Clarke, ISIS.
Date
25/06/2008

Definition at line 25 of file FileValidator.h.

Constructor & Destructor Documentation

◆ FileValidator()

Mantid::Kernel::FileValidator::FileValidator ( const std::vector< std::string > &  extensions = std::vector<std::string>(),
bool  testFileExists = true 
)
explicit

Constructor.

Parameters
extensions:: The permitted file extensions (e.g. .RAW)
testFileExists:: Flag indicating whether to test for existence of file (default: yes)

Definition at line 28 of file FileValidator.cpp.

References m_extensions.

Member Function Documentation

◆ allowedValues()

std::vector< std::string > Mantid::Kernel::FileValidator::allowedValues ( ) const
override

Returns the set of valid values.

Definition at line 39 of file FileValidator.cpp.

References m_extensions.

Referenced by Mantid::Kernel::MultiFileValidator::allowedValues().

◆ checkValidity()

std::string Mantid::Kernel::FileValidator::checkValidity ( const std::string &  value) const
overrideprivate

If m_fullTest=true if checks that the files exists, otherwise just that path syntax looks valid.

Parameters
value:: file name
Returns
An error message to display to users or an empty string on no error

Definition at line 52 of file FileValidator.cpp.

References Mantid::Kernel::Logger::debug(), endswith(), error, Mantid::DataHandling::exists(), Mantid::Kernel::DateAndTimeHelpers::g_log, m_extensions, m_testExist, and value.

◆ clone()

IValidator_sptr Mantid::Kernel::FileValidator::clone ( ) const
override

Clone the validator.

Returns
A pointer to a new validator with the same properties as this one

Definition at line 45 of file FileValidator.cpp.

◆ endswith()

bool Mantid::Kernel::FileValidator::endswith ( const std::string &  value) const
private

Checks the extension of a filename.

Parameters
value:: the filename to check
Returns
flag that true if the extension matches in the filename

Definition at line 122 of file FileValidator.cpp.

References Mantid::Kernel::has_ending(), m_extensions, and value.

Referenced by checkValidity().

Member Data Documentation

◆ m_extensions

std::vector<std::string> Mantid::Kernel::FileValidator::m_extensions
protected

The list of permitted extensions.

Definition at line 34 of file FileValidator.h.

Referenced by allowedValues(), checkValidity(), endswith(), and FileValidator().

◆ m_testExist

bool Mantid::Kernel::FileValidator::m_testExist
protected

Flag indicating whether to test for existence of filename.

Definition at line 36 of file FileValidator.h.

Referenced by Mantid::Kernel::DirectoryValidator::checkValidity(), checkValidity(), and Mantid::Kernel::DirectoryValidator::DirectoryValidator().


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