-int xbt_cfg_get_boolean(const char *name)
-{
- simgrid::config::ConfigurationElement* variable = xbt_cfgelm_get(simgrid_config, name, xbt_cfgelm_boolean);
- return variable->boolean_content;
-}
-
-namespace simgrid {
-namespace config {
-
-bool parseBool(const char* value)
-{
- for (int i = 0; xbt_cfgelm_boolean_values[i].true_val != NULL; i++) {
- if (std::strcmp(value, xbt_cfgelm_boolean_values[i].true_val) == 0)
- return true;
- if (std::strcmp(value, xbt_cfgelm_boolean_values[i].false_val) == 0)
- return false;
- }
- throw std::range_error("not a boolean");
-}
-
-double parseDouble(const char* value)
-{
- char* end;
- errno = 0;
- double res = std::strtod(value, &end);
- if (errno == ERANGE)
- throw std::range_error("out of range");
- else if (errno)
- xbt_die("Unexpected errno");
- if (end == value || *end != '\0')
- throw std::range_error("invalid double");
- else
- return res;
-}
-
-long int parseLong(const char* value)
-{
- char* end;
- errno = 0;
- long int res = std::strtol(value, &end, 0);
- if (errno) {
- if (res == LONG_MIN && errno == ERANGE)
- throw std::range_error("underflow");
- else if (res == LONG_MAX && errno == ERANGE)
- throw std::range_error("overflow");
- xbt_die("Unexpected errno");
- }
- if (end == value || *end != '\0')
- throw std::range_error("invalid integer");
- else
- return res;
-}
-
-void declareFlag(const char* name, const char* description,
- std::function<void(const char* value)> callback)
-{
- simgrid::config::ConfigurationElement* e = xbt_cfg_register(
- &simgrid_config, name, description, xbt_cfgelm_string, NULL);
- e->callback = std::move(callback);
-}
-
-}
-}
-
-#ifdef SIMGRID_TEST
-
-#include <string>
-
-#include "xbt.h"
-#include "xbt/ex.h"
-
-#include <xbt/config.hpp>
-
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(xbt_cfg);
-
-XBT_TEST_SUITE("config", "Configuration support");
-
-static xbt_cfg_t make_set()
-{
- xbt_cfg_t set = NULL;
-
- xbt_log_threshold_set(&_XBT_LOGV(xbt_cfg), xbt_log_priority_critical);
- xbt_cfg_register_str(&set, "speed:int");
- xbt_cfg_register_str(&set, "peername:string");
- xbt_cfg_register_str(&set, "user:string");
-
- return set;
-} /* end_of_make_set */
-
-XBT_PUBLIC_DATA(xbt_cfg_t) simgrid_config;
-
-XBT_TEST_UNIT("memuse", test_config_memuse, "Alloc and free a config set")