/*
* Helping functions
*/
-void surf_parse_assert(bool cond, const char *fmt, ...) {
+void surf_parse_assert(bool cond, std::string msg)
+{
if (not cond) {
- va_list va;
- va_start(va,fmt);
int lineno = surf_parse_lineno;
- char *msg = bvprintf(fmt,va);
- va_end(va);
cleanup();
- XBT_ERROR("Parse error at %s:%d: %s", surf_parsed_filename, lineno, msg);
+ XBT_ERROR("Parse error at %s:%d: %s", surf_parsed_filename, lineno, msg.c_str());
surf_exit();
xbt_die("Exiting now");
}
}
-void surf_parse_error(const char *fmt, ...) {
- va_list va;
- va_start(va,fmt);
+void surf_parse_error(std::string msg)
+{
int lineno = surf_parse_lineno;
- char *msg = bvprintf(fmt,va);
- va_end(va);
cleanup();
- XBT_ERROR("Parse error at %s:%d: %s", surf_parsed_filename, lineno, msg);
+ XBT_ERROR("Parse error at %s:%d: %s", surf_parsed_filename, lineno, msg.c_str());
surf_exit();
xbt_die("Exiting now");
}
+
void surf_parse_assert_netpoint(char* hostname, const char* pre, const char* post)
{
if (sg_netpoint_by_name_or_null(hostname) != nullptr) // found
break;
}
}
- surf_parse_error("%s", msg.c_str());
+ surf_parse_error(msg);
}
void surf_parse_warn(const char *fmt, ...) {
double res;
int ret = sscanf(string, "%lg", &res);
if (ret != 1)
- surf_parse_error("%s is not a double", string);
+ surf_parse_error(std::string(string) + " is not a double");
return res;
}
int res;
int ret = sscanf(string, "%d", &res);
if (ret != 1)
- surf_parse_error("%s is not an integer", string);
+ surf_parse_error(std::string(string) + " is not an integer");
return res;
}
end = surf_parse_get_int((radical_ends.back()).c_str());
break;
default:
- surf_parse_error("Malformed radical: %s", group.c_str());
+ surf_parse_error(std::string("Malformed radical: ") + group);
break;
}
for (int i = start; i <= end; i++)
errno = 0;
double res = strtod(string, &ptr);
if (errno == ERANGE)
- surf_parse_error("value out of range: %s", string);
+ surf_parse_error(std::string("value out of range: ") + string);
if (ptr == string)
- surf_parse_error("cannot parse number: %s", string);
+ surf_parse_error(std::string("cannot parse number:") + string);
if (ptr[0] == '\0') {
if (res == 0)
return res; // Ok, 0 can be unit-less
if (units[i].unit != nullptr)
res *= units[i].scale;
else
- surf_parse_error("unknown unit: %s", ptr);
+ surf_parse_error(std::string("unknown unit: ") + ptr);
return res;
}
cluster.topology= SURF_CLUSTER_DRAGONFLY ;
break;
default:
- surf_parse_error("Invalid cluster topology for cluster %s",
- cluster.id);
+ surf_parse_error(std::string("Invalid cluster topology for cluster ") + cluster.id);
break;
}
cluster.topo_parameters = A_surfxml_cluster_topo___parameters;
cluster.sharing_policy = SURF_LINK_FATPIPE;
break;
default:
- surf_parse_error("Invalid cluster sharing policy for cluster %s", cluster.id);
+ surf_parse_error(std::string("Invalid cluster sharing policy for cluster ") + cluster.id);
break;
}
switch (AX_surfxml_cluster_bb___sharing___policy) {
cluster.bb_sharing_policy = SURF_LINK_SHARED;
break;
default:
- surf_parse_error("Invalid bb sharing policy in cluster %s", cluster.id);
+ surf_parse_error(std::string("Invalid bb sharing policy in cluster ") + cluster.id);
break;
}
link.policy = SURF_LINK_FULLDUPLEX;
break;
default:
- surf_parse_error("Invalid sharing policy in link %s", link.id.c_str());
+ surf_parse_error(std::string("Invalid sharing policy in link ") + link.id);
break;
}
link = simgrid::surf::LinkImpl::byName(link_name);
break;
default:
- surf_parse_error("Invalid direction for link %s", link_name);
+ surf_parse_error(std::string("Invalid direction for link ") + link_name);
break;
}
xbt_free(link_name); // no-op if it's already nullptr
default:
dirname = "";
}
- surf_parse_assert(link != nullptr, "No such link: '%s'%s", A_surfxml_link___ctn_id, dirname);
+ surf_parse_assert(link != nullptr, std::string("No such link: '") + A_surfxml_link___ctn_id + "'" + dirname);
parsed_link_list.push_back(link);
}