ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/io/Globals.cpp
(Generate patch)

Comparing trunk/OOPSE-2.0/src/io/Globals.cpp (file contents):
Revision 2371 by tim, Fri Oct 14 21:43:13 2005 UTC vs.
Revision 2380 by tim, Mon Oct 17 23:13:44 2005 UTC

# Line 65 | Line 65
65    parameters_.insert(std::make_pair(std::string(KEYWORD),  &NAME));
66  
67   #define CheckParameter(NAME, CONSTRAINT)                              \
68 <  if (!NAME.empty()) { if (!(CONSTRAINT)(NAME.getData())) std::cout <<"Error in parsing " << NAME.getKeyword() << " : "<< (CONSTRAINT).getConstraintDescription() << std::endl; }                
68 >  if (!NAME.empty()) { if (!(CONSTRAINT)(NAME.getData())) { sprintf(painCave.errMsg,"Error in checking %s : should be %s\n",NAME.getKeyword().c_str(),(CONSTRAINT).getConstraintDescription().c_str()); painCave.isFatal = 1; painCave.severity = OOPSE_ERROR; simError();} }                
69  
70
70   Globals::Globals(){
71  
72    DefineParameter(ForceField, "forceField")
# Line 123 | Line 122 | Globals::Globals(){
122    DefineOptionalParameter(PrintPressureTensor, "printPressureTensor");
123    DefineOptionalParameter(ElectrostaticSummationMethod, "electrostaticSummationMethod");
124    DefineOptionalParameter(CutoffPolicy, "cutoffPolicy");
126  DefineOptionalParameter(StatFileFormat, "statFileFormat");    
125    
126    DefineOptionalParameterWithDefaultValue(MixingRule, "mixingRule", "standard");
127    DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions, "usePeriodicBoundaryConditions", true);
# Line 138 | Line 136 | Globals::Globals(){
136    DefineOptionalParameterWithDefaultValue(DampingAlpha, "dampingAlpha", 1.5);
137    DefineOptionalParameterWithDefaultValue(CompressDumpFile, "compressDumpFile", 0);
138    DefineOptionalParameterWithDefaultValue(SkinThickness, "skinThickness", 1.0);
139 +  DefineOptionalParameterWithDefaultValue(StatFileFormat, "statFileFormat", "TIME|TOTAL_ENERGY|POTENTIAL_ENERGY|KINETIC_ENERGY|TEMPERATURE|PRESSURE|VOLUME|CONSERVED_QUANTITY");    
140 +
141    
142   }
143  
144   int Globals::globalAssign( event* the_event ){
145 <  
145 >  char errorMessage[65535];
146    int key;
147  int token;
147    interface_assign_type the_type =  the_event->evt.asmt.asmt_type;
148    char* lhs = the_event->evt.asmt.lhs;
149    std::string keyword(lhs);
150  
151 <  bool result;
151 >  bool result = false;
152  
153 <
153 >  /**@todo fix memory leak */  
154    ParamMap::iterator i =parameters_.find(keyword);
155    if (i != parameters_.end()) {
156      if( the_type == STRING ){
157         result = i->second->setData(std::string(the_event->evt.asmt.rhs.sval));
158         if (!result ) {
159 <            sprintf(the_event->err_msg, "Error in parsing meta-data file!\n\t%s must be a string.\n", keyword.c_str() );
159 >            sprintf(errorMessage, "Error in parsing %s: expect %s, but get a string \"%s\".\n", keyword.c_str(), i->second->getParamType().c_str(), the_event->evt.asmt.rhs.sval);
160 >            the_event->err_msg = strdup(errorMessage);
161         }
162      } else if( the_type == DOUBLE ){
163        result = i->second->setData(the_event->evt.asmt.rhs.dval);
164         if (!result )
165 <         sprintf(the_event->err_msg, "Error in parsing meta-data file!\n\t%s must be a double.\n", keyword.c_str() );
165 >         sprintf(errorMessage, "Error in parsing %s: expect %s, but get a double %f.\n", keyword.c_str(), i->second->getParamType().c_str(), the_event->evt.asmt.rhs.dval );
166 >       the_event->err_msg = strdup(errorMessage);
167      }      
168      else if (the_type == INT ){
169        result = i->second->setData(the_event->evt.asmt.rhs.ival);
170         if (!result )
171 <         sprintf(the_event->err_msg,  "Error in parsing meta-data file!\n\t%s must be an int.\n", keyword.c_str() );
171 >         sprintf(errorMessage,  "Error in parsing %s: expect %s, but get an int %d.\n", keyword.c_str(), i->second->getParamType().c_str(), the_event->evt.asmt.rhs.ival );
172 >       the_event->err_msg = strdup(errorMessage);
173        
174      } else {
175 <    
175 >        sprintf(errorMessage,  "Internal error of parser\n");
176 >        the_event->err_msg = strdup(errorMessage);
177      }
178 +  } else {
179 +    sprintf(errorMessage,  "%s is an unrecognized keyword\n", keyword.c_str() );
180 +    the_event->err_msg = strdup(errorMessage);
181    }
182  
183    if (keyword == "nComponents" && getNComponents() > 0) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines