25 auto const material_ids_strings =
28 std::vector<int> material_ids;
29 for (
auto& mid_str : material_ids_strings)
31 std::size_t num_chars_processed = 0;
35 material_id = std::stoi(mid_str, &num_chars_processed);
37 catch (std::invalid_argument&)
40 "Could not parse material ID from '{}' to a valid integer.",
43 catch (std::out_of_range&)
46 "Could not parse material ID from '{}'. The integer value of "
47 "the given string exceeds the permitted range.",
51 if (num_chars_processed != mid_str.size())
54 if (
auto const it = std::find_if_not(
55 begin(mid_str) + num_chars_processed, end(mid_str),
56 [](
unsigned char const c) {
return std::isspace(c); });
60 "Could not parse material ID from '{}'. Please separate "
61 "multiple material IDs by comma only. Invalid character: "
62 "'{}' at position {}.",
63 mid_str, *it, distance(begin(mid_str), it));
67 material_ids.push_back(material_id);