11#include <boost/algorithm/string/case_conv.hpp>
20Logger
g_log(
"FileValidator");
29 : TypedValidator<
std::string>(), m_testExist(testFileExists) {
30 for (
const auto &extension : extensions) {
31 const std::string ext = boost::to_lower_copy(extension);
54 if (!Poco::Path().tryParse(
value)) {
55 return "Error in path syntax: \"" +
value +
"\".";
60 if (!(
value.empty())) {
76 std::string abspath(
value);
78 Poco::Path path(
value);
79 if (path.isAbsolute())
80 abspath = path.toString();
85 return "File \"" + abspath +
"\" not found";
90 in.open(
value.c_str());
92 std::stringstream
error;
93 error <<
"Failed to open " +
value +
": " << strerror(errno);
111 if (
value.length() < ending.length())
113 int result =
value.compare(
value.length() - ending.length(), ending.length(), ending);
114 return (result == 0);
129 std::string value_copy(
value);
130 std::transform(value_copy.begin(), value_copy.end(), value_copy.begin(), tolower);
double value
The value of the point.
bool m_testExist
Flag indicating whether to test for existence of filename.
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.
bool endswith(const std::string &value) const
Checks the extension of a filename.
std::vector< std::string > m_extensions
The list of permitted extensions.
std::vector< std::string > allowedValues() const override
Returns the set of valid values.
IValidator_sptr clone() const override
Clone the validator.
FileValidator(const std::vector< std::string > &extensions=std::vector< std::string >(), bool testFileExists=true)
Constructor.
void debug(const std::string &msg)
Logs at debug level.
bool exists(::NeXus::File &file, const std::string &name)
Based on the current group in the file, does the named sub-entry exist?
Logger g_log("DateAndTime")
bool has_ending(const std::string &value, const std::string &ending)
Confirm that the value string ends with then ending string.
std::shared_ptr< IValidator > IValidator_sptr
A shared_ptr to an IValidator.