--- branches/mmeineke/mdtools/interface_implementation/Component.cpp 2002/07/09 18:40:59 10 +++ trunk/mdtools/interface_implementation/Component.cpp 2002/09/25 22:51:14 118 @@ -18,22 +18,29 @@ void Component::assignString( char* lhs, char* rhs ){ if( start_array != NULL ) free( start_array ); } -void Component::assignString( char* lhs, char* rhs ){ +int Component::assignString( char* lhs, char* rhs, char** err ){ + char myErr[1000]; + + if( !strcmp( lhs, "type" ) ){ strcpy( type, rhs ); have_type = 1; } else{ - std::cerr << "Invalid assignment type for Component: " - << lhs << " = " << rhs << "\n"; - exit(1); + sprintf(myErr, "Invalid assignment type for Component: %s = %s\n", lhs, rhs); + *err = strdup(myErr); + return 0; } + + return = 1; } -void Component::assignInt( char* lhs, int rhs ){ +int Component::assignInt( char* lhs, int rhs, char** err ){ + char myErr[1000]; + if( !strcmp( lhs, "nMol" ) ){ nMol = rhs; have_nMol = 1; @@ -41,28 +48,32 @@ void Component::assignInt( char* lhs, int rhs ){ else if( !strcmp( lhs, "molFraction" ) ){ if( rhs > 1 || rhs < 0 ){ - std::cerr << "Component error. " << rhs - << " is an invalid molFraction. It must lie between 0 and 1\n"; - exit(1); + sprintf(myErr,"Component error. %d is an invalid molFraction. It must lie between 0 and 1\n",rhs); + *err = strdup(myErr); + return 0; } molFraction = rhs; have_molFraction = 1; } else{ - std::cerr << "Invalid assignment type for Component: " - << lhs << " = " << rhs << "\n"; - exit(1); + sprintf(myErr, "Invalid assignment type for Component: %s = %d\n", lhs, rhs); + *err = strdup(myErr); + return 0; } + + return 1; } -void Component::assignDouble( char* lhs, double rhs ){ +int Component::assignDouble( char* lhs, double rhs, char** err ){ + char myErr[1000]; + if( !strcmp( lhs, "molFraction" ) ){ if( rhs > 1 || rhs < 0 ){ - std::cerr << "Component error. " << rhs - << " is an invalid molFraction. It must lie between 0 and 1\n"; - exit(1); + sprintf(myErr,"Component error. %lf is an invalid molFraction. It must lie between 0 and 1\n",rhs); + *err = strdup(myErr); + return 0; } molFraction = rhs; have_molFraction = 1; @@ -74,10 +85,12 @@ void Component::assignDouble( char* lhs, double rhs ){ } else{ - std::cerr << "Invalid assignment type for Component: " - << lhs << " = " << rhs << "\n"; - exit(1); + sprintf(myErr, "Invalid assignment type for Component: %s = %lf\n", lhs, rhs); + *err = strdup(myErr); + return 0; } + + return 1; } void Component::startIndex( int* the_start_array, int n_elements ){