-/* Copyright (c) 2016-2022. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2023. 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. */
extern template XBT_PUBLIC bool const& get_value<bool>(const std::string& name);
extern template XBT_PUBLIC std::string const& get_value<std::string>(const std::string& name);
+// ***** alias *****
+
+XBT_PUBLIC void alias(const char* realname, std::initializer_list<const char*> aliases);
+
// Register:
/** Register a configuration flag
template <class T>
XBT_PUBLIC void declare_flag(const std::string& name, const std::string& description, T value,
std::function<void(const T&)> callback = std::function<void(const T&)>());
+template <class T>
+void declare_flag(const std::string& name, std::initializer_list<const char*> aliases, const std::string& description,
+ T value, std::function<void(const T&)> callback = std::function<void(const T&)>())
+{
+ declare_flag(name, description, std::move(value), std::move(callback));
+ alias(name.c_str(), aliases);
+}
extern template XBT_PUBLIC void declare_flag(const std::string& name, const std::string& description, int value,
std::function<void(int const&)> callback);
extern template XBT_PUBLIC void declare_flag(const std::string& name, const std::string& description, std::string value,
std::function<void(std::string const&)> callback);
-// ***** alias *****
-
-XBT_PUBLIC void alias(const char* realname, std::initializer_list<const char*> aliases);
-
/** Bind a variable to configuration flag
*
* @param value Bound variable
if (val == "help")
mesg += std::string("Possible values for option ") + name + ":\n";
else
- mesg += std::string("Invalid value '") + val + "' for option " + name + ". Possible values:\n";
+ mesg += "Invalid value '" + val + "' for option " + name + ". Possible values:\n";
for (auto const& kv : valid_values)
mesg += " - '" + kv.first + "': " + kv.second + (kv.first == value ? " <=== DEFAULT" : "") + "\n";
xbt_die("%s", mesg.c_str());