xbt_dict_set(simgrid_config, oldname, res, NULL);
}
-/** @brief Unregister an element from a config set.
- *
- * @param cfg the config set
- * @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.
- */
-void xbt_cfg_unregister(xbt_cfg_t cfg, const char *name)
-{
- XBT_DEBUG("Unregister elm '%s' from set %p", name, cfg);
- xbt_dict_remove((xbt_dict_t) cfg, name);
-}
-
/**
* @brief Parse a string and register the stuff described.
*
variable->isdefault = 0;
}
-/* ---- [ Removing ] ---- */
-/** @brief Remove the provided \e val integer value from a variable
- *
- * @param cfg the config set
- * @param name the name of the variable
- * @param val the value to be removed
- */
-void xbt_cfg_rm_int(xbt_cfg_t cfg, const char *name, int val)
-{
- unsigned int cpt;
- int seen;
-
- xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_int);
-
- if (xbt_dynar_length(variable->content) == variable->min)
- THROWF(mismatch_error, 0,
- "Cannot remove value %d from the config element %s since it's already at its minimal size (=%d)",
- val, name, variable->min);
-
- xbt_dynar_foreach(variable->content, cpt, seen) {
- if (seen == val) {
- xbt_dynar_cursor_rm(variable->content, &cpt);
- return;
- }
- }
- THROWF(not_found_error, 0, "Can't remove the value %d of config element %s: value not found.", val, name);
-}
-
-/** @brief Remove the provided \e val double value from a variable
- *
- * @param cfg the config set
- * @param name the name of the variable
- * @param val the value to be removed
- */
-void xbt_cfg_rm_double(xbt_cfg_t cfg, const char *name, double val)
-{
- unsigned int cpt;
- double seen;
-
- xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_double);
-
- if (xbt_dynar_length(variable->content) == variable->min)
- THROWF(mismatch_error, 0,
- "Cannot remove value %f from the config element %s since it's already at its minimal size (=%d)",
- val, name, variable->min);
-
- xbt_dynar_foreach(variable->content, cpt, seen) {
- if (seen == val) {
- xbt_dynar_cursor_rm(variable->content, &cpt);
- return;
- }
- }
-
- THROWF(not_found_error, 0,"Can't remove the value %f of config element %s: value not found.", val, name);
-}
-
-/** @brief Remove the provided \e val string value from a variable
- *
- * @param cfg the config set
- * @param name the name of the variable
- * @param val the value of the string which will be removed
- */
-void xbt_cfg_rm_string(xbt_cfg_t cfg, const char *name, const char *val)
-{
- unsigned int cpt;
- char *seen;
- xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_string);
-
- if (xbt_dynar_length(variable->content) == variable->min)
- THROWF(mismatch_error, 0,
- "Cannot remove value %s from the config element %s since it's already at its minimal size (=%d)",
- name, val, variable->min);
-
- xbt_dynar_foreach(variable->content, cpt, seen) {
- if (!strcpy(seen, val)) {
- xbt_dynar_cursor_rm(variable->content, &cpt);
- return;
- }
- }
-
- THROWF(not_found_error, 0, "Can't remove the value %s of config element %s: value not found.", val, name);
-}
-
-/** @brief Remove the provided \e val boolean value from a variable
- *
- * @param cfg the config set
- * @param name the name of the variable
- * @param val the value to be removed
- */
-void xbt_cfg_rm_boolean(xbt_cfg_t cfg, const char *name, int val)
-{
- unsigned int cpt;
- int seen;
- xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_boolean);
-
- if (xbt_dynar_length(variable->content) == variable->min)
- THROWF(mismatch_error, 0,
- "Cannot remove value %d from the config element %s since it's already at its minimal size (=%d)",
- val, name, variable->min);
-
- xbt_dynar_foreach(variable->content, cpt, seen) {
- if (seen == val) {
- xbt_dynar_cursor_rm(variable->content, &cpt);
- return;
- }
- }
-
- THROWF(not_found_error, 0, "Can't remove the value %d of config element %s: value not found.", val, name);
-}
-
-/** @brief Remove the \e pos th value from the provided variable */
-void xbt_cfg_rm_at(xbt_cfg_t cfg, const char *name, int pos)
-{
- xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_any);
-
- if (xbt_dynar_length(variable->content) == variable->min)
- THROWF(mismatch_error, 0,
- "Cannot remove %dth value from the config element %s since it's already at its minimal size (=%d)",
- pos, name, variable->min);
-
- xbt_dynar_remove_at(variable->content, pos, NULL);
-}
-
-/** @brief Remove all the values from a variable
- *
- * @param cfg the config set
- * @param name the name of the variable
- */
-void xbt_cfg_empty(xbt_cfg_t cfg, const char *name)
-{
- xbt_cfgelm_t variable = NULL;
- xbt_ex_t e;
-
- TRY {
- variable = xbt_dict_get((xbt_dict_t) cfg, name);
- } CATCH(e) {
- if (e.category != not_found_error)
- RETHROW;
-
- xbt_ex_free(e);
- THROWF(not_found_error, 0, "Can't empty '%s' since this option does not exist", name);
- }
-
- if (variable)
- xbt_dynar_reset(variable->content);
-}
/* Say if the value is the default value */
int xbt_cfg_is_default_value(const char *name)