/* This is useful to build named structs, like option or property sets. */
-/* Copyright (c) 2004-2013. The SimGrid Team.
+/* Copyright (c) 2004-2014. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
break;
default:
- XBT_ERROR("%d is an invalide type code", (int)type);
+ XBT_ERROR("%d is an invalid type code", (int)type);
}
xbt_dict_set((xbt_dict_t) * cfg, name, res, NULL);
/** @brief Unregister an element from a config set.
*
* @param cfg the config set
- * @param name the name of the elem to be freed
+ * @param name the name of the element to be freed
*
* Note that it removes both the description and the actual content.
* Throws not_found when no such element exists.
printf(" %s: %s\n", name, variable->desc);
printf(" Type: %s; ", xbt_cfgelm_type_name[variable->type]);
if (variable->min != 1 || variable->max != 1) {
- if (variable->min == 0 && variable->max == 0)
- printf("Arity: no bound; ");
+ printf("Arity: min:%d to max:", variable->min);
+ if (variable->max == 0)
+ printf("(no bound); ");
else
- printf("Arity: min:%d to max:%d; ", variable->min, variable->max);
+ printf("%d; ", variable->max);
}
size = xbt_dynar_length(variable->content);
printf("Current value%s: ", (size <= 1 ? "" : "s"));
size);
}
+ if (variable->isdefault && size > variable->min) {
+ xbt_dict_cursor_free(&cursor);
+ THROWF(mismatch_error, 0,
+ "Config elem %s theoretically accepts %d %s, but has a default of %d values.",
+ name, variable->min, xbt_cfgelm_type_name[variable->type], size);
+ }
+
if (variable->max > 0 && variable->max < size) {
xbt_dict_cursor_free(&cursor);
THROWF(mismatch_error, 0,
val = strchr(name, ':');
if (!val) {
/* don't free(optionlist_cpy) here, 'name' points inside it */
- xbt_die("Option '%s' badly formated. Should be of the form 'name:value'",
+ xbt_die("Option '%s' badly formatted. Should be of the form 'name:value'",
name);
}
*(val++) = '\0';
case xbt_cfgelm_boolean:
xbt_cfg_set_boolean(cfg, key, value); /* throws */
+ ret = (char *)value + strlen(value);
break;
case xbt_cfgelm_peer: