- Timestamp:
- Oct 17, 2011, 4:56:37 PM (13 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, 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)
- Location:
- src/Parser
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/FormatParser_Parameters.cpp
rf758dd r7f570c 20 20 #include "CodePatterns/MemDebug.hpp" 21 21 22 #include <iostream> 23 #include <boost/algorithm/string.hpp> 24 #include <boost/tokenizer.hpp> 25 #include <sstream> 22 26 #include <string> 27 28 #include "CodePatterns/Assert.hpp" 29 #include "CodePatterns/Log.hpp" 23 30 24 31 #include "Parameters/Parameter.hpp" … … 106 113 return storage->getByName(_name); 107 114 } 115 116 /** Output operator for the contents of FormatParser_Parameters::params. 117 * 118 * @param ost output stream 119 * @param params reference to FormatParser_Parameters containing params. 120 * @return reference to output stream for concatenation 121 */ 122 std::ostream & operator << (std::ostream& ost, const FormatParser_Parameters ¶ms) 123 { 124 // this is ugly, but with boost::any to safeguard const-ness is plain impossible 125 std::ostringstream output; 126 ASSERT(params.storage != NULL, 127 "operator<<(FormatParser_Parameters) - storage is NULL."); 128 for (ParameterStorage::const_iterator iter = params.storage->getBeginIter(); 129 iter != params.storage->getEndIter(); 130 ++iter) 131 output << iter->first 132 << "=" << iter->second->get() << ";"; 133 ost << output.str(); 134 return ost; 135 } 136 137 /** Input operator for a list of parameters to place into \a params. 138 * 139 * @param ist input stream 140 * @param params parameters to parse into 141 * @return input stream for concatenation 142 */ 143 std::istream & operator >> (std::istream& ist, FormatParser_Parameters ¶ms) 144 { 145 typedef boost::tokenizer<boost::char_separator<char> > 146 tokenizer; 147 boost::char_separator<char> semicolonsep(";"); 148 boost::char_separator<char> equalitysep("="); 149 boost::char_separator<char> ticksep("\""); 150 std::string line; 151 std::getline( ist, line ); 152 //DoLog(0) && (Log() << Verbose(0) << "INFO: full line of parameters is '" << line << "'" << std::endl); 153 tokenizer tokens(line, semicolonsep); 154 ASSERT(tokens.begin() != tokens.end(), 155 "operator<< on FormatParser_Parameters - empty string, need at least ';' in line "+line+"!"); 156 for (tokenizer::iterator tok_iter = tokens.begin(); 157 tok_iter != tokens.end(); ++tok_iter) { 158 //LOG(2, "INFO: (key,value) pair is: " << *tok_iter << "."); 159 tokenizer paramtokens(*tok_iter, equalitysep); 160 if (paramtokens.begin() != paramtokens.end()) { 161 tokenizer::iterator tok_paramiter = paramtokens.begin(); 162 tokenizer::iterator tok_valueiter = tok_paramiter; 163 tokenizer::iterator tok_checkiter = ++tok_valueiter; 164 ++tok_checkiter; 165 LOG(3, "INFO: key is '" << *tok_paramiter << "', value is '" << *tok_valueiter << "'."); 166 // TODO: throw exception instead of ASSERT 167 ASSERT(tok_paramiter != paramtokens.end(), 168 "operator<< on FormatParser_Parameters - missing value before ' =' in token "+*tok_iter+"!"); 169 ASSERT(tok_valueiter != paramtokens.end(), 170 "operator<< on FormatParser_Parameters - missing value after ' =' in token "+*tok_iter+"!"); 171 ASSERT(tok_checkiter == paramtokens.end(), 172 "operator<< on FormatParser_Parameters - still more tokens after ' =' in token "+*tok_iter+":" 173 +*tok_checkiter+"!"); 174 std::string key(*tok_paramiter); 175 std::string value(*tok_valueiter); 176 boost::trim(key); 177 boost::trim(value); 178 tokenizer ticklesstokens(value, ticksep); 179 ASSERT(ticklesstokens.begin() != ticklesstokens.end(), 180 "operator<< on FormatParser_Parameters - no tokens present after removing ticks in token "+*tok_valueiter+"!"); 181 std::stringstream valuestream(*(ticklesstokens.begin())); 182 //LOG(2, "INFO: Token pair is " << key << "," << valuestream.str()); 183 184 // TODO: throw exception instead of DoeLog() 185 ASSERT(params.haveParameter(key), 186 "operator >> on FormatParser_Parameters - unknown parameter name '" 187 +key+"' with value "+valuestream.str()+"!"); 188 if (params.haveParameter(key)) { 189 Parameter *instance = params.getParameter(key); 190 instance->set(valuestream.str()); 191 } 192 } else { 193 ist.setstate(std::ios::eofbit); 194 } 195 } 196 return ist; 197 } -
src/Parser/FormatParser_Parameters.hpp
rf758dd r7f570c 14 14 #endif 15 15 16 #include <iosfwd> 17 16 18 #include "CodePatterns/Clone.hpp" 17 19 … … 27 29 class FormatParser_Parameters : public Clone<FormatParser_Parameters> 28 30 { 31 //!> allow operator access to storage for easier printing. 32 friend std::ostream & operator << (std::ostream& ost, const FormatParser_Parameters ¶ms); 29 33 public: 30 34 FormatParser_Parameters(); … … 45 49 }; 46 50 51 std::ostream & operator << (std::ostream& ost, const FormatParser_Parameters ¶ms); 52 53 std::istream & operator >> (std::istream& ist, FormatParser_Parameters ¶ms); 54 47 55 48 56 #endif /* FORMATPARSER_PARAMETERS_HPP_ */ -
src/Parser/MpqcParser_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 24 #include "CodePatterns/MemDebug.hpp"25 23 26 24 #include "CodePatterns/Log.hpp" 27 25 28 26 #include "MpqcParser.hpp" 29 30 27 #include "MpqcParser_Parameters.hpp" 31 28 … … 182 179 } 183 180 184 185 /** Output operator for the contents of MpqcParser_Parameters::params.186 *187 * @param ost output stream188 * @param params reference to MpqcParser_Parameters containing params.189 * @return reference to output stream for concatenation190 */191 std::ostream & operator << (std::ostream& ost, const MpqcParser_Parameters ¶ms)192 {193 // this is ugly, but with boost::any to safeguard const-ness is plain impossible194 std::ostringstream output;195 for (size_t param = (enum MpqcParser_Parameters::Parameters)0;196 param < (size_t)MpqcParser_Parameters::unknownParam; ++param)197 output << params.getParameterName((enum MpqcParser_Parameters::Parameters)param)198 << "=" << params.getParameter((enum MpqcParser_Parameters::Parameters)param) << ";";199 ost << output.str();200 return ost;201 }202 203 /** Input operator for a list of parameters to place into \a params.204 *205 * @param ist input stream206 * @param params parameters to parse into207 * @return input stream for concatenation208 */209 std::istream & operator >> (std::istream& ist, MpqcParser_Parameters ¶ms)210 {211 typedef boost::tokenizer<boost::char_separator<char> >212 tokenizer;213 boost::char_separator<char> semicolonsep(";");214 boost::char_separator<char> equalitysep(" =");215 boost::char_separator<char> ticksep("\"");216 std::string line;217 std::getline( ist, line );218 //DoLog(0) && (Log() << Verbose(0) << "INFO: full line of parameters is '" << line << "'" << std::endl);219 tokenizer tokens(line, semicolonsep);220 ASSERT(tokens.begin() != tokens.end(),221 "operator<< on MpqcParser_Parameters - empty string, need at least ';' in line "+line+"!");222 for (tokenizer::iterator tok_iter = tokens.begin();223 tok_iter != tokens.end(); ++tok_iter) {224 tokenizer paramtokens(*tok_iter, equalitysep);225 if (paramtokens.begin() != paramtokens.end()) {226 tokenizer::iterator tok_paramiter = paramtokens.begin();227 tokenizer::iterator tok_valueiter = tok_paramiter;228 tokenizer::iterator tok_checkiter = ++tok_valueiter;229 ++tok_checkiter;230 // TODO: throw exception instead of ASSERT231 ASSERT(tok_paramiter != paramtokens.end(),232 "operator<< on MpqcParser_Parameters - missing value before ' =' in token "+*tok_iter+"!");233 ASSERT(tok_valueiter != paramtokens.end(),234 "operator<< on MpqcParser_Parameters - missing value after ' =' in token "+*tok_iter+"!");235 ASSERT(tok_checkiter == paramtokens.end(),236 "operator<< on MpqcParser_Parameters - still more tokens after ' =' in token "+*tok_iter+":"237 +*tok_checkiter+"!");238 std::stringstream keystream(*tok_paramiter);239 std::string key;240 keystream >> ws >> key;241 tokenizer ticklesstokens(*tok_valueiter, ticksep);242 ASSERT(ticklesstokens.begin() != ticklesstokens.end(),243 "operator<< on MpqcParser_Parameters - no tokens present after removing ticks in token "+*tok_valueiter+"!");244 std::stringstream valuestream(*(ticklesstokens.begin()));245 DoLog(2) && (Log() << Verbose(2)246 << "INFO: Token pair is " << key << "," << valuestream.str() << std::endl);247 248 // TODO: throw exception instead of DoeLog()249 ASSERT(params.haveParameter(key),250 "operator >> on MpqcParser_Parameters - unknown parameter name '"251 +key+"' with value "+valuestream.str()+"!");252 if (params.haveParameter(key)) {253 Parameter *instance = params.FormatParser_Parameters::getParameter(key);254 instance->set(valuestream.str());255 }256 } else {257 ist.setstate(std::ios::eofbit);258 }259 }260 return ist;261 }262 263 181 /** Checks whether all elements in the world also have parameters in the basis. 264 182 * -
src/Parser/MpqcParser_Parameters.hpp
rf758dd r7f570c 14 14 #endif 15 15 16 #include <iosfwd>17 16 #include <list> 18 17 #include <map> … … 124 123 }; 125 124 126 std::ostream & operator << (std::ostream& ost, const MpqcParser_Parameters ¶ms);127 128 std::istream & operator >> (std::istream& ist, MpqcParser_Parameters ¶ms);129 130 125 #endif /* MPQCPARSER_PARAMETERS_HPP_ */ -
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 * -
src/Parser/Psi3Parser_Parameters.hpp
rf758dd r7f570c 14 14 #endif 15 15 16 #include <iosfwd>17 16 #include <list> 18 17 #include <map> … … 20 19 21 20 #include "CodePatterns/Clone.hpp" 22 #include "CodePatterns/Log.hpp"23 21 24 22 #include "Parser/FormatParser_Parameters.hpp" … … 208 206 }; 209 207 210 std::ostream & operator << (std::ostream& ost, const Psi3Parser_Parameters ¶ms);211 212 std::istream & operator >> (std::istream& ist, Psi3Parser_Parameters ¶ms);213 214 208 #endif /* PSI3PARSER_PARAMETERS_HPP_ */
Note:
See TracChangeset
for help on using the changeset viewer.