-/* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2023. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
unit_scale::unit_scale(std::initializer_list<std::tuple<const std::string, double, int, bool>> generators)
{
- for (const auto& gen : generators) {
- const std::string& unit = std::get<0>(gen);
- double value = std::get<1>(gen);
- const int base = std::get<2>(gen);
- const bool abbrev = std::get<3>(gen);
+ for (auto [unit, value, base, abbrev] : generators) {
double mult;
std::vector<std::string> prefixes;
switch (base) {
double res = strtod(string.c_str(), &endptr);
const char* ptr = endptr; // for const-correctness
if (errno == ERANGE)
- throw simgrid::ParseError(filename, lineno, std::string("value out of range: ") + string);
+ throw simgrid::ParseError(filename, lineno, "value out of range: " + string);
if (ptr == string)
- throw simgrid::ParseError(filename, lineno, std::string("cannot parse number:") + string);
+ throw simgrid::ParseError(filename, lineno, "cannot parse number:" + string);
if (ptr[0] == '\0') {
// Ok, 0 can be unit-less
if (res != 0 && not entity_kind.empty())
const std::string& entity_kind)
{
std::vector<double> speed_per_pstate;
+ std::vector<std::string> pstate_list;
- if (speeds.find('.') == std::string::npos) {
- double speed = xbt_parse_get_speed(filename, lineno, speeds, entity_kind);
+ boost::split(pstate_list, speeds, boost::is_any_of(","));
+ for (auto speed_str : pstate_list) {
+ boost::trim(speed_str);
+ double speed = xbt_parse_get_speed(filename, lineno, speed_str, entity_kind);
speed_per_pstate.push_back(speed);
- } else {
- std::vector<std::string> pstate_list;
- boost::split(pstate_list, speeds, boost::is_any_of(","));
- for (auto speed_str : pstate_list) {
- boost::trim(speed_str);
- double speed = xbt_parse_get_speed(filename, lineno, speed_str, entity_kind);
- speed_per_pstate.push_back(speed);
- XBT_DEBUG("Speed value: %f", speed);
- }
+ XBT_DEBUG("Speed value: %f", speed);
}
+
return speed_per_pstate;
}