source: src/UIElements/CommandLineUI/CommandLineParser_validate.cpp@ d5240d

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
Last change on this file since d5240d was d5240d, checked in by Frederik Heber <heber@…>, 14 years ago

FIX: Linking to non-system boost is working now.

  • FIX: BOOST_CPPFLAGS was not present in AM_CPPFLAGS in all Makefile.am
  • Hence, not the correct includes were used and linking occured with undefined reference errors (because of version conflict between system-wide installed and non-system boost)
  • validate()s now make version check of boost as signature of validation_error)_ changed in boost 1.42
  • added AX_BOOST_SYSTEM to configure.ac and BOOST_SYSTEM_LIB to src/Makefile.am and src/unittests/Makefile.am. Otherwise we have to set an rpath to let it find the lib needed by other boost libs in non-system boost configs.
  • Property mode set to 100644
File size: 5.5 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * CommandLineParser_validate.cpp
10 *
11 * Created on: Nov 8, 2010
12 * Author: heber
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include "Helpers/MemDebug.hpp"
21
22#include <boost/version.hpp>
23
24#include <iostream>
25#include <string>
26
27#include "Actions/Values.hpp"
28#include "CommandLineParser_validate.hpp"
29
30/** boost::program_options validator specialization for VectorValue.
31 * \param &v reference for return value
32 * \param &values string vector of scanned options
33 * \param *
34 * \param
35 *
36 */
37void validate(boost::any& v, const std::vector<std::string>& values, VectorValue *, int)
38{
39 VectorValue VV;
40 std::vector<std::string> components;
41
42 // split comma-separated values
43 if (values.size() != 1) {
44 std::cerr << "Not one vector but " << values.size() << " given " << std::endl;
45#if BOOST_VERSION < 104200
46 throw boost::program_options::validation_error("Unequal to one vector given");
47#else
48 throw boost::program_options::validation_error(
49 boost::program_options::validation_error::invalid_option_value,
50 std::string("value"),
51 std::string("VectorValue")
52 );
53#endif
54 }
55 std::string argument(values.at(0));
56 std::string::iterator Aiter = argument.begin();
57 std::string::iterator Biter = argument.begin();
58 for (; Aiter != argument.end(); ++Aiter) {
59 if (*Aiter == ',') {
60 components.push_back(std::string(Biter,Aiter));
61 do {
62 Aiter++;
63 } while (*Aiter == ' ' || *Aiter == '\t');
64 Biter = Aiter;
65 }
66 }
67 components.push_back(std::string(Biter,argument.end()));
68
69 if (components.size() != 3) {
70 std::cerr << "Specified vector does not have three components but " << components.size() << std::endl;
71#if BOOST_VERSION < 104200
72 throw boost::program_options::validation_error("Specified vector does not have three components");
73#else
74 throw boost::program_options::validation_error(
75 boost::program_options::validation_error::invalid_option_value,
76 std::string("value"),
77 std::string("VectorValue")
78 );
79#endif
80 }
81 VV.x = boost::lexical_cast<double>(components.at(0));
82 VV.y = boost::lexical_cast<double>(components.at(1));
83 VV.z = boost::lexical_cast<double>(components.at(2));
84 v = boost::any(VectorValue(VV));
85}
86
87void validate(boost::any& v, const std::vector<std::string>& values, BoxValue *, int)
88{
89 BoxValue BV;
90 std::vector<std::string> components;
91
92 // split comma-separated values
93 if (values.size() != 1) {
94 std::cerr << "Not one vector but " << values.size() << " given " << std::endl;
95#if BOOST_VERSION < 104200
96 throw boost::program_options::validation_error("Unequal to one vector given");
97#else
98 throw boost::program_options::validation_error(
99 boost::program_options::validation_error::invalid_option_value,
100 std::string("value"),
101 std::string("BoxValue")
102 );
103#endif
104 }
105 std::string argument(values.at(0));
106 std::string::iterator Aiter = argument.begin();
107 std::string::iterator Biter = argument.begin();
108 for (; Aiter != argument.end(); ++Aiter) {
109 if (*Aiter == ',') {
110 components.push_back(std::string(Biter,Aiter));
111 do {
112 Aiter++;
113 } while (*Aiter == ' ' || *Aiter == '\t');
114 Biter = Aiter;
115 }
116 }
117 components.push_back(std::string(Biter,argument.end()));
118
119 if (components.size() != 6) {
120 std::cerr << "Specified vector does not have three components but " << components.size() << std::endl;
121#if BOOST_VERSION < 104200
122 throw boost::program_options::validation_error("Specified symmetric box matrix does not have six components");
123#else
124 throw boost::program_options::validation_error(
125 boost::program_options::validation_error::invalid_option_value,
126 std::string("value"),
127 std::string("BoxValue")
128 );
129#endif
130 }
131 BV.xx = boost::lexical_cast<double>(components.at(0));
132 BV.yx = boost::lexical_cast<double>(components.at(1));
133 BV.yy = boost::lexical_cast<double>(components.at(2));
134 BV.zx = boost::lexical_cast<double>(components.at(3));
135 BV.zy = boost::lexical_cast<double>(components.at(4));
136 BV.zz = boost::lexical_cast<double>(components.at(5));
137 v = boost::any(BoxValue(BV));
138}
139
140/** boost::program_options validator specialization for boost::filesystem::path.
141 * \param &v reference for return value
142 * \param &values string vector of scanned options
143 * \param *
144 * \param
145 *
146 */
147void validate(boost::any& v, const std::vector<std::string>& values, boost::filesystem::path *, int)
148{
149 boost::filesystem::path filename;
150
151 std::cerr << "boost::filesystem::path validator used." << std::endl;
152
153 // split comma-separated values
154 if (values.size() != 1) {
155 std::cerr << "Not one file but " << values.size() << " given " << std::endl;
156#if BOOST_VERSION < 104200
157 throw boost::program_options::validation_error("Unequal to one file given");
158#else
159 if (values.size() == 0) {
160 throw boost::program_options::validation_error(
161 boost::program_options::validation_error::at_least_one_value_required,
162 std::string("value"),
163 std::string("boost::filesystem::path")
164 );
165 } else {
166 throw boost::program_options::validation_error(
167 boost::program_options::validation_error::multiple_values_not_allowed,
168 std::string("value"),
169 std::string("boost::filesystem::path")
170 );
171 }
172#endif
173 }
174 filename = values.at(0);
175 v = boost::any(boost::filesystem::path(filename));
176}
177
Note: See TracBrowser for help on using the repository browser.