Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'actor-yield' of github.com:Takishipp/simgrid into actor-yield
[simgrid.git] / src / xbt / config.cpp
index 5b8ec4a..cb26929 100644 (file)
@@ -14,6 +14,7 @@
 #include <map>
 #include <stdexcept>
 #include <string>
+#include <string>
 #include <type_traits>
 #include <typeinfo>
 #include <vector>
@@ -146,8 +147,7 @@ public:
   /* Callback */
   xbt_cfg_cb_t old_callback = nullptr;
 
-  ConfigurationElement(const char* key, const char* desc)
-    : key(key ? key : ""), desc(desc ? desc : "") {}
+  ConfigurationElement(const char* key, const char* desc) : key(key ? key : ""), desc(desc ? desc : "") {}
   ConfigurationElement(const char* key, const char* desc, xbt_cfg_cb_t cb)
     : key(key ? key : ""), desc(desc ? desc : ""), old_callback(cb) {}
 
@@ -260,7 +260,7 @@ class Config {
 private:
   // name -> ConfigElement:
   std::map<std::string, simgrid::config::ConfigurationElement*> options;
-  // alias -> xbt_dict_elm_t from options:
+  // alias -> ConfigElement from options:
   std::map<std::string, simgrid::config::ConfigurationElement*> aliases;
   bool warn_for_aliases = true;
 
@@ -458,8 +458,7 @@ void xbt_cfg_register_string(const char *name, const char *default_value, xbt_cf
     simgrid_config = xbt_cfg_new();
     atexit(sg_config_finalize);
   }
-  simgrid_config->registerOption<std::string>(name, desc,
-    default_value ? default_value : "", cb_set);
+  simgrid_config->registerOption<std::string>(name, desc, default_value ? default_value : "", cb_set);
 }
 
 void xbt_cfg_register_boolean(const char *name, const char*default_value,xbt_cfg_cb_t cb_set, const char *desc)
@@ -657,10 +656,10 @@ void xbt_cfg_set_double(const char *key, double value)
  * @param value the value to be added
  *
  */
-void xbt_cfg_set_string(const char *key, const char *value)
+void xbt_cfg_set_string(const char* key, const char* value)
 {
   try {
-    (*simgrid_config)[key].setValue<std::string>(value ? value : "");
+    (*simgrid_config)[key].setValue<std::string>(value);
     return;
   }
   TRANSLATE_EXCEPTIONS("Could not set variable %s to string %s", key, value);
@@ -729,10 +728,10 @@ double xbt_cfg_get_double(const char *key)
  *
  * \warning the returned value is the actual content of the config set
  */
-char *xbt_cfg_get_string(const char *key)
+std::string xbt_cfg_get_string(const char* key)
 {
   try {
-    return (char*) (*simgrid_config)[key].getValue<std::string>().c_str();
+    return (*simgrid_config)[key].getValue<std::string>();
   }
   TRANSLATE_EXCEPTIONS("Could not get variable %s", key);
 }