18 |
|
if( start_array != NULL ) free( start_array ); |
19 |
|
} |
20 |
|
|
21 |
< |
void Component::assignString( char* lhs, char* rhs ){ |
21 |
> |
int Component::assignString( char* lhs, char* rhs, char** err ){ |
22 |
|
|
23 |
+ |
char myErr[1000]; |
24 |
+ |
|
25 |
+ |
|
26 |
|
if( !strcmp( lhs, "type" ) ){ |
27 |
|
strcpy( type, rhs ); |
28 |
|
have_type = 1; |
29 |
|
} |
30 |
|
|
31 |
|
else{ |
32 |
< |
std::cerr << "Invalid assignment type for Component: " |
33 |
< |
<< lhs << " = " << rhs << "\n"; |
34 |
< |
exit(1); |
32 |
> |
sprintf(myErr, "Invalid assignment type for Component: %s = %s\n", lhs, rhs); |
33 |
> |
*err = strdup(myErr); |
34 |
> |
return 0; |
35 |
|
} |
36 |
+ |
|
37 |
+ |
return 1; |
38 |
|
} |
39 |
|
|
40 |
< |
void Component::assignInt( char* lhs, int rhs ){ |
40 |
> |
int Component::assignInt( char* lhs, int rhs, char** err ){ |
41 |
|
|
42 |
+ |
char myErr[1000]; |
43 |
+ |
|
44 |
|
if( !strcmp( lhs, "nMol" ) ){ |
45 |
|
nMol = rhs; |
46 |
|
have_nMol = 1; |
48 |
|
|
49 |
|
else if( !strcmp( lhs, "molFraction" ) ){ |
50 |
|
if( rhs > 1 || rhs < 0 ){ |
51 |
< |
std::cerr << "Component error. " << rhs |
52 |
< |
<< " is an invalid molFraction. It must lie between 0 and 1\n"; |
53 |
< |
exit(1); |
51 |
> |
sprintf(myErr,"Component error. %d is an invalid molFraction. It must lie between 0 and 1\n",rhs); |
52 |
> |
*err = strdup(myErr); |
53 |
> |
return 0; |
54 |
|
} |
55 |
|
molFraction = rhs; |
56 |
|
have_molFraction = 1; |
57 |
|
} |
58 |
|
|
59 |
|
else{ |
60 |
< |
std::cerr << "Invalid assignment type for Component: " |
61 |
< |
<< lhs << " = " << rhs << "\n"; |
62 |
< |
exit(1); |
60 |
> |
sprintf(myErr, "Invalid assignment type for Component: %s = %d\n", lhs, rhs); |
61 |
> |
*err = strdup(myErr); |
62 |
> |
return 0; |
63 |
|
} |
64 |
+ |
|
65 |
+ |
return 1; |
66 |
|
} |
67 |
|
|
68 |
< |
void Component::assignDouble( char* lhs, double rhs ){ |
68 |
> |
int Component::assignDouble( char* lhs, double rhs, char** err ){ |
69 |
|
|
70 |
+ |
char myErr[1000]; |
71 |
+ |
|
72 |
|
if( !strcmp( lhs, "molFraction" ) ){ |
73 |
|
if( rhs > 1 || rhs < 0 ){ |
74 |
< |
std::cerr << "Component error. " << rhs |
75 |
< |
<< " is an invalid molFraction. It must lie between 0 and 1\n"; |
76 |
< |
exit(1); |
74 |
> |
sprintf(myErr,"Component error. %lf is an invalid molFraction. It must lie between 0 and 1\n",rhs); |
75 |
> |
*err = strdup(myErr); |
76 |
> |
return 0; |
77 |
|
} |
78 |
|
molFraction = rhs; |
79 |
|
have_molFraction = 1; |
85 |
|
} |
86 |
|
|
87 |
|
else{ |
88 |
< |
std::cerr << "Invalid assignment type for Component: " |
89 |
< |
<< lhs << " = " << rhs << "\n"; |
90 |
< |
exit(1); |
88 |
> |
sprintf(myErr, "Invalid assignment type for Component: %s = %lf\n", lhs, rhs); |
89 |
> |
*err = strdup(myErr); |
90 |
> |
return 0; |
91 |
|
} |
92 |
+ |
|
93 |
+ |
return 1; |
94 |
|
} |
95 |
|
|
96 |
|
void Component::startIndex( int* the_start_array, int n_elements ){ |