/** Checks that the files exist. The filenames of any files that dont exist * are returned in an error message, else the message is "". * * @param values :: a vector of vectors of file names * @returns An error message to display to users or an empty string on no error */ std::string MultiFileValidator::checkValidity( const std::vector<std::vector<std::string>> &values) const { if (values.empty()) return m_fileValidator.isValid(""); std::string accumulatedErrors(""); typedef std::vector<std::vector<std::string>>::const_iterator VecVecString_cIt; typedef std::vector<std::string>::const_iterator VecString_cIt; for (VecVecString_cIt rowIt = values.begin(); rowIt != values.end(); ++rowIt) { std::vector<std::string> row = (*rowIt); for (VecString_cIt valueIt = row.begin(); valueIt != row.end(); ++valueIt) { // For each filename value, check its validity, and and accumulate any // errors. std::string error = m_fileValidator.isValid(*valueIt); if (!error.empty()) { if (accumulatedErrors.empty()) accumulatedErrors = "Could not validate the following file(s): " + (*valueIt); else accumulatedErrors = accumulatedErrors + ", " + (*valueIt); } } } return accumulatedErrors; }
/** Checks that the files exist. The filenames of any files that dont exist * are returned in an error message, else the message is "". * * @param values :: a vector of vectors of file names * @returns An error message to display to users or an empty string on no error */ std::string MultiFileValidator::checkValidity( const std::vector<std::vector<std::string>> &values) const { if (values.empty()) return m_fileValidator.isValid(""); std::string accumulatedErrors(""); for (auto row : values) { for (const auto &valueIt : row) { // For each filename value, check its validity, and and accumulate any // errors. std::string error = m_fileValidator.isValid(valueIt); if (!error.empty()) { if (accumulatedErrors.empty()) accumulatedErrors = "Could not validate the following file(s): " + valueIt; else accumulatedErrors = accumulatedErrors + ", " + valueIt; } } } return accumulatedErrors; }