SimGrid  3.13
Versatile Simulation of Distributed Systems
simgrid::config Namespace Reference

Classes

class  Flag
 A variable bound to a CLI option. More...
 
struct  parse_option
 
struct  parse_option< bool >
 
struct  parse_option< double >
 
struct  parse_option< int >
 
struct  parse_option< std::string >
 

Functions

bool parseBool (const char *value)
 
double parseDouble (const char *value)
 
long int parseLong (const char *value)
 
template<class T >
parse (const char *value)
 
template<class T >
std::string to_string (T &&value)
 
std::string const & to_string (std::string &value)
 
std::string const & to_string (std::string const &value)
 
std::string to_string (std::string &&value)
 
void declareFlag (const char *name, const char *description, std::function< void(const char *value)> callback)
 Register a configuration flag. More...
 
template<class T >
void bindFlag (T &value, const char *name, const char *description)
 Bind a variable to configuration flag. More...
 
template<class T , class F >
std::enable_if< std::is_same< T, typename std::remove_cv< decltype(std::declval< F >)(std::declval< const char * >))) >::type >::value, void >::type bindFlag (T &value, const char *name, const char *description, F callback)
 Bind a variable to configuration flag. More...
 
template<class T , class F >
std::enable_if< std::is_same< void, decltype(std::declval< F >)(std::declval< const T & >)))>::value, void >::type bindFlag (T &value, const char *name, const char *description, F callback)
 Bind a variable to configuration flag. More...
 
template<class T , class F >
std::enable_if< std::is_same< bool, decltype(std::declval< F >)(std::declval< const T & >)))>::value, void >::type bindFlag (T &value, const char *name, const char *description, F callback)
 Bind a variable to configuration flag. More...
 

Function Documentation

bool simgrid::config::parseBool ( const char *  value)
double simgrid::config::parseDouble ( const char *  value)
long int simgrid::config::parseLong ( const char *  value)
template<class T >
T simgrid::config::parse ( const char *  value)
inline
template<class T >
std::string simgrid::config::to_string ( T &&  value)
inline
std::string const& simgrid::config::to_string ( std::string value)
inline
std::string const& simgrid::config::to_string ( std::string const &  value)
inline
std::string simgrid::config::to_string ( std::string &&  value)
inline
void simgrid::config::declareFlag ( const char *  name,
const char *  description,
std::function< void(const char *value)>  callback 
)

Register a configuration flag.

Parameters
namename of the option
descriptionDescription of the option
callbackcalled with the option value
template<class T >
void simgrid::config::bindFlag ( T &  value,
const char *  name,
const char *  description 
)

Bind a variable to configuration flag.

Parameters
valueBound variable
nameFlag name
descriptionOption description
template<class T , class F >
std::enable_if<std::is_same< T, typename std::remove_cv< decltype( std::declval<F>)(std::declval<const char*>)) ) >::type>::value, void>::type simgrid::config::bindFlag ( T &  value,
const char *  name,
const char *  description,
callback 
)

Bind a variable to configuration flag.


static int x;
simgrid::config::bindFlag(a, "x", [](const char* value) {
  return simgrid::config::parse(value);
}

template<class T , class F >
std::enable_if<std::is_same< void, decltype( std::declval<F>)(std::declval<const T&>)) )>::value, void>::type simgrid::config::bindFlag ( T &  value,
const char *  name,
const char *  description,
callback 
)

Bind a variable to configuration flag.


static int x;
simgrid::config::bindFlag(a, "x", [](int x) {
  if (x < x_min || x => x_max)
    throw std::range_error("must be in [x_min, x_max)")
});

template<class T , class F >
std::enable_if<std::is_same< bool, decltype( std::declval<F>)(std::declval<const T&>)) )>::value, void>::type simgrid::config::bindFlag ( T &  value,
const char *  name,
const char *  description,
callback 
)

Bind a variable to configuration flag.


static int x;
simgrid::config::bindFlag(a, "x", [](int x) { return return x > 0; });