X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/dccf1b41e9c7b5a696f01abceaa2779fe65f154f..5343203035034c0e4e1b894ca313a072c58d9183:/include/xbt/config.hpp diff --git a/include/xbt/config.hpp b/include/xbt/config.hpp index 8200bf06c6..6c61a46bef 100644 --- a/include/xbt/config.hpp +++ b/include/xbt/config.hpp @@ -1,11 +1,10 @@ -/* Copyright (c) 2016. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2016-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. */ -#ifndef _XBT_CONFIG_HPP_ -#define _XBT_CONFIG_HPP_ +#ifndef XBT_CONFIG_HPP +#define XBT_CONFIG_HPP #include @@ -147,10 +146,12 @@ typename std::enable_if([&value,callback](const T& val) { + callback(val); + value = std::move(val); + } + )); } /** Bind a variable to configuration flag @@ -169,11 +170,13 @@ typename std::enable_if([&value, callback](const T& val) { + if (not callback(val)) + throw std::range_error("invalid value"); + value = std::move(val); + }) + ); } /** A variable bound to a CLI option @@ -239,5 +242,6 @@ public: } } +XBT_PUBLIC(std::string) xbt_cfg_get_string(const char* name); #endif