Changeset fc41df for src


Ignore:
Timestamp:
Dec 14, 2012, 1:02:50 PM (12 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
3b75c2
Parents:
05e2ed
git-author:
Frederik Heber <heber@…> (10/25/12 08:40:00)
git-committer:
Frederik Heber <heber@…> (12/14/12 13:02:50)
Message:

FIX: TremoloParser::readAtomDataLine now uses const ref word and const_iterator for usedFields_load.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TremoloParser.cpp

    r05e2ed rfc41df  
    629629  ASSERT(tokens.begin() != tokens.end(),
    630630      "FormatParser< tremolo >::readAtomDataLine - empty string, need at least ' '!");
    631   tokenizer::iterator tok_iter = tokens.begin();
     631  tokenizer::const_iterator tok_iter = tokens.begin();
    632632  // then associate each token to each file
    633   for (usedFields_t::const_iterator it = usedFields_load.begin(); it < usedFields_load.end(); it++) {
     633  for (usedFields_t::const_iterator it = usedFields_load.begin(); it != usedFields_load.end(); it++) {
    634634    const std::string keyName = it->substr(0, it->find("="));
    635635    currentField = knownKeys[keyName];
    636     const std::string word = *tok_iter;
     636    ASSERT(tok_iter != tokens.end(),
     637        "FormatParser< tremolo >::readAtomDataLine - too few entries in line '"+line+"'!");
     638    const std::string &word = *tok_iter;
    637639    LOG(4, "INFO: Parsing key " << keyName << " with remaining data " << word);
    638640    switch (currentField) {
     
    641643        for (int i=0;i<NDIM;i++) {
    642644          ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for x["+toString(i)+"]!");
    643           LOG(4, "INFO: Parsing key " << keyName << " with next token " << *tok_iter);
    644           newAtom->set(i, toDouble(*tok_iter));
     645          LOG(4, "INFO: Parsing key " << keyName << " with next token " << word);
     646          newAtom->set(i, toDouble(word));
    645647          tok_iter++;
    646648        }
     
    650652        for (int i=0;i<NDIM;i++) {
    651653          ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for u["+toString(i)+"]!");
    652           LOG(4, "INFO: Parsing key " << keyName << " with next token " << *tok_iter);
    653           tempVector[i] = toDouble(*tok_iter);
     654          LOG(4, "INFO: Parsing key " << keyName << " with next token " << word);
     655          tempVector[i] = toDouble(word);
    654656          tok_iter++;
    655657        }
     
    660662        for (int i=0;i<NDIM;i++) {
    661663          ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for F["+toString(i)+"]!");
    662           LOG(4, "INFO: Parsing key " << keyName << " with next token " << *tok_iter);
    663           tempVector[i] = toDouble(*tok_iter);
     664          LOG(4, "INFO: Parsing key " << keyName << " with next token " << word);
     665          tempVector[i] = toDouble(word);
    664666          tok_iter++;
    665667        }
     
    669671      {
    670672        ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!");
    671         LOG(4, "INFO: Parsing key " << keyName << " with next token " << *tok_iter);
     673        LOG(4, "INFO: Parsing key " << keyName << " with next token " << word);
    672674        std::string element;
    673675        try {
    674           element = knownTypes.getType(*tok_iter);
     676          element = knownTypes.getType(word);
    675677        } catch(IllegalParserKeyException) {
    676678          // clean up
    677679          World::getInstance().destroyAtom(newAtom);
    678680          // give an error
    679           ELOG(0, "TremoloParser: I do not understand the element token " << *tok_iter << ".");
     681          ELOG(0, "TremoloParser: I do not understand the element token " << word << ".");
     682          return;
    680683        }
    681684        // put type name into container for later use
    682         atomInfo->set(currentField, *tok_iter);
    683         LOG(4, "INFO: Parsing element " << (*tok_iter) << " as " << element << " according to KnownTypes.");
     685        atomInfo->set(currentField, word);
     686        LOG(4, "INFO: Parsing element " << (word) << " as " << element << " according to KnownTypes.");
    684687        tok_iter++;
    685688        newAtom->setType(World::getInstance().getPeriode()->FindElement(element));
     
    689692      case TremoloKey::Id :
    690693        ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!");
    691         LOG(4, "INFO: Parsing key " << keyName << " with next token " << *tok_iter);
    692         associateLocaltoGlobalId(toInt(*tok_iter), atomid);
     694        LOG(4, "INFO: Parsing key " << keyName << " with next token " << word);
     695        associateLocaltoGlobalId(toInt(word), atomid);
    693696        tok_iter++;
    694697        break;
     
    696699        for (int i=0;i<atoi(it->substr(it->find("=") + 1, 1).c_str());i++) {
    697700          ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!");
    698           LOG(4, "INFO: Parsing key " << keyName << " with next token " << *tok_iter);
    699           lineStream << *tok_iter << "\t";
     701          LOG(4, "INFO: Parsing key " << keyName << " with next token " << word);
     702          lineStream << word << "\t";
    700703          tok_iter++;
    701704        }
     
    705708      case TremoloKey::charge :
    706709        ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!");
    707         LOG(4, "INFO: Parsing key " << keyName << " with next token " << *tok_iter);
    708         atomInfo->set(currentField, *tok_iter);
    709         newAtom->setCharge(boost::lexical_cast<double>(*tok_iter));
     710        LOG(4, "INFO: Parsing key " << keyName << " with next token " << word);
     711        atomInfo->set(currentField, word);
     712        newAtom->setCharge(boost::lexical_cast<double>(word));
    710713        tok_iter++;
    711714        break;
    712715      default :
    713716        ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!");
    714         LOG(4, "INFO: Parsing key " << keyName << " with next token " << *tok_iter);
    715         atomInfo->set(currentField, *tok_iter);
     717        LOG(4, "INFO: Parsing key " << keyName << " with next token " << word);
     718        atomInfo->set(currentField, word);
    716719        tok_iter++;
    717720        break;
Note: See TracChangeset for help on using the changeset viewer.