@ -20,6 +20,7 @@
# include <boost/algorithm/string.hpp>
# include <sstream>
# include <ostream>
# include "log4cplus/logger.h"
# include "log4cplus/loggingmacros.h"
@ -27,7 +28,7 @@ extern log4cplus::Logger logger;
bool ExplicitModelAdapterOptionsRegistered = storm : : settings : : Settings : : registerNewModule ( [ ] ( storm : : settings : : Settings * instance ) - > bool {
instance - > addOption ( storm : : settings : : OptionBuilder ( " ExplicitModelAdapter " , " constants " , " " , " Specifies the constant replacements to use in Explicit Models " ) . addArgument ( storm : : settings : : ArgumentBuilder : : createStringArgument ( " constantString " , " A comma separated list of constants and their value, e.g. a=1,b=2,c=3 " ) . addValidationFunctionString (
[ ] ( std : : string const & s ) - > bool {
[ ] ( std : : string const s , std : : string & errorMe ssageTarget ) - > bool {
// since regex is not yet implemented in gccs C++11, we have to check by hand
std : : vector < std : : string > constants ;
// split for single assignment expressions
@ -36,18 +37,27 @@ bool ExplicitModelAdapterOptionsRegistered = storm::settings::Settings::register
std : : vector < std : : string > constant ;
boost : : split ( constant , * it , boost : : is_any_of ( " = " ) ) ;
if ( constant . size ( ) ! = 2 ) {
std : : ostringstream stream ;
stream < < " Expected one \" = \" in constant definition: \" " < < * it < < " \" " < < std : : endl ;
errorMessageTarget . append ( stream . str ( ) ) ;
return false ;
}
// Constant Name check
bool error = false ;
std : : for_each ( constant . at ( 0 ) . cbegin ( ) , constant . at ( 0 ) . cend ( ) , [ & error ] ( const std : : string : : value_type value ) - > void {
std : : for_each ( constant . at ( 0 ) . cbegin ( ) , constant . at ( 0 ) . cend ( ) , [ & error , & errorMessageTarget ] ( const std : : string : : value_type value ) - > void {
if ( ! ( ( ' a ' < = value & & value < = ' z ' ) | | ( ' A ' < = value & & value < = ' Z ' ) | | ( ' 0 ' < = value & & value < = ' 9 ' ) ) ) {
std : : ostringstream stream ;
stream < < " Illegal character in constant name: \" " < < value < < " \" " < < std : : endl ;
errorMessageTarget . append ( stream . str ( ) ) ;
error = true ;
}
} ) ;
// Value Check
std : : for_each ( constant . at ( 1 ) . cbegin ( ) , constant . at ( 1 ) . cend ( ) , [ & error ] ( const std : : string : : value_type value ) - > void {
std : : for_each ( constant . at ( 1 ) . cbegin ( ) , constant . at ( 1 ) . cend ( ) , [ & error , & errorMessageTarget ] ( const std : : string : : value_type value ) - > void {
if ( ! ( ( ' a ' < = value & & value < = ' z ' ) | | ( ' A ' < = value & & value < = ' Z ' ) | | ( ' 0 ' < = value & & value < = ' 9 ' ) ) ) {
std : : ostringstream stream ;
stream < < " Illegal character in constant value: \" " < < value < < " \" " < < std : : endl ;
errorMessageTarget . append ( stream . str ( ) ) ;
error = true ;
}
} ) ;