-std::vector<s_smpi_factor_t> parse_factor(const std::string& smpi_coef_string)
-{
- std::vector<s_smpi_factor_t> smpi_factor;
-
- /** Setup the tokenizer that parses the string **/
- using Tokenizer = boost::tokenizer<boost::char_separator<char>>;
- boost::char_separator<char> sep(";");
- boost::char_separator<char> factor_separator(":");
- Tokenizer tokens(smpi_coef_string, sep);
-
- /**
- * Iterate over patterns like A:B:C:D;E:F;G:H
- * These will be broken down into:
- * A --> B, C, D
- * E --> F
- * G --> H
- */
- for (Tokenizer::iterator token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter) {
- XBT_DEBUG("token : %s", token_iter->c_str());
- Tokenizer factor_values(*token_iter, factor_separator);
- s_smpi_factor_t fact;
- xbt_assert(factor_values.begin() != factor_values.end(), "Malformed radical for smpi factor: '%s'",
- smpi_coef_string.c_str());
- unsigned int iteration = 0;
- for (Tokenizer::iterator factor_iter = factor_values.begin(); factor_iter != factor_values.end(); ++factor_iter) {
- iteration++;
-
- if (factor_iter == factor_values.begin()) { /* first element */
- try {
- fact.factor = std::stoi(*factor_iter);
- } catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid factor in chunk ") + std::to_string(smpi_factor.size() + 1) +
- ": " + *factor_iter);
- }
- } else {
- try {
- fact.values.push_back(
- xbt_parse_get_time(surf_parsed_filename, surf_parse_lineno, (*factor_iter).c_str(), "smpi factor", ""));
- } catch (const std::invalid_argument&) {
- throw std::invalid_argument(std::string("Invalid factor value ") + std::to_string(iteration) + " in chunk " +
- std::to_string(smpi_factor.size() + 1) + ": " + *factor_iter);
- }
- }
- }