X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ec09841c5c348a41ad076a0c5beae57448c1923e..48eb2f1b9262fc74f527816c348ed2aa6efa9f65:/src/xbt/config.cpp diff --git a/src/xbt/config.cpp b/src/xbt/config.cpp index 37c41b2076..977bad1502 100644 --- a/src/xbt/config.cpp +++ b/src/xbt/config.cpp @@ -1,9 +1,9 @@ -/* Copyright (c) 2004-2014,2016. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2004-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include +#include #include #include @@ -11,11 +11,11 @@ #include #include +#include #include #include #include #include -#include #include #include @@ -260,9 +260,10 @@ const char* TypedConfigurationElement::getTypeName() // override class Config { private: // name -> ConfigElement: - std::unordered_map options; + std::map options; // alias -> xbt_dict_elm_t from options: - std::unordered_map aliases; + std::map aliases; + bool warn_for_aliases = true; public: Config() = default; @@ -313,7 +314,8 @@ inline ConfigurationElement* Config::getDictElement(const char* name) } catch (std::out_of_range& unfound) { try { ConfigurationElement* res = aliases.at(name); - XBT_INFO("Option %s has been renamed to %s. Consider switching.", name, res->getKey().c_str()); + if (warn_for_aliases) + XBT_INFO("Option %s has been renamed to %s. Consider switching.", name, res->getKey().c_str()); return res; } catch (std::out_of_range& missing_key) { throw simgrid::config::missing_key_error(std::string("Bad config key: ") + name); @@ -356,28 +358,19 @@ void Config::dump(const char *name, const char *indent) /** @brief Displays the declared aliases and their description */ void Config::showAliases() { - std::vector names; - + bool old_warn_for_aliases = false; + std::swap(warn_for_aliases, old_warn_for_aliases); for (auto elm : aliases) - names.push_back(elm.first); - std::sort(names.begin(), names.end()); - - for (auto name : names) - printf(" %s: %s\n", name.c_str(), (*this)[name.c_str()].getDescription().c_str()); + printf(" %s: %s\n", elm.first.c_str(), (*this)[elm.first.c_str()].getDescription().c_str()); + std::swap(warn_for_aliases, old_warn_for_aliases); } /** @brief Displays the declared options and their description */ void Config::help() { - std::vector names; - - for (auto elm : options) - names.push_back(elm.first); - std::sort(names.begin(), names.end()); - - for (auto name : names) { - simgrid::config::ConfigurationElement* variable = this->options.at(name); - printf(" %s: %s\n", name.c_str(), variable->getDescription().c_str()); + for (auto elm : options) { + simgrid::config::ConfigurationElement* variable = this->options.at(elm.first); + printf(" %s: %s\n", elm.first.c_str(), variable->getDescription().c_str()); printf(" Type: %s; ", variable->getTypeName()); printf("Current value: %s\n", variable->getStringValue().c_str()); }