+ switch (variable->type) {
+ case xbt_cfgelm_string:
+ xbt_cfg_set_string(cfg, key, value); /* throws */
+ break;
+
+ case xbt_cfgelm_int:
+ i = strtol(value, &ret, 0);
+ if (ret == value) {
+ xbt_die("Value of option %s not valid. Should be an integer", key);
+ }
+
+ xbt_cfg_set_int(cfg, key, i); /* throws */
+ break;
+
+ case xbt_cfgelm_double:
+ d = strtod(value, &ret);
+ if (ret == value) {
+ xbt_die("Value of option %s not valid. Should be a double", key);
+ }
+
+ xbt_cfg_set_double(cfg, key, d); /* throws */
+ break;
+
+ case xbt_cfgelm_boolean:
+ xbt_cfg_set_boolean(cfg, key, value); /* throws */
+ ret = (char *)value + strlen(value);
+ break;
+
+ default:
+ THROWF(unknown_error, 0, "Type of config element %s is not valid.", key);
+ break;
+ }
+
+ return ret;
+}
+
+/** @brief Set an integer value to \a name within \a cfg if it wasn't changed yet
+ *
+ * This is useful to change the default value of a variable while allowing
+ * users to override it with command line arguments
+ */
+void xbt_cfg_setdefault_int(xbt_cfg_t cfg, const char *name, int val)
+{
+ xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_int);
+
+ if (variable->isdefault){
+ xbt_cfg_set_int(cfg, name, val);
+ variable->isdefault = 1;
+ }
+ else
+ XBT_DEBUG
+ ("Do not override configuration variable '%s' with value '%d' because it was already set.",
+ name, val);
+}
+
+/** @brief Set an integer value to \a name within \a cfg if it wasn't changed yet
+ *
+ * This is useful to change the default value of a variable while allowing
+ * users to override it with command line arguments
+ */
+void xbt_cfg_setdefault_double(xbt_cfg_t cfg, const char *name, double val)
+{
+ xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_double);
+
+ if (variable->isdefault) {
+ xbt_cfg_set_double(cfg, name, val);
+ variable->isdefault = 1;
+ }
+ else
+ XBT_DEBUG
+ ("Do not override configuration variable '%s' with value '%f' because it was already set.",
+ name, val);
+}
+
+/** @brief Set a string value to \a name within \a cfg if it wasn't changed yet
+ *
+ * This is useful to change the default value of a variable while allowing
+ * users to override it with command line arguments
+ */
+void xbt_cfg_setdefault_string(xbt_cfg_t cfg, const char *name,
+ const char *val)
+{
+ xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_string);
+
+ if (variable->isdefault){
+ xbt_cfg_set_string(cfg, name, val);
+ variable->isdefault = 1;
+ }
+ else
+ XBT_DEBUG
+ ("Do not override configuration variable '%s' with value '%s' because it was already set.",
+ name, val);
+}
+
+
+/** @brief Set an boolean value to \a name within \a cfg if it wasn't changed yet
+ *
+ * This is useful to change the default value of a variable while allowing
+ * users to override it with command line arguments
+ */
+void xbt_cfg_setdefault_boolean(xbt_cfg_t cfg, const char *name, const char *val)
+{
+ xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_boolean);
+
+ if (variable->isdefault){
+ xbt_cfg_set_boolean(cfg, name, val);
+ variable->isdefault = 1;
+ }
+ else
+ XBT_DEBUG
+ ("Do not override configuration variable '%s' with value '%s' because it was already set.",
+ name, val);