Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/MpqcParser_Parameters.cpp

    r311da7b r963321a  
    152152  boost::char_separator<char> semicolonsep(";");
    153153  boost::char_separator<char> equalitysep(" =");
    154   boost::char_separator<char> ticksep("\"");
    155154  std::string line;
    156155  std::getline( ist, line );
     
    158157  tokenizer tokens(line, semicolonsep);
    159158  ASSERT(tokens.begin() != tokens.end(),
    160       "operator<< on MpqcParser_Parameters - empty string, need at least ';' in line "+line+"!");
     159      "operator<< on MpqcParser_Parameters - empty string, need at least ';'!");
    161160  for (tokenizer::iterator tok_iter = tokens.begin();
    162161        tok_iter != tokens.end(); ++tok_iter) {
     
    166165      tokenizer::iterator tok_valueiter = tok_paramiter;
    167166      tokenizer::iterator tok_checkiter = ++tok_valueiter;
     167      // TODO: throw exception instead of ASSERT
     168      ASSERT(tok_valueiter == params.end(),
     169          "operator<< on MpqcParser_Parameters - missing value before ';'!");
    168170      ++tok_checkiter;
    169       // TODO: throw exception instead of ASSERT
    170       ASSERT(tok_paramiter != paramtokens.end(),
    171           "operator<< on MpqcParser_Parameters - missing value before ' =' in token "+*tok_iter+"!");
    172       ASSERT(tok_valueiter != paramtokens.end(),
    173           "operator<< on MpqcParser_Parameters - missing value after ' =' in token "+*tok_iter+"!");
    174       ASSERT(tok_checkiter == paramtokens.end(),
    175           "operator<< on MpqcParser_Parameters - still more tokens after ' =' in token "+*tok_iter+":"
    176           +*tok_checkiter+"!");
    177       std::stringstream keystream(*tok_paramiter);
    178       std::string key;
    179       keystream >> ws >> key;
    180       tokenizer ticklesstokens(*tok_valueiter, ticksep);
    181       ASSERT(ticklesstokens.begin() != ticklesstokens.end(),
    182           "operator<< on MpqcParser_Parameters - no tokens present after removing ticks in token "+*tok_valueiter+"!");
    183       std::stringstream valuestream(*(ticklesstokens.begin()));
    184       DoLog(2) && (Log() << Verbose(2)
    185           << "INFO: Token pair is " << key << "," << valuestream.str() << std::endl);
     171      ASSERT(tok_checkiter == params.end(),
     172          "operator<< on MpqcParser_Parameters - still tokens before ';'!");
     173      DoLog(0) && (Log() << Verbose(0)
     174          << "INFO: Token pair is " << *tok_paramiter << "," << *tok_valueiter << std::endl);
     175      std::stringstream value(*tok_valueiter);
    186176
    187177      // TODO: throw exception instead of DoeLog()
    188       ASSERT(params.haveParam(key),
    189           "operator >> on MpqcParser_Parameters - unknown parameter name '"
    190           +key+"' with value "+valuestream.str()+"!");
    191       if (params.haveParam(key))
    192         params.setter(params.getParam(key), valuestream);
     178      if ((params.haveParam(*tok_paramiter))) {
     179        params.setter(params.getParam(*tok_paramiter), value);
     180      } else {
     181        DoeLog(0) && (eLog() << Verbose(0)
     182            << *tok_paramiter << " is not a valid parameter name!" << std::endl);
     183      }
    193184    } else {
    194185      ist.setstate(std::ios::eofbit);
     
    256247{
    257248  // TODO: throw exception instead of eLog()
    258 //  try {
     249  try {
    259250    params[theoryParam] = _theory;
    260 //  } catch(const boost::bad_any_cast &) {
    261 //    DoeLog(0) && (eLog() << Verbose(0)
    262 //        << "MpqcParser_Parameters::setTheory() - could not set boolean!" << std::endl);
    263 //  }
     251  } catch(const boost::bad_any_cast &) {
     252    DoeLog(0) && (eLog() << Verbose(0)
     253        << "MpqcParser_Parameters::setTheory() - could not set boolean!" << std::endl);
     254  }
    264255}
    265256
    266257void MpqcParser_Parameters::setIntegration(enum MpqcParser_Parameters::IntegrationMethod _integration){
    267258  // TODO: throw exception instead of eLog()
    268 //  try {
     259  try {
    269260    params[integrationParam] = _integration;
    270 //  } catch(const boost::bad_any_cast &) {
    271 //    DoeLog(0) && (eLog() << Verbose(0)
    272 //        << "MpqcParser_Parameters::setIntegration() - could not set boolean!" << std::endl);
    273 //  }
     261  } catch(const boost::bad_any_cast &) {
     262    DoeLog(0) && (eLog() << Verbose(0)
     263        << "MpqcParser_Parameters::setIntegration() - could not set boolean!" << std::endl);
     264  }
    274265}
    275266
     
    288279  enum IntegrationMethod value;
    289280  // TODO: throw exception instead of eLog()
    290 //  try {
     281  try {
    291282    value = boost::any_cast<enum IntegrationMethod>(params[integrationParam]);
    292 //  } catch(const boost::bad_any_cast &) {
    293 //    DoeLog(0) && (eLog() << Verbose(0)
    294 //        << "MpqcParser_Parameters::getIntegration() - could not convert "
    295 //        +ParamNames[integrationParam]+" to enum IntegrationMethod!" << std::endl);
    296 //  }
     283  } catch(const boost::bad_any_cast &) {
     284    DoeLog(0) && (eLog() << Verbose(0)
     285        << "MpqcParser_Parameters::getIntegration() - could not convert "
     286        +ParamNames[integrationParam]+" to enum IntegrationMethod!" << std::endl);
     287  }
    297288  return value;
    298289}
     
    302293  enum Theory value;
    303294  // TODO: throw exception instead of eLog()
    304 //  try {
     295  try {
    305296    value = boost::any_cast<enum Theory>(params[theoryParam]);
    306 //  } catch(const boost::bad_any_cast &) {
    307 //    DoeLog(0) && (eLog() << Verbose(0)
    308 //        << "MpqcParser_Parameters::getTheory() - could not convert "
    309 //        +ParamNames[theoryParam]+" to enum Theory!" << std::endl);
    310 //  }
     297  } catch(const boost::bad_any_cast &) {
     298    DoeLog(0) && (eLog() << Verbose(0)
     299        << "MpqcParser_Parameters::getTheory() - could not convert "
     300        +ParamNames[theoryParam]+" to enum Theory!" << std::endl);
     301  }
    311302  return value;
    312303}
     
    330321    case integrationParam:
    331322      // TODO: throw exception instead of eLog()
    332 //      try {
     323      try {
    333324        Iindex = boost::any_cast<enum IntegrationMethod>(params[_param]);
    334 //      } catch(const boost::bad_any_cast &) {
    335 //        DoeLog(0) && (eLog() << Verbose(0)
    336 //            << "MpqcParser_Parameters::getString() - could not convert "
    337 //            +ParamNames[_param]+" to string!" << std::endl);
    338 //      }
     325      } catch(const boost::bad_any_cast &) {
     326        DoeLog(0) && (eLog() << Verbose(0)
     327            << "MpqcParser_Parameters::getString() - could not convert "
     328            +ParamNames[_param]+" to string!" << std::endl);
     329      }
    339330      value = IntegrationNames[Iindex];
    340331      break;
    341332    case theoryParam:
    342333      // TODO: throw exception instead of eLog()
    343 //      try {
     334      try {
    344335        Tindex = boost::any_cast<enum Theory>(params[_param]);
    345 //      } catch(const boost::bad_any_cast &) {
    346 //        DoeLog(0) && (eLog() << Verbose(0)
    347 //            << "MpqcParser_Parameters::getString() - could not convert "
    348 //            +ParamNames[_param]+" to string!" << std::endl);
    349 //      }
     336      } catch(const boost::bad_any_cast &) {
     337        DoeLog(0) && (eLog() << Verbose(0)
     338            << "MpqcParser_Parameters::getString() - could not convert "
     339            +ParamNames[_param]+" to string!" << std::endl);
     340      }
    350341      value = TheoryNames[(enum Theory)Tindex];
    351342      break;
    352343    default:
    353344      // TODO: throw exception instead of eLog()
    354 //      try {
     345      try {
    355346        value = boost::any_cast<std::string>(params[_param]);
    356 //      } catch(const boost::bad_any_cast &) {
    357 //        DoeLog(0) && (eLog() << Verbose(0)
    358 //            << "MpqcParser_Parameters::getString() - could not convert "
    359 //            +ParamNames[_param]+" to string!" << std::endl);
    360 //      }
     347      } catch(const boost::bad_any_cast &) {
     348        DoeLog(0) && (eLog() << Verbose(0)
     349            << "MpqcParser_Parameters::getString() - could not convert "
     350            +ParamNames[_param]+" to string!" << std::endl);
     351      }
    361352      break;
    362353  }
     
    371362    default:
    372363      // TODO: throw exception instead of eLog()
    373 //      try {
     364      try {
    374365        value = boost::any_cast<int>(params[_param]);
    375 //      } catch(const boost::bad_any_cast &) {
    376 //        DoeLog(0) && (eLog() << Verbose(0)
    377 //            << "MpqcParser_Parameters::getInt() - could not convert "
    378 //            +ParamNames[_param]+" to int!" << std::endl);
    379 //      }
     366      } catch(const boost::bad_any_cast &) {
     367        DoeLog(0) && (eLog() << Verbose(0)
     368            << "MpqcParser_Parameters::getInt() - could not convert "
     369            +ParamNames[_param]+" to int!" << std::endl);
     370      }
    380371      break;
    381372  }
     
    387378  double value;
    388379  // TODO: throw exception instead of eLog()
    389 //  try {
     380  try {
    390381    value = boost::any_cast<double>(params[_param]);
    391 //  } catch(const boost::bad_any_cast &) {
    392 //    DoeLog(0) && (eLog() << Verbose(0)
    393 //        << "MpqcParser_Parameters::getDouble() - could not convert "
    394 //        +ParamNames[_param]+" to double!" << std::endl);
    395 //  }
     382  } catch(const boost::bad_any_cast &) {
     383    DoeLog(0) && (eLog() << Verbose(0)
     384        << "MpqcParser_Parameters::getDouble() - could not convert "
     385        +ParamNames[_param]+" to double!" << std::endl);
     386  }
    396387  return value;
    397388}
     
    401392  bool value;
    402393  // TODO: throw exception instead of eLog()
    403 //  try {
     394  try {
    404395    value = boost::any_cast<bool>(params[_param]);
    405 //  } catch(const boost::bad_any_cast &) {
    406 //    DoeLog(0) && (eLog() << Verbose(0)
    407 //        << "MpqcParser_Parameters::getBool() - could not convert "
    408 //        +ParamNames[_param]+" to bool!" << std::endl);
    409 //  }
     396  } catch(const boost::bad_any_cast &) {
     397    DoeLog(0) && (eLog() << Verbose(0)
     398        << "MpqcParser_Parameters::getBool() - could not convert "
     399        +ParamNames[_param]+" to bool!" << std::endl);
     400  }
    410401  return value;
    411402}
Note: See TracChangeset for help on using the changeset viewer.