Changeset 266875
- Timestamp:
- Feb 4, 2011, 6:56:38 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, 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:
- 72d108
- Parents:
- 15f6e9
- git-author:
- Frederik Heber <heber@…> (02/01/11 11:09:17)
- git-committer:
- Frederik Heber <heber@…> (02/04/11 18:56:38)
- Location:
- src
- Files:
-
- 6 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
src/Descriptors/MoleculeFormulaDescriptor.cpp
r15f6e9 r266875 42 42 } 43 43 44 MoleculeDescriptor MoleculeByFormula(const std::string &_formula) throw( ParseError){44 MoleculeDescriptor MoleculeByFormula(const std::string &_formula) throw(FormulaStringParseException){ 45 45 Formula formula(_formula); 46 46 return MoleculeByFormula(formula); -
src/Descriptors/MoleculeFormulaDescriptor.hpp
r15f6e9 r266875 16 16 17 17 #include "Descriptors/MoleculeDescriptor.hpp" 18 #include "Exceptions/ ParseError.hpp"18 #include "Exceptions/FormulaStringParseException.hpp" 19 19 20 20 class Formula; 21 21 22 22 MoleculeDescriptor MoleculeByFormula(const Formula&); 23 MoleculeDescriptor MoleculeByFormula(const std::string&) throw( ParseError);23 MoleculeDescriptor MoleculeByFormula(const std::string&) throw(FormulaStringParseException); 24 24 25 25 #endif /* MOLECULEFORMULADESCRIPTOR_HPP_ */ -
src/Exceptions/FormulaStringParseException.cpp
r15f6e9 r266875 7 7 8 8 /* 9 * ParseError.cpp9 * FormulaStringParseException.cpp 10 10 * 11 11 * Created on: Jul 21, 2010 … … 20 20 #include "CodePatterns/MemDebug.hpp" 21 21 22 #include " ParseError.hpp"22 #include "FormulaStringParseException.hpp" 23 23 24 ParseError::ParseError(std::string file, int line) :24 FormulaStringParseException::FormulaStringParseException(std::string file, int line) : 25 25 CustomException(file,line) 26 26 {} 27 27 28 ParseError::~ParseError() throw(){}28 FormulaStringParseException::~FormulaStringParseException() throw(){} 29 29 30 const char* ParseError::what() const throw(){30 const char* FormulaStringParseException::what() const throw(){ 31 31 return "Could not parse string"; 32 32 } -
src/Exceptions/FormulaStringParseException.hpp
r15f6e9 r266875 1 1 /* 2 * ParseError.hpp2 * FormulaStringParseException.hpp 3 3 * 4 4 * Created on: Jul 21, 2010 … … 17 17 #include "Exceptions/CustomException.hpp" 18 18 19 class ParseError: public CustomException19 class FormulaStringParseException : public CustomException 20 20 { 21 21 public: 22 ParseError(std::string file, int line);23 virtual ~ ParseError() throw();22 FormulaStringParseException(std::string file, int line); 23 virtual ~FormulaStringParseException() throw(); 24 24 25 25 virtual const char* what() const throw(); -
src/Exceptions/Makefile.am
r15f6e9 r266875 16 16 NotOnSurfaceException.cpp \ 17 17 ShapeException.cpp \ 18 ParseError.cpp \18 FormulaStringParseException.cpp \ 19 19 SkewException.cpp \ 20 20 ZeroVectorException.cpp … … 29 29 NotInvertibleException.hpp \ 30 30 NotOnSurfaceException.hpp \ 31 ParseError.hpp \31 FormulaStringParseException.hpp \ 32 32 SkewException.hpp \ 33 33 ZeroVectorException.hpp -
src/Formula.cpp
r15f6e9 r266875 68 68 } 69 69 70 void Formula::fromString(const std::string &formula) throw( ParseError){70 void Formula::fromString(const std::string &formula) throw(FormulaStringParseException){ 71 71 // make this transactional, in case an error is thrown 72 72 Formula res; … … 77 77 } 78 78 79 int Formula::parseMaybeNumber(string::const_iterator &it,string::const_iterator &end) throw( ParseError){79 int Formula::parseMaybeNumber(string::const_iterator &it,string::const_iterator &end) throw(FormulaStringParseException){ 80 80 static const range<char> Numbers = makeRange('0',static_cast<char>('9'+1)); 81 81 int count = 0; … … 87 87 } 88 88 89 void Formula::parseFromString(string::const_iterator &it,string::const_iterator &end,char delimiter) throw( ParseError){89 void Formula::parseFromString(string::const_iterator &it,string::const_iterator &end,char delimiter) throw(FormulaStringParseException){ 90 90 // some constants needed for parsing... Assumes ASCII, change if other encodings are used 91 91 static const range<char> CapitalLetters = makeRange('A',static_cast<char>('Z'+1)); … … 103 103 sub.parseFromString(++it,end,nextdelim); 104 104 if(!sub.getElementCount()){ 105 throw( ParseError(__FILE__,__LINE__));105 throw(FormulaStringParseException(__FILE__,__LINE__)); 106 106 } 107 107 int count = parseMaybeNumber(++it,end); … … 112 112 // Atom names start with a capital letter 113 113 if(!CapitalLetters.isInRange(*it)) 114 throw( ParseError(__FILE__,__LINE__));114 throw(FormulaStringParseException(__FILE__,__LINE__)); 115 115 shorthand+=(*it++); 116 116 // the rest of the name follows … … 120 120 // test if the shorthand exists 121 121 if(!World::getInstance().getPeriode()->FindElement(shorthand)) 122 throw( ParseError(__FILE__,__LINE__));122 throw(FormulaStringParseException(__FILE__,__LINE__)); 123 123 // done, we can get the next one 124 124 addElements(shorthand,count); 125 125 } 126 126 if(it==end && delimiter!=0){ 127 throw( ParseError(__FILE__,__LINE__));127 throw(FormulaStringParseException(__FILE__,__LINE__)); 128 128 } 129 129 } -
src/Formula.hpp
r15f6e9 r266875 19 19 #include <iterator> 20 20 21 #include "Exceptions/ ParseError.hpp"21 #include "Exceptions/FormulaStringParseException.hpp" 22 22 23 23 #include "types.hpp" … … 71 71 72 72 std::string toString() const; 73 void fromString(const std::string&) throw( ParseError);73 void fromString(const std::string&) throw(FormulaStringParseException); 74 74 bool checkOut(std::ostream*) const; 75 75 … … 112 112 113 113 private: 114 void parseFromString(std::string::const_iterator&,std::string::const_iterator&,char) throw( ParseError);115 int parseMaybeNumber(std::string::const_iterator &it,std::string::const_iterator &end) throw( ParseError);114 void parseFromString(std::string::const_iterator&,std::string::const_iterator&,char) throw(FormulaStringParseException); 115 int parseMaybeNumber(std::string::const_iterator &it,std::string::const_iterator &end) throw(FormulaStringParseException); 116 116 // this contains all counts of elements in the formula 117 117 // the size of the actual structure might be used in comparisons -
src/unittests/FormulaUnitTest.cpp
r15f6e9 r266875 246 246 } 247 247 { 248 CPPUNIT_ASSERT_THROW(Formula formula("74107"), ParseError);249 CPPUNIT_ASSERT_THROW(Formula formula(" "), ParseError);250 CPPUNIT_ASSERT_THROW(Formula formula("nAcL"), ParseError);251 CPPUNIT_ASSERT_THROW(Formula formula("NAcL"), ParseError);252 CPPUNIT_ASSERT_THROW(Formula formula("Na Cl"), ParseError);253 CPPUNIT_ASSERT_THROW(Formula formula("1NaCl"), ParseError);254 CPPUNIT_ASSERT_THROW(Formula formula("Mag"), ParseError);255 CPPUNIT_ASSERT_THROW(Formula formula("AgCl)"), ParseError);256 CPPUNIT_ASSERT_THROW(Formula formula("(Na"), ParseError);257 CPPUNIT_ASSERT_THROW(Formula formula("(Mag)"), ParseError);258 CPPUNIT_ASSERT_THROW(Formula formula("MgCl2)"), ParseError);259 CPPUNIT_ASSERT_THROW(Formula formula("((MgCl2)"), ParseError);260 CPPUNIT_ASSERT_THROW(Formula formula("(MgCl2))"), ParseError);261 CPPUNIT_ASSERT_THROW(Formula formula("(MgCl2]"), ParseError);262 CPPUNIT_ASSERT_THROW(Formula formula("[MgCl2)"), ParseError);263 CPPUNIT_ASSERT_THROW(Formula formula("N(aCl"), ParseError);264 CPPUNIT_ASSERT_THROW(Formula formula("Na()Cl"), ParseError);248 CPPUNIT_ASSERT_THROW(Formula formula("74107"),FormulaStringParseException); 249 CPPUNIT_ASSERT_THROW(Formula formula(" "),FormulaStringParseException); 250 CPPUNIT_ASSERT_THROW(Formula formula("nAcL"),FormulaStringParseException); 251 CPPUNIT_ASSERT_THROW(Formula formula("NAcL"),FormulaStringParseException); 252 CPPUNIT_ASSERT_THROW(Formula formula("Na Cl"),FormulaStringParseException); 253 CPPUNIT_ASSERT_THROW(Formula formula("1NaCl"),FormulaStringParseException); 254 CPPUNIT_ASSERT_THROW(Formula formula("Mag"),FormulaStringParseException); 255 CPPUNIT_ASSERT_THROW(Formula formula("AgCl)"),FormulaStringParseException); 256 CPPUNIT_ASSERT_THROW(Formula formula("(Na"),FormulaStringParseException); 257 CPPUNIT_ASSERT_THROW(Formula formula("(Mag)"),FormulaStringParseException); 258 CPPUNIT_ASSERT_THROW(Formula formula("MgCl2)"),FormulaStringParseException); 259 CPPUNIT_ASSERT_THROW(Formula formula("((MgCl2)"),FormulaStringParseException); 260 CPPUNIT_ASSERT_THROW(Formula formula("(MgCl2))"),FormulaStringParseException); 261 CPPUNIT_ASSERT_THROW(Formula formula("(MgCl2]"),FormulaStringParseException); 262 CPPUNIT_ASSERT_THROW(Formula formula("[MgCl2)"),FormulaStringParseException); 263 CPPUNIT_ASSERT_THROW(Formula formula("N(aCl"),FormulaStringParseException); 264 CPPUNIT_ASSERT_THROW(Formula formula("Na()Cl"),FormulaStringParseException); 265 265 } 266 266
Note:
See TracChangeset
for help on using the changeset viewer.