X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b87fc0829538ec066fd077e6c30ee6270b8abd78..68fddbaeb8d7a332bec9eb09ef0e7e548ac1850c:/src/xbt/config.cpp diff --git a/src/xbt/config.cpp b/src/xbt/config.cpp index 2b1788bf63..cb6c810de6 100644 --- a/src/xbt/config.cpp +++ b/src/xbt/config.cpp @@ -51,10 +51,10 @@ const char* false_values[] = { static bool parseBool(const char* value) { - for (const char* true_value : true_values) + for (const char* const& true_value : true_values) if (std::strcmp(true_value, value) == 0) return true; - for (const char* false_value : false_values) + for (const char* const& false_value : false_values) if (std::strcmp(false_value, value) == 0) return false; throw std::range_error("not a boolean"); @@ -96,30 +96,34 @@ static long int parseLong(const char* value) // ***** ConfigType ***** /// A trait which define possible options types: -template struct ConfigType; +template class ConfigType; -template<> struct ConfigType { +template <> class ConfigType { +public: static constexpr const char* type_name = "int"; static inline double parse(const char* value) { return parseLong(value); } }; -template<> struct ConfigType { +template <> class ConfigType { +public: static constexpr const char* type_name = "double"; static inline double parse(const char* value) { return parseDouble(value); } }; -template<> struct ConfigType { +template <> class ConfigType { +public: static constexpr const char* type_name = "string"; static inline std::string parse(const char* value) { return std::string(value); } }; -template<> struct ConfigType { +template <> class ConfigType { +public: static constexpr const char* type_name = "boolean"; static inline bool parse(const char* value) { @@ -299,7 +303,7 @@ protected: Config::~Config() { XBT_DEBUG("Frees cfg set %p", this); - for (auto elm : options) + for (auto const& elm : options) delete elm.second; } @@ -344,7 +348,7 @@ void Config::dump(const char *name, const char *indent) if (name) printf("%s>> Dumping of the config set '%s':\n", indent, name); - for (auto elm : options) + for (auto const& elm : options) printf("%s %s: ()%s) %s", indent, elm.first.c_str(), elm.second->getTypeName(), elm.second->getStringValue().c_str()); @@ -358,7 +362,7 @@ void Config::showAliases() { bool old_warn_for_aliases = false; std::swap(warn_for_aliases, old_warn_for_aliases); - for (auto elm : aliases) + for (auto const& elm : aliases) 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); } @@ -366,7 +370,7 @@ void Config::showAliases() /** @brief Displays the declared options and their description */ void Config::help() { - for (auto elm : options) { + for (auto const& 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()); @@ -519,7 +523,6 @@ void xbt_cfg_set_parse(const char *options) /* Pass the following blank chars */ *(option++) = '\0'; while (option - name < (len - 1) && (*option == ' ' || *option == '\n' || *option == '\t')) { - /* fprintf(stderr,"Ignore a blank char.\n"); */ option++; } if (option - name == len - 1)