15 #ifndef INCG_IRIS_IUTEST_GENPARAMS_FROM_FILE_HPP_81CDA6E7_945B_4F72_873B_104264DF7132_
16 #define INCG_IRIS_IUTEST_GENPARAMS_FROM_FILE_HPP_81CDA6E7_945B_4F72_873B_104264DF7132_
18 #if IUTEST_HAS_CSVPARAMS
29 class iuCsvFileParamsGenerator :
public iuValuesInParamsGenerator<T>
31 typedef ::std::vector<T> params_t;
38 explicit iuCsvFileParamsGenerator(const ::std::string& path,
char delimiter =
',')
39 : iuValuesInParamsGenerator<T>(ReadParams(path, delimiter))
44 void AppendParams(params_t& params, const ::std::string& data)
46 if( StringIsBlank(data) )
51 if( !StringToValue(data, param) )
55 params.push_back(param);
57 params_t ReadParams(const ::std::string& path,
char delimiter =
',')
60 IFile* fp = detail::IFileSystem::New();
63 const ::std::string dataset = fp->ReadAll();
64 ::std::string::size_type prev = 0;
65 ::std::string::size_type pos = 0;
66 while(
static_cast<void>(pos = dataset.find(delimiter, prev)), pos != ::std::string::npos )
68 const ::std::string data = dataset.substr(prev, pos - prev);
69 AppendParams(params, data);
73 AppendParams(params, dataset.substr(prev));
77 IUTEST_LOG_(WARNING) <<
"Empty params file \"" << path <<
"\".";
82 IUTEST_LOG_(WARNING) <<
"Unable to open file \"" << path <<
"\".";
84 detail::IFileSystem::Free(fp);
94 #endif // INCG_IRIS_IUTEST_GENPARAMS_FROM_FILE_HPP_81CDA6E7_945B_4F72_873B_104264DF7132_