Changeset 7f570c for src/Parser/Psi3Parser_Parameters.cpp
- Timestamp:
- Oct 17, 2011, 4:56:37 PM (14 years ago)
- 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, Candidate_v1.7.0, 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:
- 032f31
- Parents:
- f758dd
- git-author:
- Frederik Heber <heber@…> (10/06/11 11:12:35)
- git-committer:
- Frederik Heber <heber@…> (10/17/11 16:56:37)
- File:
-
- 1 edited
-
src/Parser/Psi3Parser_Parameters.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/Psi3Parser_Parameters.cpp
rf758dd r7f570c 18 18 #endif 19 19 20 #include <iostream>21 #include <boost/tokenizer.hpp> 20 #include "CodePatterns/MemDebug.hpp" 21 22 22 #include <string> 23 23 24 #include "CodePatterns/MemDebug.hpp" 25 24 #include "CodePatterns/Assert.hpp" 26 25 #include "CodePatterns/Log.hpp" 27 26 … … 254 253 } 255 254 256 ///** Getter for name of a specific Parameter.257 // *258 // * @param param index among enum Theory259 // * @return name of the desired Theory260 // */261 //const std::string &Psi3Parser_Parameters::getTheoryName(const enum Theory theory) const262 //{263 // return ValidTheories[theory];264 //}265 //266 ///** Getter for the name of specific of IntegrationMethod.267 // *268 // * @param param index among enum IntegrationMethod269 // * @return value of the desired IntegrationMethod270 // */271 //const std::string &Psi3Parser_Parameters::getIntegrationMethodName(const enum IntegrationMethod integration) const272 //{273 // return ValidIntegrationMethods[integration];274 //}275 276 277 /** Output operator for the contents of Psi3Parser_Parameters::params.278 *279 * @param ost output stream280 * @param params reference to Psi3Parser_Parameters containing params.281 * @return reference to output stream for concatenation282 */283 std::ostream & operator << (std::ostream& ost, const Psi3Parser_Parameters ¶ms)284 {285 // this is ugly, but with boost::any to safeguard const-ness is plain impossible286 std::ostringstream output;287 for (size_t param = (enum Psi3Parser_Parameters::Parameters)0;288 param < (size_t)Psi3Parser_Parameters::unknownParam; ++param)289 output << params.getParameterName((enum Psi3Parser_Parameters::Parameters)param)290 << "=" << params.getParameter((enum Psi3Parser_Parameters::Parameters)param) << ";";291 ost << output.str();292 return ost;293 }294 295 /** Input operator for a list of parameters to place into \a params.296 *297 * @param ist input stream298 * @param params parameters to parse into299 * @return input stream for concatenation300 */301 std::istream & operator >> (std::istream& ist, Psi3Parser_Parameters ¶ms)302 {303 typedef boost::tokenizer<boost::char_separator<char> >304 tokenizer;305 boost::char_separator<char> semicolonsep(";");306 boost::char_separator<char> equalitysep(" =");307 boost::char_separator<char> ticksep("\"");308 std::string line;309 std::getline( ist, line );310 //DoLog(0) && (Log() << Verbose(0) << "INFO: full line of parameters is '" << line << "'" << std::endl);311 tokenizer tokens(line, semicolonsep);312 ASSERT(tokens.begin() != tokens.end(),313 "operator<< on Psi3Parser_Parameters - empty string, need at least ';' in line "+line+"!");314 for (tokenizer::iterator tok_iter = tokens.begin();315 tok_iter != tokens.end(); ++tok_iter) {316 tokenizer paramtokens(*tok_iter, equalitysep);317 if (paramtokens.begin() != paramtokens.end()) {318 tokenizer::iterator tok_paramiter = paramtokens.begin();319 tokenizer::iterator tok_valueiter = tok_paramiter;320 tokenizer::iterator tok_checkiter = ++tok_valueiter;321 ++tok_checkiter;322 // TODO: throw exception instead of ASSERT323 ASSERT(tok_paramiter != paramtokens.end(),324 "operator<< on Psi3Parser_Parameters - missing value before ' =' in token "+*tok_iter+"!");325 ASSERT(tok_valueiter != paramtokens.end(),326 "operator<< on Psi3Parser_Parameters - missing value after ' =' in token "+*tok_iter+"!");327 ASSERT(tok_checkiter == paramtokens.end(),328 "operator<< on Psi3Parser_Parameters - still more tokens after ' =' in token "+*tok_iter+":"329 +*tok_checkiter+"!");330 std::stringstream keystream(*tok_paramiter);331 std::string key;332 keystream >> ws >> key;333 tokenizer ticklesstokens(*tok_valueiter, ticksep);334 ASSERT(ticklesstokens.begin() != ticklesstokens.end(),335 "operator<< on Psi3Parser_Parameters - no tokens present after removing ticks in token "+*tok_valueiter+"!");336 std::stringstream valuestream(*(ticklesstokens.begin()));337 DoLog(2) && (Log() << Verbose(2)338 << "INFO: Token pair is " << key << "," << valuestream.str() << std::endl);339 340 // TODO: throw exception instead of DoeLog()341 ASSERT(params.haveParameter(key),342 "operator >> on Psi3Parser_Parameters - unknown parameter name '"343 +key+"' with value "+valuestream.str()+"!");344 if (params.haveParameter(key)) {345 Parameter *instance = params.FormatParser_Parameters::getParameter(key);346 instance->set(valuestream.str());347 }348 } else {349 ist.setstate(std::ios::eofbit);350 }351 }352 return ist;353 }354 355 255 /** Checks whether all elements in the world also have parameters in the basis. 356 256 *
Note:
See TracChangeset
for help on using the changeset viewer.
